From cf764594cd00e66ee812c5d63b016bf286178f67 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 13 Mar 2010 11:52:36 -0800 Subject: added check in DB_open for correct DB-version --- include/db.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include/db.php') 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; } -- cgit v1.2.3-18-g5258 From 850378a3e2da48d387dc565cc6e3c2b47f12e34d Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 13 Mar 2010 15:59:07 -0800 Subject: NEW FEATURE: having only low trump (fox and below) can now be a Vorbehalt The low trump can either be treated as poverty or similar to 5 nines, that is the game is canceled unless someone plays a solo. Also minor code cleanup. --- include/db.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'include/db.php') diff --git a/include/db.php b/include/db.php index 5503a4a..2a927f5 100644 --- a/include/db.php +++ b/include/db.php @@ -30,7 +30,7 @@ if(!isset($HOST)) function DB_open() { - $version_needed = 1; + $version_needed = 2; global $DB,$DB_user,$DB_host,$DB_database,$DB_password; $DB = @mysql_connect($DB_host,$DB_user, $DB_password); @@ -703,14 +703,15 @@ function DB_get_hashes_by_session($session,$user) return $r; } -function DB_get_ruleset($dullen,$schweinchen,$call) +function DB_get_ruleset($dullen,$schweinchen,$call,$lowtrump) { $r = array(); $result = DB_query("SELECT id FROM Rulesets WHERE". " dullen=".DB_quote_smart($dullen)." AND ". " Rulesets.call=".DB_quote_smart($call)." AND ". - " schweinchen=".DB_quote_smart($schweinchen)); + " schweinchen=".DB_quote_smart($schweinchen)." AND ". + " lowtrump=".DB_quote_smart($lowtrump)); if($result) $r = DB_fetch_array($result); @@ -722,6 +723,7 @@ function DB_get_ruleset($dullen,$schweinchen,$call) $result = DB_query("INSERT INTO Rulesets VALUES (NULL, NULL, ". DB_quote_smart($dullen).",". DB_quote_smart($schweinchen).",". + DB_quote_smart($lowtrump).",". DB_quote_smart($call). ", NULL)"); if($result) @@ -834,9 +836,10 @@ function DB_get_RULES($gameid) " LEFT JOIN Game ON Game.ruleset=Rulesets.id ". " WHERE Game.id='$gameid'" ); - $RULES["dullen"] = $r[2]; - $RULES["schweinchen"] = $r[3]; - $RULES["call"] = $r[4]; + $RULES['dullen'] = $r[2]; + $RULES['schweinchen'] = $r[3]; + $RULES['lowtrump'] = $r[4]; + $RULES['call'] = $r[5]; return $RULES; } -- cgit v1.2.3-18-g5258 From 83fc1a851c69e13808d14f2d5a284c3369409018 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sun, 14 Mar 2010 14:11:52 -0700 Subject: NEW FEATURE: added localization support using gettext to add support for localization --- include/db.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/db.php') diff --git a/include/db.php b/include/db.php index 2a927f5..ad6c6f0 100644 --- a/include/db.php +++ b/include/db.php @@ -772,6 +772,7 @@ function DB_get_PREF($myid) $PREF['vacation_start'] = NULL; $PREF['vacation_stop'] = NULL; $PREF['vacation_comment'] = ''; + $PREF['language'] = 'en'; /* get all preferences */ $r = DB_query('SELECT pref_key, value FROM User_Prefs'. @@ -825,8 +826,14 @@ function DB_get_PREF($myid) if($pref[1]) $PREF['vacation_comment'] = $pref[1]; break; + + case 'language': + if($pref[1]) + $PREF['language'] = $pref[1]; + break; } } + $_SESSION['language'] = $PREF['language']; return $PREF; } -- cgit v1.2.3-18-g5258