* FIX: added extra check for calling 120, etc. so that people can't cheat
[e-DoKo.git] / db.php
diff --git a/db.php b/db.php
index 98e77249f6f2aab77271ac1d553986d1b940fc72..935c8486660d3d8453596dc65fac6db4f587fe7d 100644 (file)
--- a/db.php
+++ b/db.php
@@ -629,6 +629,24 @@ function DB_set_startplayer_by_gameid($id,$p)
   return;
 }
 
+function DB_get_player_by_gameid($id)
+{
+  $result = mysql_query("SELECT player FROM Game WHERE id=".DB_quote_smart($id));
+  $r      = mysql_fetch_array($result,MYSQL_NUM);
+  
+  if($r)
+    return $r[0];
+  else
+    return 0;
+}
+function DB_set_player_by_gameid($id,$p)
+{
+  mysql_query("UPDATE Game SET player='".DB_quote_smart($p)."' WHERE id=".DB_quote_smart($id));
+  return;
+}
+
+
+
 function DB_get_ruleset_by_gameid($id)
 {
   $result = mysql_query("SELECT ruleset FROM Game WHERE id=".DB_quote_smart($id));
@@ -662,6 +680,20 @@ function DB_get_max_session()
     return 0;
 }
 
+function DB_get_hashes_by_session($session,$user)
+{
+  $r = array();
+
+  $result = mysql_query("SELECT Hand.hash FROM Hand".
+                       " LEFT JOIN Game ON Game.id=Hand.game_id ".
+                       " WHERE Game.session=".DB_quote_smart($session).
+                       " AND Hand.user_id=".DB_quote_smart($user));
+  while($t = mysql_fetch_array($result,MYSQL_NUM))
+    $r[] = $t[0];
+
+  return $r;
+}
+
 function DB_get_ruleset($dullen,$schweinchen)
 {
   $r = array();
@@ -704,5 +736,32 @@ function DB_set_party_by_hash($hash,$party)
   return;
 }
 
+function DB_get_PREF($myid)
+{
+  global $PREF;
+
+    $result = mysql_query("SELECT value from User_Prefs".
+                         " WHERE user_id='$myid' AND pref_key='cardset'" );
+    $r = mysql_fetch_array($result,MYSQL_NUM);
+    if($r)
+      {
+       if($r[0]=="germancards" && (time()-strtotime( "2009-12-31 23:59:59")<0) ) /* licence only valid until then */
+         $PREF["cardset"]="altenburg";
+      else
+       $PREF["cardset"]="english";
+      }
+    else
+      $PREF["cardset"]="english";
+
+    $result = mysql_query("SELECT value from User_Prefs".
+                         " WHERE user_id='$myid' AND pref_key='ccemail'" );
+    $r = mysql_fetch_array($result,MYSQL_NUM);
+    if($r)
+      $PREF["ccemail"]=$r[0];
+    else
+      $PREF["ccemail"]="no";
+
+    return;
+}
 
 ?>
\ No newline at end of file