2009-05-26 09:52:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle 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 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle 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.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Main administration script.
|
|
|
|
*
|
2010-09-06 11:29:21 +00:00
|
|
|
* @package core
|
2009-05-26 09:52:38 +00:00
|
|
|
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
// Check that config.php exists, if not then call the install script
|
|
|
|
if (!file_exists('../config.php')) {
|
|
|
|
header('Location: ../install.php');
|
2011-10-19 14:20:13 +01:00
|
|
|
die();
|
2009-05-26 09:56:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check that PHP is of a sufficient version as soon as possible
|
2011-08-06 20:56:57 +02:00
|
|
|
if (version_compare(phpversion(), '5.3.2') < 0) {
|
2009-05-26 09:56:35 +00:00
|
|
|
$phpversion = phpversion();
|
|
|
|
// do NOT localise - lang strings would not work here and we CAN NOT move it to later place
|
2011-08-06 20:56:57 +02:00
|
|
|
echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />";
|
|
|
|
echo "Please upgrade your server software or install older Moodle version.";
|
2011-10-19 14:20:13 +01:00
|
|
|
die();
|
2009-05-26 09:56:35 +00:00
|
|
|
}
|
|
|
|
|
2011-08-06 21:11:55 +02:00
|
|
|
// make sure iconv is available and actually works
|
|
|
|
if (!function_exists('iconv')) {
|
|
|
|
// this should not happen, this must be very borked install
|
2011-08-08 10:16:23 +08:00
|
|
|
echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
|
2011-08-06 21:11:55 +02:00
|
|
|
die();
|
|
|
|
}
|
|
|
|
if (iconv('UTF-8', 'UTF-8//IGNORE', 'abc') !== 'abc') {
|
|
|
|
// known to be broken in mid-2011 MAMP installations
|
|
|
|
echo 'Broken iconv PHP extension detected, installation/upgrade can not continue.';
|
2011-10-19 14:20:13 +01:00
|
|
|
die();
|
2011-08-06 21:11:55 +02:00
|
|
|
}
|
|
|
|
|
2010-11-19 03:40:43 +00:00
|
|
|
define('NO_OUTPUT_BUFFERING', true);
|
2009-05-26 09:56:35 +00:00
|
|
|
|
|
|
|
require('../config.php');
|
2009-05-26 10:21:56 +00:00
|
|
|
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
|
|
|
|
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
|
2012-03-16 23:34:37 +01:00
|
|
|
require_once($CFG->libdir.'/pluginlib.php'); // available updates notifications
|
2009-05-26 09:56:35 +00:00
|
|
|
|
|
|
|
$id = optional_param('id', '', PARAM_TEXT);
|
|
|
|
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
|
|
|
|
$confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL);
|
|
|
|
$confirmplugins = optional_param('confirmplugincheck', 0, PARAM_BOOL);
|
2011-03-10 00:50:18 +01:00
|
|
|
$showallplugins = optional_param('showallplugins', 0, PARAM_BOOL);
|
2009-05-26 09:56:35 +00:00
|
|
|
$agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
|
2012-03-16 23:34:37 +01:00
|
|
|
$fetchupdates = optional_param('fetchupdates', 0, PARAM_BOOL);
|
2009-05-26 09:56:35 +00:00
|
|
|
|
|
|
|
// Check some PHP server settings
|
|
|
|
|
2010-01-16 15:39:56 +00:00
|
|
|
$PAGE->set_url('/admin/index.php');
|
2010-10-12 01:18:01 +00:00
|
|
|
$PAGE->set_pagelayout('admin'); // Set a default pagelayout
|
2009-07-28 04:00:33 +00:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
|
|
|
|
|
|
|
|
if (ini_get_bool('session.auto_start')) {
|
|
|
|
print_error('phpvaroff', 'debug', '', (object)array('name'=>'session.auto_start', 'link'=>$documentationlink));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ini_get_bool('magic_quotes_runtime')) {
|
|
|
|
print_error('phpvaroff', 'debug', '', (object)array('name'=>'magic_quotes_runtime', 'link'=>$documentationlink));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ini_get_bool('file_uploads')) {
|
|
|
|
print_error('phpvaron', 'debug', '', (object)array('name'=>'file_uploads', 'link'=>$documentationlink));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_float_problem()) {
|
|
|
|
print_error('phpfloatproblem', 'admin', '', $documentationlink);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set some necessary variables during set-up to avoid PHP warnings later on this page
|
|
|
|
if (!isset($CFG->release)) {
|
2009-05-26 10:21:56 +00:00
|
|
|
$CFG->release = '';
|
2009-05-26 09:56:35 +00:00
|
|
|
}
|
|
|
|
if (!isset($CFG->version)) {
|
2009-05-26 10:21:56 +00:00
|
|
|
$CFG->version = '';
|
2009-05-26 09:56:35 +00:00
|
|
|
}
|
2012-05-10 15:43:52 +08:00
|
|
|
if (!isset($CFG->branch)) {
|
|
|
|
$CFG->branch = '';
|
|
|
|
}
|
2009-05-26 09:56:35 +00:00
|
|
|
|
|
|
|
$version = null;
|
|
|
|
$release = null;
|
2012-05-03 14:05:40 +08:00
|
|
|
$branch = null;
|
|
|
|
require("$CFG->dirroot/version.php"); // defines $version, $release, $branch and $maturity
|
2009-05-26 09:56:35 +00:00
|
|
|
$CFG->target_release = $release; // used during installation and upgrades
|
|
|
|
|
|
|
|
if (!$version or !$release) {
|
|
|
|
print_error('withoutversion', 'debug'); // without version, stop
|
|
|
|
}
|
|
|
|
|
|
|
|
// Turn off xmlstrictheaders during upgrade.
|
|
|
|
$origxmlstrictheaders = !empty($CFG->xmlstrictheaders);
|
|
|
|
$CFG->xmlstrictheaders = false;
|
|
|
|
|
2009-05-26 17:44:25 +00:00
|
|
|
if (!core_tables_exist()) {
|
2009-12-16 18:00:58 +00:00
|
|
|
$PAGE->set_pagelayout('maintenance');
|
2010-11-11 06:11:43 +00:00
|
|
|
$PAGE->set_popup_notification_allowed(false);
|
2009-05-26 09:56:35 +00:00
|
|
|
|
|
|
|
// fake some settings
|
|
|
|
$CFG->docroot = 'http://docs.moodle.org';
|
|
|
|
|
|
|
|
$strinstallation = get_string('installation', 'install');
|
|
|
|
|
|
|
|
// remove current session content completely
|
|
|
|
session_get_instance()->terminate_current();
|
|
|
|
|
|
|
|
if (empty($agreelicense)) {
|
|
|
|
$strlicense = get_string('license');
|
2011-10-19 13:24:11 +01:00
|
|
|
|
2009-09-03 05:11:33 +00:00
|
|
|
$PAGE->navbar->add($strlicense);
|
|
|
|
$PAGE->set_title($strinstallation.' - Moodle '.$CFG->target_release);
|
|
|
|
$PAGE->set_heading($strinstallation);
|
|
|
|
$PAGE->set_cacheable(false);
|
2011-10-19 13:24:11 +01:00
|
|
|
|
2011-10-18 15:50:36 +01:00
|
|
|
$output = $PAGE->get_renderer('core', 'admin');
|
2011-10-19 13:24:11 +01:00
|
|
|
echo $output->install_licence_page();
|
2011-10-19 14:20:13 +01:00
|
|
|
die();
|
2006-07-20 06:39:48 +00:00
|
|
|
}
|
2009-05-26 09:56:35 +00:00
|
|
|
if (empty($confirmrelease)) {
|
2011-10-19 13:24:11 +01:00
|
|
|
require_once($CFG->libdir.'/environmentlib.php');
|
|
|
|
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
2009-05-26 10:21:56 +00:00
|
|
|
$strcurrentrelease = get_string('currentrelease');
|
2011-10-19 13:24:11 +01:00
|
|
|
|
2009-09-03 05:11:33 +00:00
|
|
|
$PAGE->navbar->add($strcurrentrelease);
|
2011-03-03 17:16:11 +01:00
|
|
|
$PAGE->set_title($strinstallation);
|
|
|
|
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
|
2009-09-03 05:11:33 +00:00
|
|
|
$PAGE->set_cacheable(false);
|
2006-07-20 06:39:48 +00:00
|
|
|
|
2011-10-19 13:24:11 +01:00
|
|
|
$output = $PAGE->get_renderer('core', 'admin');
|
2011-10-27 15:07:34 +02:00
|
|
|
echo $output->install_environment_page($maturity, $envstatus, $environment_results, $release);
|
2011-10-19 14:20:13 +01:00
|
|
|
die();
|
2003-05-26 14:38:41 +00:00
|
|
|
}
|
|
|
|
|
2012-05-25 10:44:29 +02:00
|
|
|
// check plugin dependencies
|
|
|
|
$failed = array();
|
|
|
|
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
|
|
|
$PAGE->navbar->add(get_string('pluginscheck', 'admin'));
|
|
|
|
$PAGE->set_title($strinstallation);
|
|
|
|
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
|
|
|
|
|
|
|
|
$output = $PAGE->get_renderer('core', 'admin');
|
|
|
|
$url = new moodle_url('/admin/index.php', array('agreelicense' => 1, 'confirmrelease' => 1, 'lang' => $CFG->lang));
|
|
|
|
echo $output->unsatisfied_dependencies_page($version, $failed, $url);
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
unset($failed);
|
|
|
|
|
2011-10-27 15:07:34 +02:00
|
|
|
//TODO: add a page with list of non-standard plugins here
|
|
|
|
|
2009-05-26 10:21:56 +00:00
|
|
|
$strdatabasesetup = get_string('databasesetup');
|
2010-01-20 18:07:49 +00:00
|
|
|
upgrade_init_javascript();
|
2011-10-19 13:24:11 +01:00
|
|
|
|
2009-09-03 05:11:33 +00:00
|
|
|
$PAGE->navbar->add($strdatabasesetup);
|
|
|
|
$PAGE->set_title($strinstallation.' - Moodle '.$CFG->target_release);
|
2009-09-03 08:02:59 +00:00
|
|
|
$PAGE->set_heading($strinstallation);
|
2009-09-03 05:11:33 +00:00
|
|
|
$PAGE->set_cacheable(false);
|
2011-10-19 13:24:11 +01:00
|
|
|
|
2011-10-18 15:50:36 +01:00
|
|
|
$output = $PAGE->get_renderer('core', 'admin');
|
|
|
|
echo $output->header();
|
2007-01-22 22:32:00 +00:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
if (!$DB->setup_is_unicodedb()) {
|
|
|
|
if (!$DB->change_db_encoding()) {
|
|
|
|
// If could not convert successfully, throw error, and prevent installation
|
|
|
|
print_error('unicoderequired', 'admin');
|
2009-01-11 11:19:52 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-01 12:52:30 +00:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
install_core($version, true);
|
|
|
|
}
|
2009-01-11 11:19:52 +00:00
|
|
|
|
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
// Check version of Moodle code on disk compared with database
|
|
|
|
// and upgrade if possible.
|
2009-01-11 11:19:52 +00:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
$stradministration = get_string('administration');
|
|
|
|
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
2009-01-11 11:19:52 +00:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
if (empty($CFG->version)) {
|
|
|
|
print_error('missingconfigversion', 'debug');
|
|
|
|
}
|
2009-01-11 11:19:52 +00:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
if ($version > $CFG->version) { // upgrade
|
2011-04-13 15:03:25 +02:00
|
|
|
purge_all_caches();
|
2009-12-16 18:00:58 +00:00
|
|
|
$PAGE->set_pagelayout('maintenance');
|
2010-11-11 06:11:43 +00:00
|
|
|
$PAGE->set_popup_notification_allowed(false);
|
2009-07-09 07:35:03 +00:00
|
|
|
|
2012-01-01 17:24:36 +01:00
|
|
|
if (upgrade_stale_php_files_present()) {
|
|
|
|
$PAGE->set_title($stradministration);
|
|
|
|
$PAGE->set_cacheable(false);
|
|
|
|
|
|
|
|
$output = $PAGE->get_renderer('core', 'admin');
|
|
|
|
echo $output->upgrade_stale_php_files_page();
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
if (empty($confirmupgrade)) {
|
2012-03-28 22:48:18 +02:00
|
|
|
$a = new stdClass();
|
2011-10-19 13:24:11 +01:00
|
|
|
$a->oldversion = "$CFG->release ($CFG->version)";
|
|
|
|
$a->newversion = "$release ($version)";
|
|
|
|
$strdatabasechecking = get_string('databasechecking', '', $a);
|
|
|
|
|
2011-03-03 17:16:11 +01:00
|
|
|
$PAGE->set_title($stradministration);
|
|
|
|
$PAGE->set_heading($strdatabasechecking);
|
2009-09-03 05:11:33 +00:00
|
|
|
$PAGE->set_cacheable(false);
|
2011-10-19 13:24:11 +01:00
|
|
|
|
2011-10-18 15:50:36 +01:00
|
|
|
$output = $PAGE->get_renderer('core', 'admin');
|
2011-10-19 13:24:11 +01:00
|
|
|
echo $output->upgrade_confirm_page($a->newversion, $maturity);
|
2011-10-19 14:20:13 +01:00
|
|
|
die();
|
2009-01-11 11:19:52 +00:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
} else if (empty($confirmrelease)){
|
2011-10-19 13:24:11 +01:00
|
|
|
require_once($CFG->libdir.'/environmentlib.php');
|
|
|
|
list($envstatus, $environment_results) = check_moodle_environment($release, ENV_SELECT_RELEASE);
|
2009-05-26 10:21:56 +00:00
|
|
|
$strcurrentrelease = get_string('currentrelease');
|
2011-10-19 13:24:11 +01:00
|
|
|
|
2009-09-03 05:11:33 +00:00
|
|
|
$PAGE->navbar->add($strcurrentrelease);
|
|
|
|
$PAGE->set_title($strcurrentrelease);
|
2009-09-03 08:05:42 +00:00
|
|
|
$PAGE->set_heading($strcurrentrelease);
|
2009-09-03 05:11:33 +00:00
|
|
|
$PAGE->set_cacheable(false);
|
2009-01-11 11:19:52 +00:00
|
|
|
|
2011-10-19 13:24:11 +01:00
|
|
|
$output = $PAGE->get_renderer('core', 'admin');
|
2011-10-19 13:47:02 +01:00
|
|
|
echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
|
|
|
|
die();
|
2009-01-11 11:19:52 +00:00
|
|
|
|
2011-10-19 13:24:11 +01:00
|
|
|
} else if (empty($confirmplugins)) {
|
2009-05-26 09:56:35 +00:00
|
|
|
$strplugincheck = get_string('plugincheck');
|
2011-10-19 13:24:11 +01:00
|
|
|
|
2009-09-03 05:11:33 +00:00
|
|
|
$PAGE->navbar->add($strplugincheck);
|
|
|
|
$PAGE->set_title($strplugincheck);
|
2009-09-03 08:05:42 +00:00
|
|
|
$PAGE->set_heading($strplugincheck);
|
2009-09-03 05:11:33 +00:00
|
|
|
$PAGE->set_cacheable(false);
|
2011-03-10 00:50:18 +01:00
|
|
|
|
2012-03-19 14:52:17 +01:00
|
|
|
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1));
|
|
|
|
|
|
|
|
if ($fetchupdates) {
|
2012-03-30 11:08:48 +02:00
|
|
|
// no sesskey support guaranteed here
|
2012-05-15 14:30:47 +02:00
|
|
|
if (empty($CFG->disableupdatenotifications)) {
|
|
|
|
available_update_checker::instance()->fetch();
|
|
|
|
}
|
2012-03-19 14:52:17 +01:00
|
|
|
redirect($reloadurl);
|
|
|
|
}
|
|
|
|
|
2011-10-19 13:24:11 +01:00
|
|
|
$output = $PAGE->get_renderer('core', 'admin');
|
2012-03-19 14:52:17 +01:00
|
|
|
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
|
|
|
|
$version, $showallplugins, $reloadurl,
|
2011-10-19 13:24:11 +01:00
|
|
|
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)));
|
2009-05-26 09:56:35 +00:00
|
|
|
die();
|
2009-01-11 11:19:52 +00:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
} else {
|
|
|
|
// Launch main upgrade
|
|
|
|
upgrade_core($version, true);
|
2009-01-29 22:54:41 +00:00
|
|
|
}
|
2009-05-26 09:56:35 +00:00
|
|
|
} else if ($version < $CFG->version) {
|
2010-09-05 19:16:42 +00:00
|
|
|
// better stop here, we can not continue with plugin upgrades or anything else
|
|
|
|
throw new moodle_exception('downgradedcore', 'error', new moodle_url('/admin/'));
|
2009-05-26 09:56:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Updated human-readable release version if necessary
|
|
|
|
if ($release <> $CFG->release) { // Update the release version
|
2009-05-26 10:21:56 +00:00
|
|
|
set_config('release', $release);
|
2009-05-26 09:56:35 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 14:05:40 +08:00
|
|
|
if ($branch <> $CFG->branch) { // Update the branch
|
|
|
|
set_config('branch', $branch);
|
|
|
|
}
|
|
|
|
|
2010-09-05 19:41:00 +00:00
|
|
|
if (moodle_needs_upgrading()) {
|
|
|
|
if (!$PAGE->headerprinted) {
|
2010-09-05 19:44:24 +00:00
|
|
|
// means core upgrade or installation was not already done
|
2010-09-05 19:41:00 +00:00
|
|
|
if (!$confirmplugins) {
|
2011-10-19 13:24:11 +01:00
|
|
|
$strplugincheck = get_string('plugincheck');
|
|
|
|
|
2010-09-05 19:44:24 +00:00
|
|
|
$PAGE->set_pagelayout('maintenance');
|
2010-11-11 06:11:43 +00:00
|
|
|
$PAGE->set_popup_notification_allowed(false);
|
2010-09-05 19:41:00 +00:00
|
|
|
$PAGE->navbar->add($strplugincheck);
|
|
|
|
$PAGE->set_title($strplugincheck);
|
|
|
|
$PAGE->set_heading($strplugincheck);
|
|
|
|
$PAGE->set_cacheable(false);
|
2011-03-10 00:50:18 +01:00
|
|
|
|
2012-03-19 14:52:17 +01:00
|
|
|
if ($fetchupdates) {
|
2012-03-30 11:08:48 +02:00
|
|
|
// no sesskey support guaranteed here
|
2012-03-19 14:52:17 +01:00
|
|
|
available_update_checker::instance()->fetch();
|
|
|
|
redirect($PAGE->url);
|
|
|
|
}
|
|
|
|
|
2011-10-19 13:24:11 +01:00
|
|
|
$output = $PAGE->get_renderer('core', 'admin');
|
2012-03-19 14:52:17 +01:00
|
|
|
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
|
|
|
|
$version, $showallplugins,
|
|
|
|
new moodle_url($PAGE->url),
|
2011-10-19 13:24:11 +01:00
|
|
|
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1)));
|
2010-09-05 19:41:00 +00:00
|
|
|
die();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// install/upgrade all plugins and other parts
|
|
|
|
upgrade_noncore(true);
|
|
|
|
}
|
2009-05-26 09:56:35 +00:00
|
|
|
|
2009-06-24 09:17:56 +00:00
|
|
|
// If this is the first install, indicate that this site is fully configured
|
|
|
|
// except the admin password
|
|
|
|
if (during_initial_install()) {
|
|
|
|
set_config('rolesactive', 1); // after this, during_initial_install will return false.
|
2009-05-26 09:56:35 +00:00
|
|
|
set_config('adminsetuppending', 1);
|
2010-09-18 22:54:46 +00:00
|
|
|
// we need this redirect to setup proper session
|
2009-05-26 09:56:35 +00:00
|
|
|
upgrade_finished("index.php?sessionstarted=1&lang=$CFG->lang");
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
if (!empty($CFG->adminsetuppending)) {
|
|
|
|
$sessionstarted = optional_param('sessionstarted', 0, PARAM_BOOL);
|
|
|
|
if (!$sessionstarted) {
|
|
|
|
redirect("index.php?sessionstarted=1&lang=$CFG->lang");
|
|
|
|
} else {
|
|
|
|
$sessionverify = optional_param('sessionverify', 0, PARAM_BOOL);
|
|
|
|
if (!$sessionverify) {
|
|
|
|
$SESSION->sessionverify = 1;
|
|
|
|
redirect("index.php?sessionstarted=1&sessionverify=1&lang=$CFG->lang");
|
2009-01-29 22:54:41 +00:00
|
|
|
} else {
|
2009-05-26 09:56:35 +00:00
|
|
|
if (empty($SESSION->sessionverify)) {
|
|
|
|
print_error('installsessionerror', 'admin', "index.php?sessionstarted=1&lang=$CFG->lang");
|
2009-01-29 22:54:41 +00:00
|
|
|
}
|
2009-05-26 09:56:35 +00:00
|
|
|
unset($SESSION->sessionverify);
|
2009-01-29 22:54:41 +00:00
|
|
|
}
|
2009-05-26 09:56:35 +00:00
|
|
|
}
|
2009-01-29 22:54:41 +00:00
|
|
|
|
2012-02-29 14:50:48 +10:30
|
|
|
// at this stage there can be only one admin unless more were added by install - users may change username, so do not rely on that
|
2012-03-18 18:37:24 +01:00
|
|
|
$adminids = explode(',', $CFG->siteadmins);
|
|
|
|
$adminuser = get_complete_user_data('id', reset($adminids));
|
2009-01-29 22:54:41 +00:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
if ($adminuser->password === 'adminsetuppending') {
|
|
|
|
// prevent installation hijacking
|
|
|
|
if ($adminuser->lastip !== getremoteaddr()) {
|
|
|
|
print_error('installhijacked', 'admin');
|
2009-01-17 20:25:58 +00:00
|
|
|
}
|
2009-05-26 09:56:35 +00:00
|
|
|
// login user and let him set password and admin details
|
|
|
|
$adminuser->newadminuser = 1;
|
2011-07-10 13:22:55 +02:00
|
|
|
complete_user_login($adminuser);
|
2009-05-26 09:56:35 +00:00
|
|
|
redirect("$CFG->wwwroot/user/editadvanced.php?id=$adminuser->id"); // Edit thyself
|
2009-01-11 11:19:52 +00:00
|
|
|
|
2009-01-12 15:13:44 +00:00
|
|
|
} else {
|
2009-05-26 09:56:35 +00:00
|
|
|
unset_config('adminsetuppending');
|
2004-02-05 09:55:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
} else {
|
|
|
|
// just make sure upgrade logging is properly terminated
|
|
|
|
upgrade_finished('upgradesettings.php');
|
|
|
|
}
|
2008-07-07 14:34:40 +00:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
// Turn xmlstrictheaders back on now.
|
|
|
|
$CFG->xmlstrictheaders = $origxmlstrictheaders;
|
|
|
|
unset($origxmlstrictheaders);
|
|
|
|
|
|
|
|
// Check for valid admin user - no guest autologin
|
|
|
|
require_login(0, false);
|
|
|
|
$context = get_context_instance(CONTEXT_SYSTEM);
|
|
|
|
require_capability('moodle/site:config', $context);
|
|
|
|
|
|
|
|
// check that site is properly customized
|
|
|
|
$site = get_site();
|
|
|
|
if (empty($site->shortname)) {
|
|
|
|
// probably new installation - lets return to frontpage after this step
|
|
|
|
// remove settings that we want uninitialised
|
|
|
|
unset_config('registerauth');
|
|
|
|
redirect('upgradesettings.php?return=site');
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
set_config('registered', time());
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup critical warnings before printing admin tree block
|
2009-05-26 10:21:56 +00:00
|
|
|
$insecuredataroot = is_dataroot_insecure(true);
|
2009-05-26 09:56:35 +00:00
|
|
|
$SESSION->admin_critical_warning = ($insecuredataroot==INSECURE_DATAROOT_ERROR);
|
|
|
|
|
|
|
|
$adminroot = admin_get_root();
|
|
|
|
|
|
|
|
// Check if there are any new admin settings which have still yet to be set
|
|
|
|
if (any_new_admin_settings($adminroot)){
|
|
|
|
redirect('upgradesettings.php');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Everything should now be set up, and the user is an admin
|
|
|
|
|
|
|
|
// Print default admin page with notifications.
|
2011-10-19 13:24:11 +01:00
|
|
|
$errorsdisplayed = defined('WARN_DISPLAY_ERRORS_ENABLED');
|
2011-04-13 15:03:25 +02:00
|
|
|
|
2009-05-26 09:56:35 +00:00
|
|
|
$lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}');
|
2011-10-19 13:24:11 +01:00
|
|
|
$cronoverdue = ($lastcron < time() - 3600 * 24);
|
|
|
|
$dbproblems = $DB->diagnose();
|
|
|
|
$maintenancemode = !empty($CFG->maintenance_enabled);
|
2002-09-19 12:01:55 +00:00
|
|
|
|
2012-03-16 23:34:37 +01:00
|
|
|
$updateschecker = available_update_checker::instance();
|
2012-03-22 13:06:58 +01:00
|
|
|
$availableupdates = $updateschecker->get_update_info('core',
|
|
|
|
array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
|
2012-03-16 23:34:37 +01:00
|
|
|
$availableupdatesfetch = $updateschecker->get_last_timefetched();
|
|
|
|
|
2011-10-19 13:24:11 +01:00
|
|
|
admin_externalpage_setup('adminnotifications');
|
2012-03-16 23:34:37 +01:00
|
|
|
|
|
|
|
if ($fetchupdates) {
|
|
|
|
require_sesskey();
|
|
|
|
$updateschecker->fetch();
|
|
|
|
redirect($PAGE->url);
|
|
|
|
}
|
|
|
|
|
2011-10-19 13:24:11 +01:00
|
|
|
$output = $PAGE->get_renderer('core', 'admin');
|
|
|
|
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
|
2012-03-16 23:34:37 +01:00
|
|
|
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch);
|