3 /// Check that config.php exists, if not then call the install script
4 if (!file_exists("../config.php")) {
5 header('Location: ../install.php');
9 require_once("../config.php");
10 include_once("$CFG->dirroot/lib/adminlib.php"); // Contains various admin-only functions
13 /// Check that PHP is of a sufficient version
15 if (!check_php_version("4.1.0")) {
16 $version = phpversion();
17 print_heading("Sorry, Moodle requires PHP 4.1.0 or later (currently using version $version)");
22 /// Check some PHP server settings
24 $documentationlink = "please read the <A HREF=\"../doc/?frame=install.html&sub=webserver\">install documentation</A>";
26 if (ini_get_bool('session.auto_start')) {
27 error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
30 if (ini_get_bool('magic_quotes_runtime')) {
31 error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink");
34 if (!ini_get_bool('file_uploads')) {
35 error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
39 /// Check that config.php has been edited
41 if ($CFG->wwwroot
== "http://example.com/moodle") {
42 error("Moodle has not been configured yet. You need to to edit config.php first.");
46 /// Check settings in config.php
48 $dirroot = dirname(realpath("../index.php"));
49 if (!empty($dirroot) and $dirroot != $CFG->dirroot
) {
50 error("Please fix your settings in config.php:
52 <P>\$CFG->dirroot = \"".addslashes($CFG->dirroot
)."\";
54 <P>\$CFG->dirroot = \"".addslashes($dirroot)."\";",
58 /// Set some necessary variables during set-up to avoid PHP warnings later on this page
59 if (!isset($CFG->framename
)) {
60 $CFG->framename
= "_top";
62 if (!isset($CFG->release
)) {
65 if (!isset($CFG->version
)) {
69 /// Turn off time limits, sometimes upgrades can be slow.
73 /// Check if the main tables have been installed yet or not.
75 if (! $tables = $db->Metatables() ) { // No tables yet at all.
78 } else { // Check for missing main tables
80 $mtables = array("config", "course", "course_categories", "course_modules",
81 "course_sections", "log", "log_display", "modules",
82 "user", "user_admins", "user_students", "user_teachers");
83 foreach ($mtables as $mtable) {
84 if (!in_array($CFG->prefix
.$mtable, $tables)) {
92 if (empty($agreelicence)) {
93 $strlicense = get_string("license");
94 print_header($strlicense, $strlicense, $strlicense, "", "", false, " ", " ");
95 print_heading("<A HREF=\"http://moodle.org\">Moodle</A> - Modular Object-Oriented Dynamic Learning Environment");
96 print_heading(get_string("copyrightnotice"));
97 print_simple_box_start("center");
98 echo text_to_html(get_string("gpl"));
99 print_simple_box_end();
101 notice_yesno(get_string("doyouagree"), "index.php?agreelicence=true",
102 "http://moodle.org/doc/?frame=licence.html");
106 $strdatabasesetup = get_string("databasesetup");
107 $strdatabasesuccess = get_string("databasesuccess");
108 print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup, "", "", false, " ", " ");
109 if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
111 if (modify_database("$CFG->libdir/db/$CFG->dbtype.sql")) {
113 notify($strdatabasesuccess, "green");
116 error("Error: Main databases NOT set up successfully");
119 error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle. See the lib/db directory.");
121 print_continue("index.php");
126 /// Insert default values for any important configuration variables
128 include_once("$CFG->dirroot/lib/defaults.php");
130 foreach ($defaults as $name => $value) {
131 if (!isset($CFG->$name)) {
132 $CFG->$name = $value;
133 set_config($name, $value);
134 $configchange = true;
138 /// If any new configurations were found then send to the config page to check
140 if (!empty($configchange)) {
141 redirect("config.php");
145 /// Check version of Moodle code on disk compared with database
146 /// and upgrade if possible.
148 include_once("$CFG->dirroot/version.php"); # defines $version
149 include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines upgrades
152 if ($version > $CFG->version
) { // upgrade
153 $a->oldversion
= $CFG->version
;
154 $a->newversion
= $version;
155 $strdatabasechecking = get_string("databasechecking", "", $a);
156 $strdatabasesuccess = get_string("databasesuccess");
157 print_header($strdatabasechecking, $strdatabasechecking, $strdatabasechecking,
158 "", "", false, " ", " ");
159 print_heading($strdatabasechecking);
161 if (main_upgrade($CFG->version
)) {
163 if (set_config("version", $version)) {
164 notify($strdatabasesuccess, "green");
165 print_continue("index.php");
168 notify("Upgrade failed! (Could not update version in config table)");
172 notify("Upgrade failed! See /version.php");
174 } else if ($version < $CFG->version
) {
175 notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
179 $strcurrentversion = get_string("currentversion");
180 print_header($strcurrentversion, $strcurrentversion, $strcurrentversion,
181 "", "", false, " ", " ");
183 if (set_config("version", $version)) {
184 print_heading("You are currently using Moodle version $version (Release $release)");
185 print_continue("index.php");
189 if (main_upgrade(0)) {
190 print_continue("index.php");
192 error("A problem occurred inserting current version into databases");
198 /// Updated human-readable release version if necessary
200 if ($release <> $CFG->release
) { // Update the release version
201 $strcurrentrelease = get_string("currentrelease");
202 print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, " ", " ");
203 print_heading("Moodle $release");
204 if (!set_config("release", $release)) {
205 notify("ERROR: Could not update release version in database!!");
207 print_continue("index.php");
208 print_simple_box_start("CENTER");
209 include("$CFG->dirroot/lang/en/docs/release.html");
210 print_simple_box_end();
211 print_continue("index.php");
216 /// Upgrade backup/restore system if necessary
217 require_once("$CFG->dirroot/backup/lib.php");
218 upgrade_backup_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
220 /// Upgrade blocks system if necessary
221 require_once("$CFG->dirroot/lib/blocklib.php");
222 upgrade_blocks_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
224 /// Check all blocks and load (or upgrade them if necessary)
225 upgrade_blocks_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
227 /// Check all enrolment plugins and upgrade if necessary
228 upgrade_enrol_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
230 /// Find and check all main modules and load them up or upgrade them if necessary
231 upgrade_activity_modules("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
235 /// Set up the overall site name etc.
236 if (! $site = get_site()) {
237 redirect("site.php");
240 /// Set up the admin user
241 if (! record_exists("user_admins")) { // No admin user yet
242 redirect("user.php");
245 /// Check for valid admin user
249 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
253 /// At this point everything is set up and the user is an admin, so print menu
255 $stradministration = get_string("administration");
256 print_header("$site->shortname: $stradministration","$site->fullname", "$stradministration");
257 print_simple_box_start("center", "100%", "$THEME->cellcontent2", 20);
258 print_heading($stradministration);
260 if (!empty($CFG->upgrade
)) { // Print notice about extra upgrading that needs to be done
261 print_simple_box(get_string("upgrade$CFG->upgrade", "admin",
262 "$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"), "center");
266 $table->tablealign
= "right";
267 $table->align
= array ("right", "left");
268 $table->wrap
= array ("nowrap", "nowrap");
269 $table->cellpadding
= 4;
270 $table->cellspacing
= 3;
271 $table->width
= "40%";
273 $configdata = "<font size=+1> </font><a href=\"config.php\">".get_string("configvariables")."</a> - <font size=1>".
274 get_string("adminhelpconfigvariables")."</font><br />";
275 $configdata .= "<font size=+1> </font><a href=\"site.php\">".get_string("sitesettings")."</a> - <font size=1>".
276 get_string("adminhelpsitesettings")."</font><br />";
277 $configdata .= "<font size=+1> </font><a href=\"../theme/index.php\">".get_string("themes")."</a> - <font size=1>".
278 get_string("adminhelpthemes")."</font><br />";
279 $configdata .= "<font size=+1> </font><a href=\"lang.php\">".get_string("language")."</a> - <font size=1>".
280 get_string("adminhelplanguage")."</font><br />";
281 $configdata .= "<font size=+1> </font><a href=\"modules.php\">".get_string("managemodules")."</a> - <font size=1>".
282 get_string("adminhelpmanagemodules")."</font><br />";
283 $configdata .= "<font size=+1> </font><a href=\"blocks.php\">".get_string("manageblocks")."</a> - <font size=1>".
284 get_string("adminhelpmanageblocks")."</font><br />";
285 $configdata .= "<font size=+1> </font><a href=\"filters.php?sesskey=$USER->sesskey\">".get_string("managefilters")."</a> - <font size=1>".
286 get_string("adminhelpmanagefilters")."</font><br />";
287 if (!isset($CFG->disablescheduledbackups
)) {
288 $configdata .= "<font size=+1> </font><a href=\"backup.php?sesskey=$USER->sesskey\">".get_string("backup")."</a> - <font size=1>".
289 get_string("adminhelpbackup")."</font><br />";
291 $configdata .= "<font size=+1> </font><a href=\"editor.php?sesskey=$USER->sesskey\">". get_string("editorsettings") ."</a> - <font size=1>".
292 get_string("adminhelpeditorsettings")."</font><br />";
294 $table->data
[] = array("<font size=+1><b><a href=\"configure.php\">".get_string("configuration")."</a></b>",
298 $userdata = "<font size=+1> </font><a href=\"auth.php?sesskey=$USER->sesskey\">".get_string("authentication")."</a> - <font size=1>".
299 get_string("adminhelpauthentication")."</font><br />";
300 $userdata .= "<font size=+1> </font><a href=\"user.php\">".get_string("edituser")."</a> - <font size=1>".
301 get_string("adminhelpedituser")."</font><br />";
302 $userdata .= "<font size=+1> </font><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true&sesskey=$USER->sesskey\">".
303 get_string("addnewuser")."</a> - <font size=1>".
304 get_string("adminhelpaddnewuser")."</font><br />";
305 $userdata .= "<font size=+1> </font><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php?sesskey=$USER->sesskey\">".
306 get_string("uploadusers")."</a> - <font size=1>".
307 get_string("adminhelpuploadusers")."</font><br />";
309 $userdata .= "<hr><font size=+1> </font><a href=\"enrol.php?sesskey=$USER->sesskey\">".get_string("enrolments")."</a> - <font size=1>".
310 get_string("adminhelpenrolments")."</font><br />";
311 $userdata .= "<font size=+1> </font><a href=\"../course/index.php?edit=off&sesskey=$USER->sesskey\">".get_string("assignstudents")."</a> - <font size=1>".
312 get_string("adminhelpassignstudents")."</font><br />";
314 $userdata .= "<font size=+1> </font><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("assignteachers")."</a> - <font size=1>".
315 get_string("adminhelpassignteachers").
316 " <img src=\"../pix/t/user.gif\" height=11 width=11></font><br />";
317 $userdata .= "<font size=+1> </font><a href=\"creators.php?sesskey=$USER->sesskey\">".get_string("assigncreators")."</a> - <font size=1>".
318 get_string("adminhelpassigncreators")."</font><br />";
319 $userdata .= "<font size=+1> </font><a href=\"admin.php?sesskey=$USER->sesskey\">".get_string("assignadmins")."</a> - <font size=1>".
320 get_string("adminhelpassignadmins")."</font><br />";
322 $table->data
[] = array("<font size=+1><b><a href=\"users.php\">".get_string("users")."</a></b>", $userdata);
324 $table->data
[] = array("<font size=+1><b><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("courses")."</a></b>",
325 "<font size=+1> </font>".get_string("adminhelpcourses"));
326 $table->data
[] = array("<font size=+1><b><a href=\"../course/log.php?id=$site->id\">".get_string("logs")."</a></b>",
327 "<font size=+1> </font>".get_string("adminhelplogs"));
328 $table->data
[] = array("<font size=+1><b><a href=\"../files/index.php?id=$site->id\">".get_string("sitefiles")."</a></b>",
329 "<font size=+1> </font>".get_string("adminhelpsitefiles"));
330 if (file_exists("$CFG->dirroot/$CFG->admin/$CFG->dbtype")) {
331 $table->data
[] = array("<font size=+1><b><a href=\"$CFG->dbtype/frame.php\">".get_string("managedatabase")."</a></b>",
332 "<font size=+1> </font>".get_string("adminhelpmanagedatabase"));
337 //////////////////////////////////////////////////////////////////////////////////////////////////
338 //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO REMOVE OR MODIFY THE COPYRIGHT NOTICE BELOW ////
339 $copyrighttext = "<a href=\"http://moodle.org/\">Moodle</a> ".
340 "<a href=\"../doc/?frame=release.html\">$CFG->release</a> ($CFG->version)<br />".
341 "Copyright © 1999-2004 Martin Dougiamas<br />".
342 "<a href=\"../doc/?frame=licence.html\">GNU Public License</a>";
343 echo "<center><p><font size=1>$copyrighttext</font></p></center>";
344 //////////////////////////////////////////////////////////////////////////////////////////////////
347 echo "<table border=0 align=center width=100%><tr>";
348 echo "<td align=center width=33%>";
349 print_single_button("$CFG->wwwroot/doc", NULL, get_string("documentation"));
352 echo "<td align=center width=33%>";
353 print_single_button("phpinfo.php", NULL, get_string("phpinfo"));
356 echo "<td align=center width=33%>";
357 $options['sesskey'] = $USER->sesskey
;
358 print_single_button("register.php", $options, get_string("registration"));
362 print_simple_box_end();