Changeset 1026

Show
Ignore:
Timestamp:
03/14/07 12:42:06 (2 years ago)
Author:
sven
Message:

add mysql version check on install

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/lib/dbsetup.php

    r701 r1026  
    2525    if (file_exists($CFG->dirroot . "lib/db/$CFG->dbtype.sql")) { 
    2626        $db->debug = true; 
    27         if (modify_database($CFG->dirroot . "lib/db/$CFG->dbtype.sql")) { 
    28             include_once($CFG->dirroot . "version.php"); 
    29             set_config('version', $version); 
    30             $db->debug = false; 
    31             notify($strdatabasesuccess, "green"); 
    32             if (!isset($CFG->newsinitialpassword) || empty($CFG->newsinitialpassword)) { 
    33                 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."); 
     27         
     28        //version check 
     29        $continue = true; 
     30        $infoarr = $db->ServerInfo(); 
     31        if (!empty($infoarr['version'])) { 
     32            switch($CFG->dbtype) { 
     33                case "mysql": 
     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.'); 
     36                        $continue = false; 
     37                    } 
     38                break; 
     39            } 
     40        } 
     41         
     42        if ($continue) { 
     43            if (modify_database($CFG->dirroot . "lib/db/$CFG->dbtype.sql")) { 
     44                include_once($CFG->dirroot . "version.php"); 
     45                set_config('version', $version); 
     46                $db->debug = false; 
     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."); 
     50                } else { 
     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'); 
     54                } 
     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'); 
    3457            } else { 
    35                 //$newspassword = $db->qstr(md5($CFG->newsinitialpassword)); 
    36                 //execute_sql("update ".$CFG->prefix."users set password = $newspassword where username = 'news'"); 
    37                 set_field('users', 'password', md5($CFG->newsinitialpassword), 'username', 'news'); 
     58                $db->debug = false; 
     59                error("Error: Main databases NOT set up successfully"); 
    3860            } 
    39             //execute_sql("update ".$CFG->prefix."users set email = ". $db->qstr($CFG->sysadminemail) ." where username = 'news'"); 
    40             set_field('users', 'email', $CFG->sysadminemail, 'username', 'news'); 
    41         } else { 
    42             $db->debug = false; 
    43             error("Error: Main databases NOT set up successfully"); 
    4461        } 
    4562    } else {