From: Arun Persaud Date: Sat, 13 Mar 2010 19:52:36 +0000 (-0800) Subject: added check in DB_open for correct DB-version X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=commitdiff_plain;h=cf764594cd00e66ee812c5d63b016bf286178f67;hp=fceb0d9bc48ae848461e728abaf5065a2578da61 added check in DB_open for correct DB-version --- diff --git a/include/db.php b/include/db.php index b79da87..5503a4a 100644 --- a/include/db.php +++ b/include/db.php @@ -30,17 +30,24 @@ if(!isset($HOST)) function DB_open() { + $version_needed = 1; + global $DB,$DB_user,$DB_host,$DB_database,$DB_password; $DB = @mysql_connect($DB_host,$DB_user, $DB_password); if ( $DB ) { - mysql_select_db($DB_database) or die('Could not select database'); + mysql_select_db($DB_database) or die('Error: Could not select database'); } else { echo mysql_errno() . ": " . mysql_error(). "\n"; return -1; - } + }; + + $version = DB_get_version(); + if ($version != $version_needed) + return -2; + return 0; } diff --git a/index.php b/index.php index 83618f3..54efdcb 100644 --- a/index.php +++ b/index.php @@ -36,11 +36,17 @@ include_once("./include/functions.php"); /* the rest */ config_check(); /* open the database */ -if(DB_open()<0) +$DBopen = DB_open(); +if($DBopen<0) { output_header(); - echo "Database error, can't connect... Please wait a while and try again. ". - "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL."; + + if($DBopen == -1) + echo "Database error, can't connect... Please wait a while and try again. ". + "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL."; + else if ($DBopen == -2) + echo "Wrong database version, please update your database using the update.php script."; + output_footer(); exit(); }