2 global $db, $METATABLES;
4 /// Check if the main tables have been installed yet or not.
5 if (!$METATABLES) { // No tables yet at all.
10 foreach ($METATABLES as $table) {
11 if (preg_match("/^{$CFG->prefix}users$/", $table)) {
14 if (preg_match("/^{$CFG->prefix}datalists$/", $table)) {
20 $strdatabasesuccess = "Yay!"; // well, if people leave never-defined variables about the place...
25 if (file_exists($CFG->dirroot
. "lib/db/$CFG->dbtype.sql")) {
30 $infoarr = $db->ServerInfo();
31 if (!empty($infoarr['version'])) {
32 switch($CFG->dbtype
) {
34 if (!preg_match('/^(4\.1|[5-9]\.|[0-9][0-9]+)/', $infoarr['version'])) {
35 error('Error: Your MySQL version is too old: ' . $infoarr['version'] . '. Elgg requires MySQL 4.1 or newer. 5.0 or newer is recommended.');
43 if (modify_database($CFG->dirroot
. "lib/db/$CFG->dbtype.sql")) {
44 include_once($CFG->dirroot
. "version.php");
45 set_config('version', $version);
47 notify($strdatabasesuccess, "green");
48 if (!isset($CFG->newsinitialpassword
) ||
empty($CFG->newsinitialpassword
)) {
49 notify("WARNING: the initial password for the news account is 'password'. This account has administrator privileges, and you should log in and change the password as soon as installation is complete.");
51 //$newspassword = $db->qstr(md5($CFG->newsinitialpassword));
52 //execute_sql("update ".$CFG->prefix."users set password = $newspassword where username = 'news'");
53 set_field('users', 'password', md5($CFG->newsinitialpassword
), 'username', 'news');
55 //execute_sql("update ".$CFG->prefix."users set email = ". $db->qstr($CFG->sysadminemail) ." where username = 'news'");
56 set_field('users', 'email', $CFG->sysadminemail
, 'username', 'news');
59 error("Error: Main databases NOT set up successfully");
63 error("Error: Your database ($CFG->dbtype) is not yet fully supported by Elgg. See the lib/db directory.");
65 print_continue("index.php");
69 if (user_flag_get("admin",$_SESSION['userid'])) {
71 if (empty($CFG->version
)) {
75 if (empty($CFG->release
)) {
84 include_once($CFG->dirroot
. "version.php"); # defines $version
85 include_once($CFG->dirroot
. "lib/db/$CFG->dbtype.php"); # defines upgrades
88 if ($version > $CFG->version
) { // upgrade
90 $a->oldversion
= "$CFG->release ($CFG->version)";
91 $a->newversion
= "$release ($version)";
93 if (empty($_GET['confirmupgrade'])) {
94 notice_yesno(__gettext('Need to upgrade database'), $CFG->wwwroot
. '?confirmupgrade=yes', '');
99 if (main_upgrade($CFG->version
)) {
101 if (set_config("version", $version)) {
102 notify($strdatabasesuccess, "green");
103 print_continue("index.php");
106 notify("Upgrade failed! (Could not update version in config table)");
110 notify("Upgrade failed! See /version.php");
113 } else if ($version < $CFG->version
) {
114 notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
118 if (set_config("version", $version)) {
119 print_header("Elgg $release ($version)");
120 print_continue("index.php");
124 if (main_upgrade(0)) {
125 print_continue("index.php");
127 error("A problem occurred inserting current version into databases");