X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fdb.php;h=ad6c6f0cfbae967f536e99073f436ef6b9b8d781;hp=55d97c97e4673134418ad5a1aa49f934a65e799a;hb=c581cd05476d07f0fd17dab41cbb211a443fd57f;hpb=f2217bfa18ba8a8ab17dd188b38777460ae0590d diff --git a/include/db.php b/include/db.php index 55d97c9..ad6c6f0 100644 --- a/include/db.php +++ b/include/db.php @@ -1,4 +1,23 @@ + * + * This file is part of e-DoKo. + * + * e-DoKo is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * e-DoKo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with e-DoKo. If not, see . + * + */ + /* make sure that we are not called from outside the scripts, * use a variable defined in config.php to check this */ @@ -11,17 +30,24 @@ if(!isset($HOST)) function DB_open() { + $version_needed = 2; + 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; } @@ -677,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); @@ -696,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) @@ -744,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'. @@ -797,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; } @@ -808,9 +843,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; }