projects
/
e-DoKo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
fceb0d9
)
added check in DB_open for correct DB-version
author
Arun Persaud
<arun@nubati.net>
Sat, 13 Mar 2010 19:52:36 +0000
(11:52 -0800)
committer
Arun Persaud
<arun@nubati.net>
Sun, 14 Mar 2010 00:05:34 +0000
(16:05 -0800)
include/db.php
patch
|
blob
|
history
index.php
patch
|
blob
|
history
diff --git
a/include/db.php
b/include/db.php
index b79da87def6d231ccbc39507619e21a049cc8e09..5503a4a160e2ea9baf83eb8bbc245f5a0b159437 100644
(file)
--- a/
include/db.php
+++ b/
include/db.php
@@
-30,17
+30,24
@@
if(!isset($HOST))
function DB_open()
{
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 )
{
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;
}
else
{
echo mysql_errno() . ": " . mysql_error(). "\n";
return -1;
- }
+ };
+
+ $version = DB_get_version();
+ if ($version != $version_needed)
+ return -2;
+
return 0;
}
return 0;
}
diff --git
a/index.php
b/index.php
index 83618f32d856d089b33b1b5bfb306297c8951647..54efdcbf9aef946b72f536a0b39918c8dbc59f84 100644
(file)
--- a/
index.php
+++ b/
index.php
@@
-36,11
+36,17
@@
include_once("./include/functions.php"); /* the rest */
config_check();
/* open the database */
config_check();
/* open the database */
-if(DB_open()<0)
+$DBopen = DB_open();
+if($DBopen<0)
{
output_header();
{
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();
}
output_footer();
exit();
}