You need to create a config.php.
See the installation instructions.";
die;
}
require_once("../config.php");
/// Check that PHP is of a sufficient version
if (!check_php_version("4.1.0")) {
$version = phpversion();
print_heading("Sorry, Moodle requires PHP 4.1.0 or later (currently using version $version)");
die;
}
/// Check some PHP server settings
$documentationlink = "please read the install documentation";
if (ini_get_bool('session.auto_start')) {
error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
}
if (ini_get_bool('magic_quotes_runtime')) {
error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink");
}
if (!ini_get_bool('magic_quotes_gpc')) {
error("The PHP server variable 'magic_quotes_gpc' is not turned On - $documentationlink");
}
if (!ini_get_bool('file_uploads')) {
error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
}
if (!ini_get_bool('short_open_tag')) {
error("The PHP server variable 'short_open_tag' is not turned On - $documentationlink");
}
/// Check that sessions are supported
if (!is_readable(ini_get('session.save_path')) and !ini_get_bool('safe_mode')) {
$sessionpath = ini_get('session.save_path');
notify("Warning: It appears your server does not support sessions (session.save_path = '$sessionpath')");
}
/// Check that config.php has been edited
if ($CFG->wwwroot == "http://example.com/moodle") {
error("Moodle has not been configured yet. You need to to edit config.php first.");
}
/// Check settings in config.php
$dirroot = dirname(realpath("../config.php"));
if (!empty($dirroot) and $dirroot != $CFG->dirroot) {
error("Please fix your settings in config.php:
You have:
\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
but it should be:
\$CFG->dirroot = \"".addslashes($dirroot)."\";",
"./");
}
/// Set some necessary variables during set-up to avoid PHP warnings later on this page
if (!isset($CFG->framename)) {
$CFG->framename = "_top";
}
if (!isset($CFG->release)) {
$CFG->release = "";
}
if (!isset($CFG->version)) {
$CFG->version = "";
}
/// Check if the main tables have been installed yet or not.
if (! $tables = $db->Metatables() ) { // No tables yet at all.
$maintables = false;
} else { // Check for missing main tables
$maintables = true;
$mtables = array("config", "course", "course_categories", "course_modules",
"course_sections", "log", "log_display", "modules",
"user", "user_admins", "user_students", "user_teachers");
foreach ($mtables as $mtable) {
if (!in_array($CFG->prefix.$mtable, $tables)) {
$maintables = false;
break;
}
}
}
if (! $maintables) {
if (empty($agreelicence)) {
$strlicense = get_string("license");
print_header($strlicense, $strlicense, $strlicense, "", "", false, " ", " ");
print_heading("Moodle - Modular Object-Oriented Dynamic Learning Environment");
print_heading(get_string("copyrightnotice"));
print_simple_box_start("center");
echo text_to_html(get_string("gpl"));
print_simple_box_end();
echo "
";
notice_yesno(get_string("doyouagree"), "index.php?agreelicence=true",
"http://moodle.org/doc/?frame=licence.html");
exit;
}
$strdatabasesetup = get_string("databasesetup");
$strdatabasesuccess = get_string("databasesuccess");
print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup, "", "", false, " ", " ");
if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
$db->debug = true;
set_time_limit(0); // To allow slow databases to complete the long SQL
if (modify_database("$CFG->libdir/db/$CFG->dbtype.sql")) {
$db->debug = false;
notify($strdatabasesuccess, "green");
} else {
$db->debug = false;
error("Error: Main databases NOT set up successfully");
}
} else {
error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle. See the lib/db directory.");
}
print_continue("index.php");
die;
}
/// Check version of Moodle code on disk compared with database
/// and upgrade if possible.
include_once("$CFG->dirroot/version.php"); # defines $version
include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines upgrades
if ($CFG->version) {
if ($version > $CFG->version) { // upgrade
$a->oldversion = $CFG->version;
$a->newversion = $version;
$strdatabasechecking = get_string("databasechecking", "", $a);
$strdatabasesuccess = get_string("databasesuccess");
print_header($strdatabasechecking, $strdatabasechecking, $strdatabasechecking,
"", "", false, " ", " ");
print_heading($strdatabasechecking);
$db->debug=true;
if (main_upgrade($CFG->version)) {
$db->debug=false;
if (set_config("version", $version)) {
notify($strdatabasesuccess, "green");
print_continue("index.php");
die;
} else {
notify("Upgrade failed! (Could not update version in config table)");
}
} else {
$db->debug=false;
notify("Upgrade failed! See /version.php");
}
} else if ($version < $CFG->version) {
notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
}
} else {
$strcurrentversion = get_string("currentversion");
print_header($strcurrentversion, $strcurrentversion, $strcurrentversion,
"", "", false, " ", " ");
if (set_config("version", $version)) {
print_heading("You are currently using Moodle version $version (Release $release)");
print_continue("index.php");
die;
} else {
$db->debug=true;
if (main_upgrade(0)) {
print_continue("index.php");
} else {
error("A problem occurred inserting current version into databases");
}
$db->debug=false;
}
}
/// Updated human-readable release version if necessary
if ($release <> $CFG->release) { // Update the release version
$strcurrentrelease = get_string("currentrelease");
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, " ", " ");
print_heading("Moodle $release");
if (!set_config("release", $release)) {
notify("ERROR: Could not update release version in database!!");
}
print_continue("index.php");
print_simple_box_start("CENTER");
include("$CFG->dirroot/lang/en/docs/release.html");
print_simple_box_end();
print_continue("index.php");
exit;
}
/// Upgrade backup/restore system if necessary
require_once("$CFG->dirroot/backup/lib.php");
upgrade_backup_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
/// Find and check all modules and load them up or upgrade them if necessary
if (!$mods = get_list_of_plugins("mod") ) {
error("No modules installed!");
}
foreach ($mods as $mod) {
if ($mod == "NEWMODULE") { // Someone has unzipped the template, ignore it
continue;
}
$fullmod = "$CFG->dirroot/mod/$mod";
unset($module);
if ( is_readable("$fullmod/version.php")) {
include_once("$fullmod/version.php"); # defines $module with version etc
} else {
notify("Module $mod: $fullmod/version.php was not readable");
continue;
}
if ( is_readable("$fullmod/db/$CFG->dbtype.php")) {
include_once("$fullmod/db/$CFG->dbtype.php"); # defines upgrading function
} else {
notify("Module $mod: $fullmod/db/$CFG->dbtype.php was not readable");
continue;
}
if (!isset($module)) {
continue;
}
$module->name = $mod; // The name MUST match the directory
if ($currmodule = get_record("modules", "name", $module->name)) {
if ($currmodule->version == $module->version) {
// do nothing
} else if ($currmodule->version < $module->version) {
print_heading("$module->name module needs upgrading");
$upgrade_function = $module->name."_upgrade";
if (function_exists($upgrade_function)) {
$db->debug=true;
if ($upgrade_function($currmodule->version, $module)) {
$db->debug=false;
// OK so far, now update the modules record
$module->id = $currmodule->id;
if (! update_record("modules", $module)) {
error("Could not update $module->name record in modules table!");
}
notify(get_string("modulesuccess", "", $module->name), "green");
echo "
$copyrighttext
"; print_single_button("$CFG->wwwroot/doc", NULL, get_string("documentation")); echo " | "; echo ""; print_single_button("register.php", NULL, get_string("registration")); echo " | "; echo "