weekly release 1.9.14+
[moodle.git] / admin / index.php
blob087418340900388f4ce1d359edeea697718faa97
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/19/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 (is_float_problem()) {
65 print_error('phpfloatproblem', 'admin', '', $documentationlink);
68 if (empty($CFG->prefix) && $CFG->dbfamily != 'mysql') { //Enforce prefixes for everybody but mysql
69 error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')');
72 if ($CFG->dbfamily == 'oracle' && strlen($CFG->prefix) > 2) { //Max prefix length for Oracle is 2cc
73 error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.');
76 /// Check that config.php has been edited
78 if ($CFG->wwwroot == "http://example.com/moodle") {
79 error("Moodle has not been configured yet. You need to edit config.php first.");
83 /// Check settings in config.php
85 $dirroot = dirname(realpath("../index.php"));
86 if (!empty($dirroot) and $dirroot != $CFG->dirroot) {
87 error("Please fix your settings in config.php:
88 <p>You have:
89 <p>\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
90 <p>but it should be:
91 <p>\$CFG->dirroot = \"".addslashes($dirroot)."\";",
92 "./");
95 /// Set some necessary variables during set-up to avoid PHP warnings later on this page
96 if (!isset($CFG->framename)) {
97 $CFG->framename = "_top";
99 if (!isset($CFG->release)) {
100 $CFG->release = "";
102 if (!isset($CFG->version)) {
103 $CFG->version = "";
106 if (is_readable("$CFG->dirroot/version.php")) {
107 include_once("$CFG->dirroot/version.php"); # defines $version
110 if (!$version or !$release) {
111 error('Main version.php was not readable or specified');# without version, stop
114 /// Check if the main tables have been installed yet or not.
116 if (! $tables = $db->Metatables() ) { // No tables yet at all.
117 $maintables = false;
119 } else { // Check for missing main tables
120 $maintables = true;
121 $mtables = array("config", "course", "course_categories", "course_modules",
122 "course_sections", "log", "log_display", "modules",
123 "user");
124 foreach ($mtables as $mtable) {
125 if (!in_array($CFG->prefix.$mtable, $tables)) {
126 $maintables = false;
127 break;
132 if (! $maintables) {
133 /// hide errors from headers in case debug enabled in config.php
134 $origdebug = $CFG->debug;
135 $CFG->debug = DEBUG_MINIMAL;
136 error_reporting($CFG->debug);
137 if (empty($agreelicense)) {
138 $strlicense = get_string('license');
139 $navigation = build_navigation(array(array('name'=>$strlicense, 'link'=>null, 'type'=>'misc')));
140 print_header($strlicense, $strlicense, $navigation, "", "", false, "&nbsp;", "&nbsp;");
141 print_heading("<a href=\"http://moodle.org\">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment");
142 print_heading(get_string('copyrightnotice'));
143 print_box(text_to_html(get_string('gpl')), 'copyrightnotice');
144 echo "<br />";
145 notice_yesno(get_string('doyouagree'), "index.php?agreelicense=1",
146 "http://docs.moodle.org/dev/License");
147 print_footer('none');
148 exit;
150 if (empty($confirmrelease)) {
151 $strcurrentrelease = get_string("currentrelease");
152 $navigation = build_navigation(array(array('name'=>$strcurrentrelease, 'link'=>null, 'type'=>'misc')));
153 print_header($strcurrentrelease, $strcurrentrelease, $navigation, "", "", false, "&nbsp;", "&nbsp;");
154 print_heading("Moodle $release");
155 print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/19/en/Release_Notes'), 'generalbox boxaligncenter boxwidthwide');
156 echo '<form action="index.php"><div>';
157 echo '<input type="hidden" name="agreelicense" value="1" />';
158 echo '<input type="hidden" name="confirmrelease" value="1" />';
159 echo '</div>';
160 echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="1" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
161 echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
162 echo '</form>';
163 print_footer('none');
164 die;
168 $strdatabasesetup = get_string("databasesetup");
169 $strdatabasesuccess = get_string("databasesuccess");
170 $navigation = build_navigation(array(array('name'=>$strdatabasesetup, 'link'=>null, 'type'=>'misc')));
171 print_header($strdatabasesetup, $strdatabasesetup, $navigation,
172 "", upgrade_get_javascript(), false, "&nbsp;", "&nbsp;");
173 /// return to original debugging level
174 $CFG->debug = $origdebug;
175 error_reporting($CFG->debug);
176 upgrade_log_start();
177 $db->debug = true;
179 /// Both old .sql files and new install.xml are supported
180 /// But we prioritise install.xml (XMLDB) if present
182 change_db_encoding(); // first try to change db encoding to utf8
183 if (!setup_is_unicodedb()) {
184 // If could not convert successfully, throw error, and prevent installation
185 print_error('unicoderequired', 'admin');
188 $status = false;
189 if (file_exists("$CFG->libdir/db/install.xml")) {
190 $status = install_from_xmldb_file("$CFG->libdir/db/install.xml"); //New method
191 } else if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
192 $status = modify_database("$CFG->libdir/db/$CFG->dbtype.sql"); //Old method
193 } else {
194 error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present. See the lib/db directory.");
197 // all new installs are in unicode - keep for backwards compatibility and 1.8 upgrade checks
198 set_config('unicodedb', 1);
200 /// Continue with the instalation
201 $db->debug = false;
202 if ($status) {
204 /// Groups install is now in core above.
206 // Install the roles system.
207 moodle_install_roles();
208 set_config('statsrolesupgraded',time());
210 // install core event handlers
211 events_update_definition();
213 /// This is used to handle any settings that must exist in $CFG but which do not exist in
214 /// admin_get_root()/$ADMIN as admin_setting objects (there are some exceptions).
215 apply_default_exception_settings(array('auth' => 'email',
216 'auth_pop3mailbox' => 'INBOX',
217 'enrol' => 'manual',
218 'enrol_plugins_enabled' => 'manual',
219 'style' => 'default',
220 'template' => 'default',
221 'theme' => 'standardwhite',
222 'filter_multilang_converted' => 1));
224 // Write default settings unconditionally (i.e. even if a setting is already set, overwrite it)
225 // (this should only have any effect during initial install).
226 admin_apply_default_settings(NULL, true);
228 notify($strdatabasesuccess, "green");
229 require_once $CFG->dirroot.'/mnet/lib.php';
230 } else {
231 error("Error: Main databases NOT set up successfully");
233 print_continue('index.php');
234 print_footer('none');
235 die;
239 /// Check version of Moodle code on disk compared with database
240 /// and upgrade if possible.
242 if (file_exists("$CFG->dirroot/lib/db/$CFG->dbtype.php")) {
243 include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines old upgrades
245 if (file_exists("$CFG->dirroot/lib/db/upgrade.php")) {
246 include_once("$CFG->dirroot/lib/db/upgrade.php"); # defines new upgrades
249 $stradministration = get_string("administration");
251 if ($CFG->version) {
252 if ($version > $CFG->version) { // upgrade
254 /// If the database is not already Unicode then we do not allow upgrading!
255 /// Instead, we print an error telling them to upgrade to 1.7 first. MDL-6857
256 if (empty($CFG->unicodedb)) {
257 print_error('unicodeupgradeerror', 'error', '', $version);
260 $a->oldversion = "$CFG->release ($CFG->version)";
261 $a->newversion = "$release ($version)";
262 $strdatabasechecking = get_string("databasechecking", "", $a);
264 // hide errors from headers in case debug is enabled
265 $origdebug = $CFG->debug;
266 $CFG->debug = DEBUG_MINIMAL;
267 error_reporting($CFG->debug);
269 // logo ut in case we are upgrading from pre 1.9 version in order to prevent
270 // weird session/role problems caused by incorrect data in USER and SESSION
271 if ($CFG->version < 2007101500) {
272 require_logout();
275 if (empty($confirmupgrade)) {
276 $navigation = build_navigation(array(array('name'=>$strdatabasechecking, 'link'=>null, 'type'=>'misc')));
277 print_header($strdatabasechecking, $stradministration, $navigation,
278 "", "", false, "&nbsp;", "&nbsp;");
280 notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=1', 'index.php');
281 print_footer('none');
282 exit;
284 } else if (empty($confirmrelease)){
285 $strcurrentrelease = get_string("currentrelease");
286 $navigation = build_navigation(array(array('name'=>$strcurrentrelease, 'link'=>null, 'type'=>'misc')));
287 print_header($strcurrentrelease, $strcurrentrelease, $navigation, "", "", false, "&nbsp;", "&nbsp;");
288 print_heading("Moodle $release");
289 print_box(get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/19/en/Release_Notes'));
291 require_once($CFG->libdir.'/environmentlib.php');
292 print_heading(get_string('environment', 'admin'));
293 remove_dir($CFG->dataroot . '/environment'); /// Always delete downloaded env. info to force use of the released one. MDL-9796
294 if (!check_moodle_environment($release, $environment_results, true)) {
295 if (empty($CFG->skiplangupgrade)) {
296 print_box_start('generalbox', 'notice'); // MDL-8330
297 print_string('langpackwillbeupdated', 'admin');
298 print_box_end();
300 notice_yesno(get_string('environmenterrorupgrade', 'admin'),
301 'index.php?confirmupgrade=1&amp;confirmrelease=1', 'index.php');
302 } else {
303 notify(get_string('environmentok', 'admin'), 'notifysuccess');
304 if (empty($CFG->skiplangupgrade)) {
305 print_box_start('generalbox', 'notice'); // MDL-8330
306 print_string('langpackwillbeupdated', 'admin');
307 print_box_end();
309 echo '<form action="index.php"><div>';
310 echo '<input type="hidden" name="confirmupgrade" value="1" />';
311 echo '<input type="hidden" name="confirmrelease" value="1" />';
312 echo '</div>';
313 echo '<div class="continuebutton">';
314 echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
315 echo '</form>';
318 print_footer('none');
319 die;
320 } elseif (empty($confirmplugincheck)) {
321 $strplugincheck = get_string('plugincheck');
322 $navigation = build_navigation(array(array('name'=>$strplugincheck, 'link'=>null, 'type'=>'misc')));
323 print_header($strplugincheck, $strplugincheck, $navigation, "", "", false, "&nbsp;", "&nbsp;");
324 print_heading($strplugincheck);
325 print_box_start('generalbox', 'notice'); // MDL-8330
326 print_string('pluginchecknotice');
327 print_box_end();
328 print_plugin_tables();
329 echo "<br />";
330 echo '<div class="continuebutton">';
331 echo '<a href="index.php?confirmupgrade=1&amp;confirmrelease=1" title="'.get_string('reload').'" ><img src="'.$CFG->pixpath.'/i/reload.gif" alt="" /> '.get_string('reload').'</a>';
332 echo '</div><br />';
333 echo '<form action="index.php"><div>';
334 echo '<input type="hidden" name="confirmupgrade" value="1" />';
335 echo '<input type="hidden" name="confirmrelease" value="1" />';
336 echo '<input type="hidden" name="confirmplugincheck" value="1" />';
337 echo '</div>';
338 echo '<div class="continuebutton"><input name="autopilot" id="autopilot" type="checkbox" value="1" /><label for="autopilot">'.get_string('unattendedoperation', 'admin').'</label>';
339 echo '<br /><br /><input type="submit" value="'.get_string('continue').'" /></div>';
340 echo '</form>';
341 print_footer('none');
342 die();
344 } else {
345 $strdatabasesuccess = get_string("databasesuccess");
346 $navigation = build_navigation(array(array('name'=>$strdatabasesuccess, 'link'=>null, 'type'=>'misc')));
347 print_header($strdatabasechecking, $stradministration, $navigation,
348 "", upgrade_get_javascript(), false, "&nbsp;", "&nbsp;");
350 /// return to original debugging level
351 $CFG->debug = $origdebug;
352 error_reporting($CFG->debug);
353 upgrade_log_start();
355 /// Upgrade current language pack if we can
356 if (empty($CFG->skiplangupgrade)) {
357 upgrade_language_pack();
360 print_heading($strdatabasechecking);
361 $db->debug=true;
362 /// Launch the old main upgrade (if exists)
363 $status = true;
364 if (function_exists('main_upgrade')) {
365 $status = main_upgrade($CFG->version);
367 /// If succesful and exists launch the new main upgrade (XMLDB), called xmldb_main_upgrade
368 if ($status && function_exists('xmldb_main_upgrade')) {
369 $status = xmldb_main_upgrade($CFG->version);
371 $db->debug=false;
372 /// If successful, continue upgrading roles and setting everything properly
373 if ($status) {
374 if (empty($CFG->rolesactive)) {
376 /// Groups upgrade is now in core above.
378 // Upgrade to the roles system.
379 moodle_install_roles();
380 set_config('rolesactive', 1);
381 } else if (!update_capabilities()) {
382 error('Had trouble upgrading the core capabilities for the Roles System');
384 // update core events
385 events_update_definition();
387 require_once($CFG->libdir.'/statslib.php');
388 if (!stats_upgrade_for_roles_wrapper()) {
389 notify('Couldn\'t upgrade the stats tables to use the new roles system');
391 if (set_config("version", $version)) {
392 remove_dir($CFG->dataroot . '/cache', true); // flush cache
393 notify($strdatabasesuccess, "green");
394 print_continue("upgradesettings.php");
395 print_footer('none');
396 exit;
397 } else {
398 error('Upgrade failed! (Could not update version in config table)');
400 /// Main upgrade not success
401 } else {
402 notify('Main Upgrade failed! See lib/db/upgrade.php');
403 print_continue('index.php?confirmupgrade=1&amp;confirmrelease=1&amp;confirmplugincheck=1');
404 print_footer('none');
405 die;
407 upgrade_log_finish();
409 } else if ($version < $CFG->version) {
410 upgrade_log_start();
411 notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
412 upgrade_log_finish();
414 } else {
415 if (!set_config("version", $version)) {
416 error("A problem occurred inserting current version into databases");
420 /// Updated human-readable release version if necessary
422 if ($release <> $CFG->release) { // Update the release version
423 if (!set_config("release", $release)) {
424 error("ERROR: Could not update release version in database!!");
428 /// Groups install/upgrade is now in core above.
431 /// Find and check all main modules and load them up or upgrade them if necessary
432 /// first old *.php update and then the new upgrade.php script
433 upgrade_activity_modules("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
435 /// Check all questiontype plugins and upgrade if necessary
436 /// first old *.php update and then the new upgrade.php script
437 /// It is important that this is done AFTER the quiz module has been upgraded
438 upgrade_plugins('qtype', 'question/type', "$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
440 /// Upgrade backup/restore system if necessary
441 /// first old *.php update and then the new upgrade.php script
442 require_once("$CFG->dirroot/backup/lib.php");
443 upgrade_backup_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
445 /// Upgrade blocks system if necessary
446 /// first old *.php update and then the new upgrade.php script
447 require_once("$CFG->dirroot/lib/blocklib.php");
448 upgrade_blocks_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
450 /// Check all blocks and load (or upgrade them if necessary)
451 /// first old *.php update and then the new upgrade.php script
452 upgrade_blocks_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
454 /// Check all enrolment plugins and upgrade if necessary
455 /// first old *.php update and then the new upgrade.php script
456 upgrade_plugins('enrol', 'enrol', "$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
458 /// Check all auth plugins and upgrade if necessary
459 upgrade_plugins('auth','auth',"$CFG->wwwroot/$CFG->admin/index.php");
461 /// Check all course formats and upgrade if necessary
462 upgrade_plugins('format','course/format',"$CFG->wwwroot/$CFG->admin/index.php");
464 /// Check for local database customisations
465 /// first old *.php update and then the new upgrade.php script
466 require_once("$CFG->dirroot/lib/locallib.php");
467 upgrade_local_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
469 /// Check for changes to RPC functions
470 require_once("$CFG->dirroot/$CFG->admin/mnet/adminlib.php");
471 upgrade_RPC_functions("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
473 /// Upgrade all plugins for gradebook
474 upgrade_plugins('gradeexport', 'grade/export', "$CFG->wwwroot/$CFG->admin/index.php");
475 upgrade_plugins('gradeimport', 'grade/import', "$CFG->wwwroot/$CFG->admin/index.php");
476 upgrade_plugins('gradereport', 'grade/report', "$CFG->wwwroot/$CFG->admin/index.php");
478 /// Check all message output plugins and upgrade if necessary
479 upgrade_plugins('message','message/output',"$CFG->wwwroot/$CFG->admin/index.php");
481 /// Check all course report plugins and upgrade if necessary
482 upgrade_plugins('coursereport', 'course/report', "$CFG->wwwroot/$CFG->admin/index.php");
484 /// Check all admin report plugins and upgrade if necessary
485 upgrade_plugins('report', $CFG->admin.'/report', "$CFG->wwwroot/$CFG->admin/index.php");
488 /// just make sure upgrade logging is properly terminated
489 upgrade_log_finish();
491 unset($_SESSION['installautopilot']);
493 /// Set up the blank site - to be customized later at the end of install.
494 if (! $site = get_site()) {
495 // We are about to create the site "course"
496 require_once($CFG->libdir.'/blocklib.php');
498 $newsite = new object();
499 $newsite->fullname = "";
500 $newsite->shortname = "";
501 $newsite->summary = NULL;
502 $newsite->newsitems = 3;
503 $newsite->numsections = 0;
504 $newsite->category = 0;
505 $newsite->format = 'site'; // Only for this course
506 $newsite->teacher = get_string("defaultcourseteacher");
507 $newsite->teachers = get_string("defaultcourseteachers");
508 $newsite->student = get_string("defaultcoursestudent");
509 $newsite->students = get_string("defaultcoursestudents");
510 $newsite->timemodified = time();
512 if (!$newid = insert_record('course', $newsite)) {
513 error("Serious Error! Could not set up the site!");
515 // make sure course context exists
516 get_context_instance(CONTEXT_COURSE, $newid);
518 // Site created, add blocks for it
519 $page = page_create_object(PAGE_COURSE_VIEW, $newid);
520 blocks_repopulate_page($page); // Return value not checked because you can always edit later
522 $cat = new object();
523 $cat->name = get_string('miscellaneous');
524 $cat->depth = 1;
525 if (!$catid = insert_record('course_categories', $cat)) {
526 error("Serious Error! Could not set up a default course category!");
528 // make sure category context exists
529 get_context_instance(CONTEXT_COURSECAT, $catid);
530 mark_context_dirty('/'.SYSCONTEXTID);
532 redirect('index.php');
535 // initialise default blocks on admin and site page if needed
536 if (empty($CFG->adminblocks_initialised)) {
537 require_once("$CFG->dirroot/$CFG->admin/pagelib.php");
538 require_once($CFG->libdir.'/blocklib.php');
539 page_map_class(PAGE_ADMIN, 'page_admin');
540 $page = page_create_object(PAGE_ADMIN, 0); // there must be some id number
541 blocks_repopulate_page($page);
543 //add admin_tree block to site if not already present
544 if ($admintree = get_record('block', 'name', 'admin_tree')) {
545 $page = page_create_object(PAGE_COURSE_VIEW, SITEID);
546 $pageblocks=blocks_get_by_page($page);
547 blocks_execute_action($page, $pageblocks, 'add', (int)$admintree->id, false, false);
548 if ($admintreeinstance = get_record('block_instance', 'pagetype', $page->type, 'pageid', SITEID, 'blockid', $admintree->id)) {
549 $pageblocks=blocks_get_by_page($page); // Needs to be re-got, since has just changed
550 blocks_execute_action($page, $pageblocks, 'moveleft', $admintreeinstance, false, false);
554 set_config('adminblocks_initialised', 1);
557 /// Define the unique site ID code if it isn't already set. This getter does that as a side-effect.
558 get_site_identifier();
560 /// Check if the guest user exists. If not, create one.
561 if (! record_exists("user", "username", "guest")) {
562 if (! $guest = create_guest_record()) {
563 notify("Could not create guest user record !!!");
568 /// Set up the admin user
569 if (empty($CFG->rolesactive)) {
570 build_context_path(); // just in case - should not be needed
571 create_admin_user();
574 /// Check for valid admin user - no guest autologin
575 require_login(0, false);
577 $context = get_context_instance(CONTEXT_SYSTEM);
579 require_capability('moodle/site:config', $context);
581 /// check that site is properly customized
582 if (empty($site->shortname)) {
583 // probably new installation - lets return to frontpage after this step
584 // remove settings that we want uninitialised
585 unset_config('registerauth');
586 redirect('upgradesettings.php?return=site');
589 /// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
591 if (!empty($id)) {
592 if ($id == $CFG->siteidentifier) {
593 set_config('registered', time());
597 /// setup critical warnings before printing admin tree block
598 $insecuredataroot = is_dataroot_insecure(true);
599 $register_globals_enabled = ini_get_bool('register_globals');
601 $SESSION->admin_critical_warning = ($register_globals_enabled || $insecuredataroot==INSECURE_DATAROOT_ERROR);
603 $adminroot =& admin_get_root();
605 /// Check if there are any new admin settings which have still yet to be set
606 if (any_new_admin_settings($adminroot)){
607 redirect('upgradesettings.php');
610 /// Everything should now be set up, and the user is an admin
612 /// Print default admin page with notifications.
614 admin_externalpage_setup('adminnotifications');
615 admin_externalpage_print_header();
617 /// Deprecated database! Warning!!
618 if (!empty($CFG->migrated_to_new_db)) {
619 print_box(print_string('dbmigrationdeprecateddb', 'admin'), 'generalbox adminwarning');
622 /// Check for any special upgrades that might need to be run
623 if (!empty($CFG->upgrade)) {
624 print_box(get_string("upgrade$CFG->upgrade", "admin", "$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"));
627 if ($register_globals_enabled) {
628 print_box(get_string('globalswarning', 'admin'), 'generalbox adminerror');
631 if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
632 print_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning');
633 } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
634 print_box(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'generalbox adminerror');
638 if (empty($CFG->passwordsaltmain)) {
639 $path = $CFG->docroot.'/'.str_replace('_utf8', '', current_language()).'/report/security/report_security_check_passwordsaltmain';
640 print_box(get_string('upgrade197notice', 'admin')."\n".get_string('upgrade197salt', 'admin', $path));
643 if (defined('WARN_DISPLAY_ERRORS_ENABLED')) {
644 print_box(get_string('displayerrorswarning', 'admin'), 'generalbox adminwarning');
647 if (substr($CFG->wwwroot, -1) == '/') {
648 print_box(get_string('cfgwwwrootslashwarning', 'admin'), 'generalbox adminwarning');
650 if (strpos($ME, $CFG->httpswwwroot.'/') === false) {
651 print_box(get_string('cfgwwwrootwarning', 'admin'), 'generalbox adminwarning');
654 /// If no recently cron run
655 $lastcron = get_field_sql('SELECT max(lastcron) FROM ' . $CFG->prefix . 'modules');
656 if (time() - $lastcron > 3600 * 24) {
657 $strinstallation = get_string('installation', 'install');
658 $helpbutton = helpbutton('install', $strinstallation, 'moodle', true, false, '', true);
659 print_box(get_string('cronwarning', 'admin')."&nbsp;".$helpbutton, 'generalbox adminwarning');
662 /// Print multilang upgrade notice if needed
663 if (empty($CFG->filter_multilang_converted)) {
664 print_box(get_string('multilangupgradenotice', 'admin'), 'generalbox adminwarning');
667 /// Alert if we are currently in maintenance mode
668 if (file_exists($CFG->dataroot.'/1/maintenance.html')) {
669 print_box(get_string('sitemaintenancewarning', 'admin'), 'generalbox adminwarning');
673 /// Print slightly annoying registration button
674 $options = array();
675 $options['sesskey'] = $USER->sesskey;
676 print_box_start('generalbox adminwarning');
677 if(!isset($CFG->registered)) {
678 print_string('pleaseregister', 'admin');
680 else { /* if (isset($CFG->registered) && $CFG->registered < (time() - 3600*24*30*6)) { */
681 print_string('pleaserefreshregistration', 'admin', userdate($CFG->registered));
683 print_single_button('register.php', $options, get_string('registration'));
684 print_box_end();
687 //////////////////////////////////////////////////////////////////////////////////////////////////
688 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
689 $copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
690 '<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
691 'Copyright &copy; 1999 onwards, Martin Dougiamas<br />'.
692 'and <a href="http://docs.moodle.org/dev/Credits">many other contributors</a>.<br />'.
693 '<a href="http://docs.moodle.org/dev/License">GNU Public License</a>';
694 print_box($copyrighttext, 'copyright');
695 //////////////////////////////////////////////////////////////////////////////////////////////////
697 admin_externalpage_print_footer();