MDL-15249 whitespaces and comments cleanup, no other changes

This commit is contained in:
skodak 2009-05-26 09:56:35 +00:00
parent 8580535b81
commit 00be19165f

View file

@ -23,89 +23,89 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
/// Check that config.php exists, if not then call the install script // Check that config.php exists, if not then call the install script
if (!file_exists('../config.php')) { if (!file_exists('../config.php')) {
header('Location: ../install.php'); header('Location: ../install.php');
die; die;
} }
/// Check that PHP is of a sufficient version as soon as possible // Check that PHP is of a sufficient version as soon as possible
if (version_compare(phpversion(), "5.2.0") < 0) { if (version_compare(phpversion(), "5.2.0") < 0) {
$phpversion = phpversion(); $phpversion = phpversion();
// do NOT localise - lang strings would not work here and we CAN not move it to later palce // do NOT localise - lang strings would not work here and we CAN NOT move it to later place
echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion). "; echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion). ";
echo "Please upgrade your server software or use latest Moodle 1.9.x instead."; echo "Please upgrade your server software or use latest Moodle 1.9.x instead.";
die; die;
} }
/// try to flush everything all the time // try to flush everything all the time
@ob_implicit_flush(true); @ob_implicit_flush(true);
while(@ob_end_clean()); // ob_end_flush prevents sending of headers while(@ob_end_clean()); // ob_end_flush prevents sending of headers
require('../config.php'); require('../config.php');
require_once($CFG->libdir.'/adminlib.php'); // Contains various admin-only functions require_once($CFG->libdir.'/adminlib.php'); // Contains various admin-only functions
require_once($CFG->libdir.'/upgradelib.php'); require_once($CFG->libdir.'/upgradelib.php');
$id = optional_param('id', '', PARAM_TEXT); $id = optional_param('id', '', PARAM_TEXT);
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL); $confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
$confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL); $confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL);
$confirmplugins = optional_param('confirmplugincheck', 0, PARAM_BOOL); $confirmplugins = optional_param('confirmplugincheck', 0, PARAM_BOOL);
$agreelicense = optional_param('agreelicense', 0, PARAM_BOOL); $agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
/// Check some PHP server settings // Check some PHP server settings
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>'; $documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
if (ini_get_bool('session.auto_start')) { if (ini_get_bool('session.auto_start')) {
print_error('phpvaroff', 'debug', '', (object)array('name'=>'session.auto_start', 'link'=>$documentationlink)); print_error('phpvaroff', 'debug', '', (object)array('name'=>'session.auto_start', 'link'=>$documentationlink));
} }
if (ini_get_bool('magic_quotes_runtime')) { if (ini_get_bool('magic_quotes_runtime')) {
print_error('phpvaroff', 'debug', '', (object)array('name'=>'magic_quotes_runtime', 'link'=>$documentationlink)); print_error('phpvaroff', 'debug', '', (object)array('name'=>'magic_quotes_runtime', 'link'=>$documentationlink));
} }
if (!ini_get_bool('file_uploads')) { if (!ini_get_bool('file_uploads')) {
print_error('phpvaron', 'debug', '', (object)array('name'=>'file_uploads', 'link'=>$documentationlink)); print_error('phpvaron', 'debug', '', (object)array('name'=>'file_uploads', 'link'=>$documentationlink));
} }
if (is_float_problem()) { if (is_float_problem()) {
print_error('phpfloatproblem', 'admin', '', $documentationlink); print_error('phpfloatproblem', 'admin', '', $documentationlink);
} }
/// Check settings in config.php // Check settings in config.php
$dirroot = dirname(realpath("../index.php")); $dirroot = dirname(realpath("../index.php"));
/// Check correct dirroot, ignoring slashes (though should be always forward slashes). MDL-18195 // Check correct dirroot, ignoring slashes (though should be always forward slashes). MDL-18195
if (!empty($dirroot) and str_replace('\\', '/', $dirroot) != str_replace('\\', '/', $CFG->dirroot)) { if (!empty($dirroot) and str_replace('\\', '/', $dirroot) != str_replace('\\', '/', $CFG->dirroot)) {
print_error('fixsetting', 'debug', '', (object)array('current'=>$CFG->dirroot, 'found'=>str_replace('\\', '/', $dirroot))); print_error('fixsetting', 'debug', '', (object)array('current'=>$CFG->dirroot, 'found'=>str_replace('\\', '/', $dirroot)));
} }
/// Set some necessary variables during set-up to avoid PHP warnings later on this page // Set some necessary variables during set-up to avoid PHP warnings later on this page
if (!isset($CFG->framename)) { if (!isset($CFG->framename)) {
$CFG->framename = "_top"; $CFG->framename = "_top";
} }
if (!isset($CFG->release)) { if (!isset($CFG->release)) {
$CFG->release = ""; $CFG->release = "";
} }
if (!isset($CFG->version)) { if (!isset($CFG->version)) {
$CFG->version = ""; $CFG->version = "";
} }
$version = null; $version = null;
$release = null; $release = null;
require("$CFG->dirroot/version.php"); // defines $version and $release require("$CFG->dirroot/version.php"); // defines $version and $release
$CFG->target_release = $release; // used during installation and upgrades $CFG->target_release = $release; // used during installation and upgrades
if (!$version or !$release) { if (!$version or !$release) {
print_error('withoutversion', 'debug'); // without version, stop print_error('withoutversion', 'debug'); // without version, stop
} }
/// Check if the main tables have been installed yet or not. // Check if the main tables have been installed yet or not.
if (!$tables = $DB->get_tables() ) { // No tables yet at all. if (!$tables = $DB->get_tables() ) { // No tables yet at all.
$maintables = false; $maintables = false;
} else { // Check for missing main tables } else { // Check for missing main tables
$maintables = true; $maintables = true;
$mtables = array('config', 'course', 'groupings'); // some tables used in 1.9 and 2.0, preferable something from the start and end of install.xml $mtables = array('config', 'course', 'groupings'); // some tables used in 1.9 and 2.0, preferable something from the start and end of install.xml
foreach ($mtables as $mtable) { foreach ($mtables as $mtable) {
@ -115,22 +115,22 @@
} }
} }
unset($mtables); unset($mtables);
} }
unset($tables); unset($tables);
// Turn off xmlstrictheaders during upgrade. // Turn off xmlstrictheaders during upgrade.
$origxmlstrictheaders = !empty($CFG->xmlstrictheaders); $origxmlstrictheaders = !empty($CFG->xmlstrictheaders);
$CFG->xmlstrictheaders = false; $CFG->xmlstrictheaders = false;
if (!$maintables) { if (!$maintables) {
/// hide errors from headers in case debug enabled in config.php // hide errors from headers in case debug enabled in config.php
/// fake some settings // fake some settings
$CFG->docroot = 'http://docs.moodle.org'; $CFG->docroot = 'http://docs.moodle.org';
$strinstallation = get_string('installation', 'install'); $strinstallation = get_string('installation', 'install');
/// remove current session content completely // remove current session content completely
session_get_instance()->terminate_current(); session_get_instance()->terminate_current();
if (empty($agreelicense)) { if (empty($agreelicense)) {
@ -181,20 +181,20 @@
} }
install_core($version, true); install_core($version, true);
} }
/// Check version of Moodle code on disk compared with database // Check version of Moodle code on disk compared with database
/// and upgrade if possible. // and upgrade if possible.
$stradministration = get_string('administration'); $stradministration = get_string('administration');
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
if (empty($CFG->version)) { if (empty($CFG->version)) {
print_error('missingconfigversion', 'debug'); print_error('missingconfigversion', 'debug');
} }
if ($version > $CFG->version) { // upgrade if ($version > $CFG->version) { // upgrade
require_once($CFG->libdir.'/db/upgrade.php'); // Defines upgrades require_once($CFG->libdir.'/db/upgrade.php'); // Defines upgrades
require_once($CFG->libdir.'/db/upgradelib.php'); // Upgrade-related functions require_once($CFG->libdir.'/db/upgradelib.php'); // Upgrade-related functions
@ -253,28 +253,28 @@
// Launch main upgrade // Launch main upgrade
upgrade_core($version, true); upgrade_core($version, true);
} }
} else if ($version < $CFG->version) { } else if ($version < $CFG->version) {
notify("WARNING!!! The code you are using is OLDER than the version that made these databases!"); notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
} }
/// Updated human-readable release version if necessary // Updated human-readable release version if necessary
if ($release <> $CFG->release) { // Update the release version if ($release <> $CFG->release) { // Update the release version
set_config("release", $release); set_config("release", $release);
} }
// upgrade all plugins and other parts // upgrade all plugins and other parts
upgrade_noncore(true); upgrade_noncore(true);
/// indicate that this site is fully configured except the admin password // indicate that this site is fully configured except the admin password
if (empty($CFG->rolesactive)) { if (empty($CFG->rolesactive)) {
set_config('rolesactive', 1); set_config('rolesactive', 1);
set_config('adminsetuppending', 1); set_config('adminsetuppending', 1);
// we neeed this redirect to setup proper session // we neeed this redirect to setup proper session
upgrade_finished("index.php?sessionstarted=1&amp;lang=$CFG->lang"); upgrade_finished("index.php?sessionstarted=1&amp;lang=$CFG->lang");
} }
/// make sure admin user is created - this is the last step because we need // make sure admin user is created - this is the last step because we need
/// session to be working properly in order to edit admin account // session to be working properly in order to edit admin account
if (!empty($CFG->adminsetuppending)) { if (!empty($CFG->adminsetuppending)) {
$sessionstarted = optional_param('sessionstarted', 0, PARAM_BOOL); $sessionstarted = optional_param('sessionstarted', 0, PARAM_BOOL);
if (!$sessionstarted) { if (!$sessionstarted) {
@ -309,102 +309,102 @@
unset_config('adminsetuppending'); unset_config('adminsetuppending');
} }
} else { } else {
/// just make sure upgrade logging is properly terminated // just make sure upgrade logging is properly terminated
upgrade_finished('upgradesettings.php'); upgrade_finished('upgradesettings.php');
} }
// Turn xmlstrictheaders back on now. // Turn xmlstrictheaders back on now.
$CFG->xmlstrictheaders = $origxmlstrictheaders; $CFG->xmlstrictheaders = $origxmlstrictheaders;
unset($origxmlstrictheaders); unset($origxmlstrictheaders);
/// Check for valid admin user - no guest autologin // Check for valid admin user - no guest autologin
require_login(0, false); require_login(0, false);
$context = get_context_instance(CONTEXT_SYSTEM); $context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context); require_capability('moodle/site:config', $context);
/// check that site is properly customized // check that site is properly customized
$site = get_site(); $site = get_site();
if (empty($site->shortname)) { if (empty($site->shortname)) {
// probably new installation - lets return to frontpage after this step // probably new installation - lets return to frontpage after this step
// remove settings that we want uninitialised // remove settings that we want uninitialised
unset_config('registerauth'); unset_config('registerauth');
redirect('upgradesettings.php?return=site'); redirect('upgradesettings.php?return=site');
} }
/// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders // Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
if (!empty($id) and $id == $CFG->siteidentifier) { if (!empty($id) and $id == $CFG->siteidentifier) {
set_config('registered', time()); set_config('registered', time());
} }
/// setup critical warnings before printing admin tree block // setup critical warnings before printing admin tree block
$insecuredataroot = is_dataroot_insecure(true); $insecuredataroot = is_dataroot_insecure(true);
$SESSION->admin_critical_warning = ($insecuredataroot==INSECURE_DATAROOT_ERROR); $SESSION->admin_critical_warning = ($insecuredataroot==INSECURE_DATAROOT_ERROR);
$adminroot = admin_get_root(); $adminroot = admin_get_root();
/// Check if there are any new admin settings which have still yet to be set // Check if there are any new admin settings which have still yet to be set
if (any_new_admin_settings($adminroot)){ if (any_new_admin_settings($adminroot)){
redirect('upgradesettings.php'); redirect('upgradesettings.php');
} }
/// Everything should now be set up, and the user is an admin // Everything should now be set up, and the user is an admin
/// Print default admin page with notifications. // Print default admin page with notifications.
admin_externalpage_setup('adminnotifications'); admin_externalpage_setup('adminnotifications');
admin_externalpage_print_header(); admin_externalpage_print_header();
/// Deprecated database! Warning!! // Deprecated database! Warning!!
if (!empty($CFG->migrated_to_new_db)) { if (!empty($CFG->migrated_to_new_db)) {
print_box(print_string('dbmigrationdeprecateddb', 'admin'), 'generalbox adminwarning'); print_box(print_string('dbmigrationdeprecateddb', 'admin'), 'generalbox adminwarning');
} }
/// Check for any special upgrades that might need to be run // Check for any special upgrades that might need to be run
if (!empty($CFG->upgrade)) { if (!empty($CFG->upgrade)) {
print_box(get_string("upgrade$CFG->upgrade", "admin", "$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php")); print_box(get_string("upgrade$CFG->upgrade", "admin", "$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"));
} }
if ($insecuredataroot == INSECURE_DATAROOT_WARNING) { if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
print_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning'); print_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning');
} else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) { } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
print_box(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'generalbox adminerror'); print_box(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'generalbox adminerror');
} }
if (defined('WARN_DISPLAY_ERRORS_ENABLED')) { if (defined('WARN_DISPLAY_ERRORS_ENABLED')) {
print_box(get_string('displayerrorswarning', 'admin'), 'generalbox adminwarning'); print_box(get_string('displayerrorswarning', 'admin'), 'generalbox adminwarning');
} }
/// If no recently cron run // If no recently cron run
$lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}'); $lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}');
if (time() - $lastcron > 3600 * 24) { if (time() - $lastcron > 3600 * 24) {
$strinstallation = get_string('installation', 'install'); $strinstallation = get_string('installation', 'install');
$helpbutton = helpbutton('install', $strinstallation, 'moodle', true, false, '', true); $helpbutton = helpbutton('install', $strinstallation, 'moodle', true, false, '', true);
print_box(get_string('cronwarning', 'admin')."&nbsp;".$helpbutton, 'generalbox adminwarning'); print_box(get_string('cronwarning', 'admin')."&nbsp;".$helpbutton, 'generalbox adminwarning');
} }
/// Print multilang upgrade notice if needed // Print multilang upgrade notice if needed
if (empty($CFG->filter_multilang_converted)) { if (empty($CFG->filter_multilang_converted)) {
print_box(get_string('multilangupgradenotice', 'admin'), 'generalbox adminwarning'); print_box(get_string('multilangupgradenotice', 'admin'), 'generalbox adminwarning');
} }
/// Alert if we are currently in maintenance mode // Alert if we are currently in maintenance mode
if (file_exists($CFG->dataroot.'/1/maintenance.html')) { if (file_exists($CFG->dataroot.'/1/maintenance.html')) {
print_box(get_string('sitemaintenancewarning', 'admin'), 'generalbox adminwarning'); print_box(get_string('sitemaintenancewarning', 'admin'), 'generalbox adminwarning');
} }
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE /// //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
$copyrighttext = '<a href="http://moodle.org/">Moodle</a> '. $copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
'<a href="http://docs.moodle.org/en/Release" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'. '<a href="http://docs.moodle.org/en/Release" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
'Copyright &copy; 1999 onwards, Martin Dougiamas<br />'. 'Copyright &copy; 1999 onwards, Martin Dougiamas<br />'.
'and <a href="http://docs.moodle.org/en/Credits">many other contributors</a>.<br />'. 'and <a href="http://docs.moodle.org/en/Credits">many other contributors</a>.<br />'.
'<a href="http://docs.moodle.org/en/License">GNU Public License</a>'; '<a href="http://docs.moodle.org/en/License">GNU Public License</a>';
print_box($copyrighttext, 'copyright'); print_box($copyrighttext, 'copyright');
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
admin_externalpage_print_footer(); admin_externalpage_print_footer();