"MDL-15592, change js function name toggle() to menu_toggle(), to be friendly with...
[moodle-linuxchix.git] / admin / index.php
blobcee968a16fa733fb386dbe0b2ef5ffb59b8a06e9
1 <?php // $Id$
3 /// Check that config.php exists, if not then call the install script
4 if (!file_exists('../config.php')) {
5 header('Location: ../install.php');
6 die;
9 /// Check that PHP is of a sufficient version
10 /// Moved here because older versions do not allow while(@ob_end_clean());
11 if (version_compare(phpversion(), "4.3.0") < 0) {
12 $phpversion = phpversion();
13 echo "Sorry, Moodle requires PHP 4.3.0 or later (currently using version $phpversion)";
14 die;
17 /// Turn off time limits and try to flush everything all the time, sometimes upgrades can be slow.
19 @set_time_limit(0);
20 @ob_implicit_flush(true);
21 while(@ob_end_clean()); // ob_end_flush prevents sending of headers
24 require_once('../config.php');
25 require_once($CFG->libdir.'/adminlib.php'); // Contains various admin-only functions
26 require_once($CFG->libdir.'/ddllib.php'); // Install/upgrade related db functions
27 require_once($CFG->libdir.'/db/upgradelib.php'); // Upgrade-related functions
29 $id = optional_param('id', '', PARAM_TEXT);
30 $confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
31 $confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL);
32 $agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
33 $autopilot = optional_param('autopilot', 0, PARAM_BOOL);
34 $ignoreupgradewarning = optional_param('ignoreupgradewarning', 0, PARAM_BOOL);
35 $confirmplugincheck = optional_param('confirmplugincheck', 0, PARAM_BOOL);
37 /// check upgrade status first
38 if ($ignoreupgradewarning and !empty($_SESSION['upgraderunning'])) {
39 $_SESSION['upgraderunning'] = 0;
41 upgrade_check_running("Upgrade already running in this session, please wait!<br />Click on the exclamation marks to ignore this warning (<a href=\"index.php?ignoreupgradewarning=1\">!!!</a>).", 10);
43 /// set install/upgrade autocontinue session flag
44 if ($autopilot) {
45 $_SESSION['installautopilot'] = $autopilot;
48 /// Check some PHP server settings
50 $documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
52 if (ini_get_bool('session.auto_start')) {
53 error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
56 if (ini_get_bool('magic_quotes_runtime')) {
57 error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink");
60 if (!ini_get_bool('file_uploads')) {
61 error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
64 if (empty($CFG->prefix) && $CFG->dbfamily != 'mysql') { //Enforce prefixes for everybody but mysql
65 error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')');
68 if ($CFG->dbfamily == 'oracle' && strlen($CFG->prefix) > 2) { //Max prefix length for Oracle is 2cc
69 error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.');
72 /// Check that config.php has been edited
74 if ($CFG->wwwroot == "http://example.com/moodle") {
75 error("Moodle has not been configured yet. You need to edit config.php first.");
79 /// Check settings in config.php
81 $dirroot = dirname(realpath("../index.php"));
82 if (!empty($dirroot) and $dirroot != $CFG->dirroot) {
83 error("Please fix your settings in config.php:
84 <p>You have:
85 <p>\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
86 <p>but it should be:
87 <p>\$CFG->dirroot = \"".addslashes($dirroot)."\";",
88 "./");
91 /// Set some necessary variables during set-up to avoid PHP warnings later on this page
92 if (!isset($CFG->framename)) {
93 $CFG->framename = "_top";
95 if (!isset($CFG->release)) {
96 $CFG->release = "";
98 if (!isset($CFG->version)) {
99 $CFG->version = "";
102 if (is_readable("$CFG->dirroot/version.php")) {
103 include_once("$CFG->dirroot/version.php"); # defines $version
106 if (!$version or !$release) {
107 error('Main version.php was not readable or specified');# without version, stop
110 /// Check if the main tables have been installed yet or not.
112 if (! $tables = $db->Metatables() ) { // No tables yet at all.
113 $maintables = false;
115 } else { // Check for missing main tables
116 $maintables = true;
117 $mtables = array("config", "course", "course_categories", "course_modules",
118 "course_sections", "log", "log_display", "modules",
119 "user");
120 foreach ($mtables as $mtable) {
121 if (!in_array($CFG->prefix.$mtable, $tables)) {
122 $maintables = false;
123 break;
128 if (! $maintables) {
129 /// hide errors from headers in case debug enabled in config.php
130 $origdebug = $CFG->debug;
131 $CFG->debug = DEBUG_MINIMAL;
132 error_reporting($CFG->debug);
133 if (empty($agreelicense)) {
134 $strlicense = get_string('license');
135 $navigation = build_navigation(array(array('name'=>$strlicense, 'link'=>null, 'type'=>'misc')));
136 print_header($strlicense, $strlicense, $navigation, "", "", false, "&nbsp;", "&nbsp;");
137 print_heading("<a href=\"http://moodle.org\">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment");
138 print_heading(get_string('copyrightnotice'));
139 print_box(text_to_html(get_string('gpl')), 'copyrightnotice');
140 echo "<br />";
141 notice_yesno(get_string('doyouagree'), "index.php?agreelicense=1",
142 "http://docs.moodle.org/en/License");
143 print_footer('none');
144 exit;
146 if (empty($confirmrelease)) {
147 $strcurrentrelease = get_string("currentrelease");
148 $navigation = build_navigation(array(array('name'=>$strcurrentrelease, 'link'=>null, 'type'=>'misc')));
149 print_header($strcurrentrelease, $strcurrentrelease, $navigation, "", "", false, "&nbsp;", "&nbsp;");
150 print_heading("Moodle $release");
151 print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'), 'generalbox boxaligncenter boxwidthwide');
152 echo '<form action="index.php"><div>';
153 echo '<input type="hidden" name="agreelicense" value="1" />';
154 echo '<input type="hidden" name="confirmrelease" value="1" />';
155 echo '</div>';
156 echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="1" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
157 echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
158 echo '</form>';
159 print_footer('none');
160 die;
164 $strdatabasesetup = get_string("databasesetup");
165 $strdatabasesuccess = get_string("databasesuccess");
166 $navigation = build_navigation(array(array('name'=>$strdatabasesetup, 'link'=>null, 'type'=>'misc')));
167 print_header($strdatabasesetup, $strdatabasesetup, $navigation,
168 "", upgrade_get_javascript(), false, "&nbsp;", "&nbsp;");
169 /// return to original debugging level
170 $CFG->debug = $origdebug;
171 error_reporting($CFG->debug);
172 upgrade_log_start();
173 $db->debug = true;
175 /// Both old .sql files and new install.xml are supported
176 /// But we prioritise install.xml (XMLDB) if present
178 change_db_encoding(); // first try to change db encoding to utf8
179 if (!setup_is_unicodedb()) {
180 // If could not convert successfully, throw error, and prevent installation
181 print_error('unicoderequired', 'admin');
184 $status = false;
185 if (file_exists("$CFG->libdir/db/install.xml")) {
186 $status = install_from_xmldb_file("$CFG->libdir/db/install.xml"); //New method
187 } else if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
188 $status = modify_database("$CFG->libdir/db/$CFG->dbtype.sql"); //Old method
189 } else {
190 error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present. See the lib/db directory.");
193 // all new installs are in unicode - keep for backwards compatibility and 1.8 upgrade checks
194 set_config('unicodedb', 1);
196 /// Continue with the instalation
197 $db->debug = false;
198 if ($status) {
200 /// Groups install is now in core above.
202 // Install the roles system.
203 moodle_install_roles();
204 set_config('statsrolesupgraded',time());
206 // install core event handlers
207 events_update_definition();
209 /// This is used to handle any settings that must exist in $CFG but which do not exist in
210 /// admin_get_root()/$ADMIN as admin_setting objects (there are some exceptions).
211 apply_default_exception_settings(array('auth' => 'email',
212 'auth_pop3mailbox' => 'INBOX',
213 'enrol' => 'manual',
214 'enrol_plugins_enabled' => 'manual',
215 'style' => 'default',
216 'template' => 'default',
217 'theme' => 'standardwhite',
218 'filter_multilang_converted' => 1));
220 // Write default settings unconditionally (i.e. even if a setting is already set, overwrite it)
221 // (this should only have any effect during initial install).
222 admin_apply_default_settings(NULL, true);
224 notify($strdatabasesuccess, "green");
225 require_once $CFG->dirroot.'/mnet/lib.php';
226 } else {
227 error("Error: Main databases NOT set up successfully");
229 print_continue('index.php');
230 print_footer('none');
231 die;
235 /// Check version of Moodle code on disk compared with database
236 /// and upgrade if possible.
238 if (file_exists("$CFG->dirroot/lib/db/$CFG->dbtype.php")) {
239 include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines old upgrades
241 if (file_exists("$CFG->dirroot/lib/db/upgrade.php")) {
242 include_once("$CFG->dirroot/lib/db/upgrade.php"); # defines new upgrades
245 $stradministration = get_string("administration");
247 if ($CFG->version) {
248 if ($version > $CFG->version) { // upgrade
250 /// If the database is not already Unicode then we do not allow upgrading!
251 /// Instead, we print an error telling them to upgrade to 1.7 first. MDL-6857
252 if (empty($CFG->unicodedb)) {
253 print_error('unicodeupgradeerror', 'error', '', $version);
256 $a->oldversion = "$CFG->release ($CFG->version)";
257 $a->newversion = "$release ($version)";
258 $strdatabasechecking = get_string("databasechecking", "", $a);
260 // hide errors from headers in case debug is enabled
261 $origdebug = $CFG->debug;
262 $CFG->debug = DEBUG_MINIMAL;
263 error_reporting($CFG->debug);
265 // logo ut in case we are upgrading from pre 1.9 version in order to prevent
266 // weird session/role problems caused by incorrect data in USER and SESSION
267 if ($CFG->version < 2007101500) {
268 require_logout();
271 if (empty($confirmupgrade)) {
272 $navigation = build_navigation(array(array('name'=>$strdatabasechecking, 'link'=>null, 'type'=>'misc')));
273 print_header($strdatabasechecking, $stradministration, $navigation,
274 "", "", false, "&nbsp;", "&nbsp;");
276 notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=1', 'index.php');
277 print_footer('none');
278 exit;
280 } else if (empty($confirmrelease)){
281 $strcurrentrelease = get_string("currentrelease");
282 $navigation = build_navigation(array(array('name'=>$strcurrentrelease, 'link'=>null, 'type'=>'misc')));
283 print_header($strcurrentrelease, $strcurrentrelease, $navigation, "", "", false, "&nbsp;", "&nbsp;");
284 print_heading("Moodle $release");
285 print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes'));
287 require_once($CFG->libdir.'/environmentlib.php');
288 print_heading(get_string('environment', 'admin'));
289 if (!check_moodle_environment($release, $environment_results, true)) {
290 print_box_start('generalbox', 'notice'); // MDL-8330
291 print_string('langpackwillbeupdated', 'admin');
292 print_box_end();
293 notice_yesno(get_string('environmenterrorupgrade', 'admin'),
294 'index.php?confirmupgrade=1&confirmrelease=1', 'index.php');
295 } else {
296 notify(get_string('environmentok', 'admin'), 'notifysuccess');
297 print_box_start('generalbox', 'notice'); // MDL-8330
298 print_string('langpackwillbeupdated', 'admin');
299 print_box_end();
300 echo '<form action="index.php"><div>';
301 echo '<input type="hidden" name="confirmupgrade" value="1" />';
302 echo '<input type="hidden" name="confirmrelease" value="1" />';
303 echo '</div>';
304 echo '<div class="continuebutton">';
305 echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
306 echo '</form>';
309 print_footer('none');
310 die;
311 } elseif (empty($confirmplugincheck)) {
312 $strplugincheck = get_string('plugincheck');
313 $navigation = build_navigation(array(array('name'=>$strplugincheck, 'link'=>null, 'type'=>'misc')));
314 print_header($strplugincheck, $strplugincheck, $navigation, "", "", false, "&nbsp;", "&nbsp;");
315 print_heading($strplugincheck);
316 print_box_start('generalbox', 'notice'); // MDL-8330
317 print_string('pluginchecknotice');
318 print_box_end();
319 print_plugin_tables();
320 echo "<br />";
321 echo '<div class="continuebutton">';
322 print_single_button('index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1), get_string('reload'), 'get');
323 echo '</div><br />';
324 echo '<form action="index.php"><div>';
325 echo '<input type="hidden" name="confirmupgrade" value="1" />';
326 echo '<input type="hidden" name="confirmrelease" value="1" />';
327 echo '<input type="hidden" name="confirmplugincheck" value="1" />';
328 echo '</div>';
329 echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="1" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
330 echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
331 echo '</form>';
332 print_footer('none');
333 die();
335 } else {
336 $strdatabasesuccess = get_string("databasesuccess");
337 $navigation = build_navigation(array(array('name'=>$strdatabasesuccess, 'link'=>null, 'type'=>'misc')));
338 print_header($strdatabasechecking, $stradministration, $navigation,
339 "", upgrade_get_javascript(), false, "&nbsp;", "&nbsp;");
341 /// return to original debugging level
342 $CFG->debug = $origdebug;
343 error_reporting($CFG->debug);
344 upgrade_log_start();
346 /// Upgrade current language pack if we can
347 upgrade_language_pack();
349 print_heading($strdatabasechecking);
350 $db->debug=true;
351 /// Launch the old main upgrade (if exists)
352 $status = true;
353 if (function_exists('main_upgrade')) {
354 $status = main_upgrade($CFG->version);
356 /// If succesful and exists launch the new main upgrade (XMLDB), called xmldb_main_upgrade
357 if ($status && function_exists('xmldb_main_upgrade')) {
358 $status = xmldb_main_upgrade($CFG->version);
360 $db->debug=false;
361 /// If successful, continue upgrading roles and setting everything properly
362 if ($status) {
363 if (empty($CFG->rolesactive)) {
365 /// Groups upgrade is now in core above.
367 // Upgrade to the roles system.
368 moodle_install_roles();
369 set_config('rolesactive', 1);
370 } else if (!update_capabilities()) {
371 error('Had trouble upgrading the core capabilities for the Roles System');
373 // update core events
374 events_update_definition();
376 require_once($CFG->libdir.'/statslib.php');
377 if (!stats_upgrade_for_roles_wrapper()) {
378 notify('Couldn\'t upgrade the stats tables to use the new roles system');
380 if (set_config("version", $version)) {
381 remove_dir($CFG->dataroot . '/cache', true); // flush cache
382 notify($strdatabasesuccess, "green");
383 print_continue("upgradesettings.php");
384 print_footer('none');
385 exit;
386 } else {
387 error('Upgrade failed! (Could not update version in config table)');
389 /// Main upgrade not success
390 } else {
391 notify('Main Upgrade failed! See lib/db/upgrade.php');
392 print_continue('index.php?confirmupgrade=1&amp;confirmrelease=1&amp;confirmplugincheck=1');
393 print_footer('none');
394 die;
396 upgrade_log_finish();
398 } else if ($version < $CFG->version) {
399 upgrade_log_start();
400 notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
401 upgrade_log_finish();
403 } else {
404 if (!set_config("version", $version)) {
405 error("A problem occurred inserting current version into databases");
409 /// Updated human-readable release version if necessary
411 if ($release <> $CFG->release) { // Update the release version
412 if (!set_config("release", $release)) {
413 error("ERROR: Could not update release version in database!!");
417 /// Groups install/upgrade is now in core above.
420 /// Find and check all main modules and load them up or upgrade them if necessary
421 /// first old *.php update and then the new upgrade.php script
422 upgrade_activity_modules("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
424 /// Check all questiontype plugins and upgrade if necessary
425 /// first old *.php update and then the new upgrade.php script
426 /// It is important that this is done AFTER the quiz module has been upgraded
427 upgrade_plugins('qtype', 'question/type', "$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
429 /// Upgrade backup/restore system if necessary
430 /// first old *.php update and then the new upgrade.php script
431 require_once("$CFG->dirroot/backup/lib.php");
432 upgrade_backup_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
434 /// Upgrade blocks system if necessary
435 /// first old *.php update and then the new upgrade.php script
436 require_once("$CFG->dirroot/lib/blocklib.php");
437 upgrade_blocks_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
439 /// Check all blocks and load (or upgrade them if necessary)
440 /// first old *.php update and then the new upgrade.php script
441 upgrade_blocks_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
443 /// Check all enrolment plugins and upgrade if necessary
444 /// first old *.php update and then the new upgrade.php script
445 upgrade_plugins('enrol', 'enrol', "$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
447 /// Check all auth plugins and upgrade if necessary
448 upgrade_plugins('auth','auth',"$CFG->wwwroot/$CFG->admin/index.php");
450 /// Check all course formats and upgrade if necessary
451 upgrade_plugins('format','course/format',"$CFG->wwwroot/$CFG->admin/index.php");
453 /// Check for local database customisations
454 /// first old *.php update and then the new upgrade.php script
455 require_once("$CFG->dirroot/lib/locallib.php");
456 upgrade_local_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
458 /// Check for changes to RPC functions
459 require_once("$CFG->dirroot/$CFG->admin/mnet/adminlib.php");
460 upgrade_RPC_functions("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
462 /// Upgrade all plugins for gradebook
463 upgrade_plugins('gradeexport', 'grade/export', "$CFG->wwwroot/$CFG->admin/index.php");
464 upgrade_plugins('gradeimport', 'grade/import', "$CFG->wwwroot/$CFG->admin/index.php");
465 upgrade_plugins('gradereport', 'grade/report', "$CFG->wwwroot/$CFG->admin/index.php");
467 /// Check all message output plugins and upgrade if necessary
468 upgrade_plugins('message','message/output',"$CFG->wwwroot/$CFG->admin/index.php");
470 /// Check all admin report plugins and upgrade if necessary
471 upgrade_plugins('report', $CFG->admin.'/report', "$CFG->wwwroot/$CFG->admin/index.php");
474 /// just make sure upgrade logging is properly terminated
475 upgrade_log_finish();
477 unset($_SESSION['installautopilot']);
479 /// Set up the blank site - to be customized later at the end of install.
480 if (! $site = get_site()) {
481 // We are about to create the site "course"
482 require_once($CFG->libdir.'/blocklib.php');
484 $newsite = new object();
485 $newsite->fullname = "";
486 $newsite->shortname = "";
487 $newsite->summary = NULL;
488 $newsite->newsitems = 3;
489 $newsite->numsections = 0;
490 $newsite->category = 0;
491 $newsite->format = 'site'; // Only for this course
492 $newsite->teacher = get_string("defaultcourseteacher");
493 $newsite->teachers = get_string("defaultcourseteachers");
494 $newsite->student = get_string("defaultcoursestudent");
495 $newsite->students = get_string("defaultcoursestudents");
496 $newsite->timemodified = time();
498 if (!$newid = insert_record('course', $newsite)) {
499 error("Serious Error! Could not set up the site!");
501 // make sure course context exists
502 get_context_instance(CONTEXT_COURSE, $newid);
504 // Site created, add blocks for it
505 $page = page_create_object(PAGE_COURSE_VIEW, $newid);
506 blocks_repopulate_page($page); // Return value not checked because you can always edit later
508 $cat = new object();
509 $cat->name = get_string('miscellaneous');
510 $cat->depth = 1;
511 if (!$catid = insert_record('course_categories', $cat)) {
512 error("Serious Error! Could not set up a default course category!");
514 // make sure category context exists
515 get_context_instance(CONTEXT_COURSECAT, $catid);
516 mark_context_dirty('/'.SYSCONTEXTID);
518 redirect('index.php');
521 // initialise default blocks on admin and site page if needed
522 if (empty($CFG->adminblocks_initialised)) {
523 require_once("$CFG->dirroot/$CFG->admin/pagelib.php");
524 require_once($CFG->libdir.'/blocklib.php');
525 page_map_class(PAGE_ADMIN, 'page_admin');
526 $page = page_create_object(PAGE_ADMIN, 0); // there must be some id number
527 blocks_repopulate_page($page);
529 //add admin_tree block to site if not already present
530 if ($admintree = get_record('block', 'name', 'admin_tree')) {
531 $page = page_create_object(PAGE_COURSE_VIEW, SITEID);
532 $pageblocks=blocks_get_by_page($page);
533 blocks_execute_action($page, $pageblocks, 'add', (int)$admintree->id, false, false);
534 if ($admintreeinstance = get_record('block_instance', 'pagetype', $page->type, 'pageid', SITEID, 'blockid', $admintree->id)) {
535 $pageblocks=blocks_get_by_page($page); // Needs to be re-got, since has just changed
536 blocks_execute_action($page, $pageblocks, 'moveleft', $admintreeinstance, false, false);
540 set_config('adminblocks_initialised', 1);
543 /// Define the unique site ID code if it isn't already
544 if (empty($CFG->siteidentifier)) { // Unique site identification code
545 set_config('siteidentifier', random_string(32).$_SERVER['HTTP_HOST']);
548 /// Check if the guest user exists. If not, create one.
549 if (! record_exists("user", "username", "guest")) {
550 if (! $guest = create_guest_record()) {
551 notify("Could not create guest user record !!!");
556 /// Set up the admin user
557 if (empty($CFG->rolesactive)) {
558 build_context_path(); // just in case - should not be needed
559 create_admin_user();
562 /// Check for valid admin user - no guest autologin
563 require_login(0, false);
565 $context = get_context_instance(CONTEXT_SYSTEM);
567 require_capability('moodle/site:config', $context);
569 /// check that site is properly customized
570 if (empty($site->shortname)) {
571 // probably new installation - lets return to frontpage after this step
572 // remove settings that we want uninitialised
573 unset_config('registerauth');
574 redirect('upgradesettings.php?return=site');
577 /// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
579 if (!empty($id)) {
580 if ($id == $CFG->siteidentifier) {
581 set_config('registered', time());
585 $adminroot =& admin_get_root();
587 /// Check if there are any new admin settings which have still yet to be set
588 if (any_new_admin_settings($adminroot)){
589 redirect('upgradesettings.php');
592 /// Everything should now be set up, and the user is an admin
594 /// Print default admin page with notifications.
596 admin_externalpage_setup('adminnotifications');
597 admin_externalpage_print_header();
599 /// Deprecated database! Warning!!
600 if (!empty($CFG->migrated_to_new_db)) {
601 print_box(print_string('dbmigrationdeprecateddb', 'admin'), 'generalbox adminwarning');
604 /// Check for any special upgrades that might need to be run
605 if (!empty($CFG->upgrade)) {
606 print_box(get_string("upgrade$CFG->upgrade", "admin", "$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"));
609 if (ini_get_bool('register_globals')) {
610 print_box(get_string('globalswarning', 'admin'), 'generalbox adminwarning');
613 if (is_dataroot_insecure()) {
614 print_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning');
617 if (defined('WARN_DISPLAY_ERRORS_ENABLED')) {
618 print_box(get_string('displayerrorswarning', 'admin'), 'generalbox adminwarning');
621 if (substr($CFG->wwwroot, -1) == '/') {
622 print_box(get_string('cfgwwwrootslashwarning', 'admin'), 'generalbox adminwarning');
624 if (strpos($ME, $CFG->httpswwwroot.'/') === false) {
625 print_box(get_string('cfgwwwrootwarning', 'admin'), 'generalbox adminwarning');
628 /// If no recently cron run
629 $lastcron = get_field_sql('SELECT max(lastcron) FROM ' . $CFG->prefix . 'modules');
630 if (time() - $lastcron > 3600 * 24) {
631 $strinstallation = get_string('installation', 'install');
632 $helpbutton = helpbutton('install', $strinstallation, 'moodle', true, false, '', true);
633 print_box(get_string('cronwarning', 'admin')."&nbsp;".$helpbutton, 'generalbox adminwarning');
636 /// Print multilang upgrade notice if needed
637 if (empty($CFG->filter_multilang_converted)) {
638 print_box(get_string('multilangupgradenotice', 'admin'), 'generalbox adminwarning');
641 /// Alert if we are currently in maintenance mode
642 if (file_exists($CFG->dataroot.'/1/maintenance.html')) {
643 print_box(get_string('sitemaintenancewarning', 'admin'), 'generalbox adminwarning');
647 /// Print slightly annoying registration button
648 $options = array();
649 $options['sesskey'] = $USER->sesskey;
650 print_box_start('generalbox adminwarning');
651 if(!isset($CFG->registered)) {
652 print_string('pleaseregister', 'admin');
654 else { /* if (isset($CFG->registered) && $CFG->registered < (time() - 3600*24*30*6)) { */
655 print_string('pleaserefreshregistration', 'admin', userdate($CFG->registered));
657 print_single_button('register.php', $options, get_string('registration'));
658 print_box_end();
661 //////////////////////////////////////////////////////////////////////////////////////////////////
662 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
663 $copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
664 '<a href="http://docs.moodle.org/en/Release" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
665 'Copyright &copy; 1999 onwards, Martin Dougiamas<br />'.
666 'and <a href="http://docs.moodle.org/en/Credits">many other contributors</a>.<br />'.
667 '<a href="http://docs.moodle.org/en/License">GNU Public License</a>';
668 print_box($copyrighttext, 'copyright');
669 //////////////////////////////////////////////////////////////////////////////////////////////////
671 admin_externalpage_print_footer();