summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/cancelgame.php3
-rw-r--r--include/db.php492
-rw-r--r--include/functions.php56
-rw-r--r--include/game.php245
-rw-r--r--include/newgame.php46
-rw-r--r--include/register.php8
-rw-r--r--include/reminder.php3
-rw-r--r--include/stats.php195
-rw-r--r--include/user.php42
-rw-r--r--include/welcome.php12
10 files changed, 533 insertions, 569 deletions
diff --git a/include/cancelgame.php b/include/cancelgame.php
index fba950e..5b85534 100644
--- a/include/cancelgame.php
+++ b/include/cancelgame.php
@@ -35,8 +35,7 @@ $gameid = DB_get_gameid_by_hash($me);
$myname = DB_get_name('hash',$me);
/* check if game really is old enough to be canceled */
-$result = mysql_query("SELECT mod_date from Game WHERE id='$gameid' " );
-$r = mysql_fetch_array($result,MYSQL_NUM);
+$r = DB_query_array("SELECT mod_date from Game WHERE id='$gameid' " );
if(time()-strtotime($r[0]) > 60*60*24*30) /* = 1 month */
{
$message = "Hello, \n\n".
diff --git a/include/db.php b/include/db.php
index b13c0f0..2d04357 100644
--- a/include/db.php
+++ b/include/db.php
@@ -45,8 +45,8 @@ function DB_quote_smart($value)
function DB_test()
{
- $result = mysql_query("SELECT * FROM User");
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT * FROM User");
+ while($r = DB_fetch_array($result))
{
foreach($r as $thing)
echo " $thing ";
@@ -55,10 +55,39 @@ function DB_test()
return;
}
+/* use Mysql in the background */
+function DB_query($query)
+{
+ return mysql_query($query);
+}
+
+function DB_fetch_array($result)
+{
+ return mysql_fetch_array($result,MYSQL_NUM);
+}
+
+function DB_insert_id()
+{
+ return mysql_insert_id();
+}
+
+function DB_num_rows($result)
+{
+ return mysql_num_rows($result);
+}
+/* end Mysql functions */
+
+function DB_query_array($query)
+{
+ $result = DB_query($query);
+ $return = DB_fetch_array($result);
+
+ return $return;
+}
+
function DB_get_passwd_by_name($name)
{
- $result = mysql_query("SELECT password FROM User WHERE fullname=".DB_quote_smart($name)."");
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT password FROM User WHERE fullname=".DB_quote_smart($name)."");
if($r)
return $r[0];
@@ -68,13 +97,11 @@ function DB_get_passwd_by_name($name)
function DB_check_recovery_passwords($password,$email)
{
- $result = mysql_query("SELECT User.id FROM User".
- " LEFT JOIN Recovery ON User.id=Recovery.user_id".
- " WHERE email=".DB_quote_smart($email).
- " AND Recovery.password=".DB_quote_smart($password).
- " AND DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= Recovery.create_date");
- $r = mysql_fetch_array($result,MYSQL_NUM);
-
+ $r = DB_query_array("SELECT User.id FROM User".
+ " LEFT JOIN Recovery ON User.id=Recovery.user_id".
+ " WHERE email=".DB_quote_smart($email).
+ " AND Recovery.password=".DB_quote_smart($password).
+ " AND DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= Recovery.create_date");
if($r)
return 1;
else
@@ -86,22 +113,20 @@ function DB_get_handid($type,$var1='',$var2='')
switch($type)
{
case 'hash':
- $result = mysql_query("SELECT id FROM Hand WHERE hash=".DB_quote_smart($var1));
+ $r = DB_query_array("SELECT id FROM Hand WHERE hash=".DB_quote_smart($var1));
break;
case 'gameid-position':
- $result = mysql_query("SELECT id FROM Hand WHERE game_id=".
- DB_quote_smart($var1)." AND position=".
- DB_quote_smart($var2));
+ $r = DB_query_array("SELECT id FROM Hand WHERE game_id=".
+ DB_quote_smart($var1)." AND position=".
+ DB_quote_smart($var2));
break;
case 'gameid-userid':
- $result = mysql_query("SELECT id FROM Hand WHERE game_id=".
- DB_quote_smart($var1)." AND user_id=".
- DB_quote_smart($var2));
+ $r = DB_query_array("SELECT id FROM Hand WHERE game_id=".
+ DB_quote_smart($var1)." AND user_id=".
+ DB_quote_smart($var2));
break;
}
- $r = mysql_fetch_array($result,MYSQL_NUM);
-
if($r)
return $r[0];
else
@@ -110,8 +135,7 @@ function DB_get_handid($type,$var1='',$var2='')
function DB_get_pos_by_hash($hash)
{
- $result = mysql_query("SELECT position FROM Hand WHERE hash=".DB_quote_smart($hash));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r= DB_query_array("SELECT position FROM Hand WHERE hash=".DB_quote_smart($hash));
if($r)
return $r[0];
@@ -121,8 +145,7 @@ function DB_get_pos_by_hash($hash)
function DB_get_status_by_hash($hash)
{
- $result = mysql_query("SELECT status FROM Hand WHERE hash=".DB_quote_smart($hash));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r= DB_query_array("SELECT status FROM Hand WHERE hash=".DB_quote_smart($hash));
if($r)
return $r[0];
@@ -132,19 +155,18 @@ function DB_get_status_by_hash($hash)
function DB_set_game_status_by_gameid($id,$status)
{
- mysql_query("UPDATE Game SET status='".$status."' WHERE id=".DB_quote_smart($id));
+ DB_query("UPDATE Game SET status='".$status."' WHERE id=".DB_quote_smart($id));
return;
}
function DB_set_sickness_by_gameid($id,$status)
{
- mysql_query("UPDATE Game SET sickness='".$status."' WHERE id=".DB_quote_smart($id));
+ DB_query("UPDATE Game SET sickness='".$status."' WHERE id=".DB_quote_smart($id));
return;
}
function DB_get_sickness_by_gameid($id)
{
- $result = mysql_query("SELECT sickness FROM Game WHERE id=".DB_quote_smart($id));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT sickness FROM Game WHERE id=".DB_quote_smart($id));
if($r)
return $r[0];
@@ -154,8 +176,7 @@ function DB_get_sickness_by_gameid($id)
function DB_get_game_status_by_gameid($id)
{
- $result = mysql_query("SELECT status FROM Game WHERE id=".DB_quote_smart($id));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT status FROM Game WHERE id=".DB_quote_smart($id));
if($r)
return $r[0];
@@ -165,16 +186,14 @@ function DB_get_game_status_by_gameid($id)
function DB_set_hand_status_by_hash($hash,$status)
{
- mysql_query("UPDATE Hand SET status='".$status."' WHERE hash=".DB_quote_smart($hash));
+ DB_query("UPDATE Hand SET status='".$status."' WHERE hash=".DB_quote_smart($hash));
return;
}
function DB_get_hand_status_by_userid_and_gameid($uid,$gid)
{
- $result = mysql_query("SELECT status FROM Hand WHERE user_id=".DB_quote_smart($uid).
- " AND game_id=".DB_quote_smart($gid));
- $r = mysql_fetch_array($result,MYSQL_NUM);
-
+ $r = DB_query_array("SELECT status FROM Hand WHERE user_id=".DB_quote_smart($uid).
+ " AND game_id=".DB_quote_smart($gid));
if($r)
return $r[0];
else
@@ -183,10 +202,8 @@ function DB_get_hand_status_by_userid_and_gameid($uid,$gid)
function DB_get_sickness_by_userid_and_gameid($uid,$gid)
{
- $result = mysql_query("SELECT sickness FROM Hand WHERE user_id=".DB_quote_smart($uid).
- " AND game_id=".DB_quote_smart($gid));
- $r = mysql_fetch_array($result,MYSQL_NUM);
-
+ $r = DB_query_array("SELECT sickness FROM Hand WHERE user_id=".DB_quote_smart($uid).
+ " AND game_id=".DB_quote_smart($gid));
if($r)
return $r[0];
else
@@ -195,10 +212,8 @@ function DB_get_sickness_by_userid_and_gameid($uid,$gid)
function DB_get_sickness_by_pos_and_gameid($pos,$gid)
{
- $result = mysql_query("SELECT sickness FROM Hand WHERE position=".DB_quote_smart($pos).
- " AND game_id=".DB_quote_smart($gid));
- $r = mysql_fetch_array($result,MYSQL_NUM);
-
+ $r = DB_query_array("SELECT sickness FROM Hand WHERE position=".DB_quote_smart($pos).
+ " AND game_id=".DB_quote_smart($gid));
if($r)
return $r[0];
else
@@ -207,8 +222,7 @@ function DB_get_sickness_by_pos_and_gameid($pos,$gid)
function DB_get_gameid_by_hash($hash)
{
- $result = mysql_query("SELECT game_id FROM Hand WHERE hash=".DB_quote_smart($hash));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT game_id FROM Hand WHERE hash=".DB_quote_smart($hash));
if($r)
return $r[0];
@@ -224,24 +238,22 @@ function DB_cancel_game($hash)
return;
/* get the IDs of all players */
- $result = mysql_query("SELECT id FROM Hand WHERE game_id=".DB_quote_smart($gameid));
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT id FROM Hand WHERE game_id=".DB_quote_smart($gameid));
+ while($r = DB_fetch_array($result))
{
$id = $r[0];
- $tmp = mysql_query("SELECT id FROM Hand_Card WHERE hand_id=".DB_quote_smart($id));
- $tmp = mysql_fetch_array($tmp,MYSQL_NUM);
- mysql_query("DELETE FROM Play WHERE hand_card_id=".DB_quote_smart($tmp[0]));
-
+ $tmp = DB_query_array("SELECT id FROM Hand_Card WHERE hand_id=".DB_quote_smart($id));
+ DB_query("DELETE FROM Play WHERE hand_card_id=".DB_quote_smart($tmp[0]));
- mysql_query("DELETE FROM Hand_Card WHERE hand_id=".DB_quote_smart($id));
- mysql_query("DELETE FROM Hand WHERE id=".DB_quote_smart($id));
+ DB_query("DELETE FROM Hand_Card WHERE hand_id=".DB_quote_smart($id));
+ DB_query("DELETE FROM Hand WHERE id=".DB_quote_smart($id));
}
/* delete game */
- mysql_query("DELETE FROM User_Game_Prefs WHERE game_id=".DB_quote_smart($gameid));
- mysql_query("DELETE FROM Trick WHERE game_id=".DB_quote_smart($gameid));
- mysql_query("DELETE FROM Game WHERE id=".DB_quote_smart($gameid));
+ DB_query("DELETE FROM User_Game_Prefs WHERE game_id=".DB_quote_smart($gameid));
+ DB_query("DELETE FROM Trick WHERE game_id=".DB_quote_smart($gameid));
+ DB_query("DELETE FROM Game WHERE id=".DB_quote_smart($gameid));
return;
}
@@ -252,8 +264,8 @@ function DB_get_hand($me)
$handid = DB_get_handid('hash',$me);
- $result = mysql_query("SELECT card_id FROM Hand_Card WHERE hand_id=".DB_quote_smart($handid)." and played='false' ");
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT card_id FROM Hand_Card WHERE hand_id=".DB_quote_smart($handid)." and played='false' ");
+ while($r = DB_fetch_array($result))
$cards[]=$r[0];
return $cards;
@@ -265,8 +277,8 @@ function DB_get_all_hand($me)
$handid = DB_get_handid('hash',$me);
- $result = mysql_query("SELECT card_id FROM Hand_Card WHERE hand_id=".DB_quote_smart($handid));
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT card_id FROM Hand_Card WHERE hand_id=".DB_quote_smart($handid));
+ while($r = DB_fetch_array($result))
$cards[]=$r[0];
return $cards;
@@ -277,11 +289,11 @@ function DB_get_cards_by_trick($id)
$cards = array();
$i = 1;
- $result = mysql_query("SELECT card_id,position FROM Play LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id ".
- "LEFT JOIN Hand ON Hand.id=Hand_Card.hand_id ".
- "WHERE trick_id=".
- DB_quote_smart($id)." ORDER BY sequence ASC");
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT card_id,position FROM Play LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id ".
+ "LEFT JOIN Hand ON Hand.id=Hand_Card.hand_id ".
+ "WHERE trick_id=".
+ DB_quote_smart($id)." ORDER BY sequence ASC");
+ while($r = DB_fetch_array($result))
{
$cards[$i]=array("card"=>$r[0],"pos"=>$r[1]);
$i++;
@@ -293,19 +305,19 @@ function DB_get_cards_by_trick($id)
function DB_set_solo_by_hash($hash,$solo)
{
- mysql_query("UPDATE Hand SET solo=".DB_quote_smart($solo)." WHERE hash=".DB_quote_smart($hash));
+ DB_query("UPDATE Hand SET solo=".DB_quote_smart($solo)." WHERE hash=".DB_quote_smart($hash));
return;
}
function DB_set_solo_by_gameid($id,$solo)
{
- mysql_query("UPDATE Game SET solo=".DB_quote_smart($solo)." WHERE id=".DB_quote_smart($id));
+ DB_query("UPDATE Game SET solo=".DB_quote_smart($solo)." WHERE id=".DB_quote_smart($id));
return;
}
function DB_set_sickness_by_hash($hash,$sickness)
{
- mysql_query("UPDATE Hand SET sickness=".DB_quote_smart($sickness)." WHERE hash=".DB_quote_smart($hash));
+ DB_query("UPDATE Hand SET sickness=".DB_quote_smart($sickness)." WHERE hash=".DB_quote_smart($hash));
return;
}
@@ -315,11 +327,11 @@ function DB_get_current_trickid($gameid)
$sequence = NULL;
$number = 0;
- $result = mysql_query("SELECT Trick.id,MAX(Play.sequence) FROM Play ".
- "LEFT JOIN Trick ON Play.trick_id=Trick.id ".
- "WHERE Trick.game_id=".DB_quote_smart($gameid)." ".
- "GROUP BY Trick.id");
- while( $r = mysql_fetch_array($result,MYSQL_NUM) )
+ $result = DB_query("SELECT Trick.id,MAX(Play.sequence) FROM Play ".
+ "LEFT JOIN Trick ON Play.trick_id=Trick.id ".
+ "WHERE Trick.game_id=".DB_quote_smart($gameid)." ".
+ "GROUP BY Trick.id");
+ while( $r = DB_fetch_array($result) )
{
$trickid = $r[0];
$sequence = $r[1];
@@ -328,8 +340,8 @@ function DB_get_current_trickid($gameid)
if(!$sequence || $sequence==4)
{
- mysql_query("INSERT INTO Trick VALUES (NULL,NULL,NULL, ".DB_quote_smart($gameid).",NULL)");
- $trickid = mysql_insert_id();
+ DB_query("INSERT INTO Trick VALUES (NULL,NULL,NULL, ".DB_quote_smart($gameid).",NULL)");
+ $trickid = DB_insert_id();
$sequence = 1;
$number++;
}
@@ -343,18 +355,17 @@ function DB_get_current_trickid($gameid)
function DB_get_max_trickid($gameid)
{
- $result = mysql_query("SELECT MAX(id) FROM Trick WHERE game_id=".DB_quote_smart($gameid));
- $r = mysql_fetch_array($result,MYSQL_NUM) ;
+ $r = DB_query_array("SELECT MAX(id) FROM Trick WHERE game_id=".DB_quote_smart($gameid));
return ($r?$r[0]:NULL);
}
function DB_play_card($trickid,$handcardid,$sequence)
{
- mysql_query("INSERT INTO Play VALUES(NULL,NULL,NULL,".DB_quote_smart($trickid).
- ",".DB_quote_smart($handcardid).",".DB_quote_smart($sequence).")");
+ DB_query("INSERT INTO Play VALUES(NULL,NULL,NULL,".DB_quote_smart($trickid).
+ ",".DB_quote_smart($handcardid).",".DB_quote_smart($sequence).")");
- $playid = mysql_insert_id();
+ $playid = DB_insert_id();
return $playid;
}
@@ -362,9 +373,9 @@ function DB_get_all_names_by_gameid($id)
{
$names = array();
- $result = mysql_query("SELECT fullname FROM Hand LEFT JOIN User ON Hand.user_id=User.id WHERE game_id=".
- DB_quote_smart($id)." ORDER BY position ASC");
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT fullname FROM Hand LEFT JOIN User ON Hand.user_id=User.id WHERE game_id=".
+ DB_quote_smart($id)." ORDER BY position ASC");
+ while($r = DB_fetch_array($result))
$names[] = $r[0];
return $names;
@@ -374,9 +385,9 @@ function DB_get_all_userid_by_gameid($id)
{
$names = array();
- $result = mysql_query("SELECT user_id FROM Hand WHERE game_id=".
- DB_quote_smart($id)." ORDER BY position ");
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT user_id FROM Hand WHERE game_id=".
+ DB_quote_smart($id)." ORDER BY position ");
+ while($r = DB_fetch_array($result))
$names[] = $r[0];
return $names;
@@ -384,8 +395,7 @@ function DB_get_all_userid_by_gameid($id)
function DB_get_hash_from_game_and_pos($id,$pos)
{
- $result = mysql_query("SELECT hash FROM Hand WHERE game_id=".DB_quote_smart($id)." and position=".DB_quote_smart($pos));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT hash FROM Hand WHERE game_id=".DB_quote_smart($id)." and position=".DB_quote_smart($pos));
if($r)
return $r[0];
@@ -395,8 +405,7 @@ function DB_get_hash_from_game_and_pos($id,$pos)
function DB_get_hash_from_gameid_and_userid($id,$user)
{
- $result = mysql_query("SELECT hash FROM Hand WHERE game_id=".DB_quote_smart($id)." and user_id=".DB_quote_smart($user));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT hash FROM Hand WHERE game_id=".DB_quote_smart($id)." and user_id=".DB_quote_smart($user));
if($r)
return $r[0];
@@ -408,8 +417,8 @@ function DB_get_all_names()
{
$names = array();
- $result = mysql_query("SELECT fullname FROM User");
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT fullname FROM User");
+ while($r = DB_fetch_array($result))
$names[] = $r[0];
return $names;
@@ -419,8 +428,8 @@ function DB_get_names_of_last_logins($N)
{
$names = array();
- $result = mysql_query("SELECT fullname FROM User ORDER BY last_login DESC LIMIT $N");
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT fullname FROM User ORDER BY last_login DESC LIMIT $N");
+ while($r = DB_fetch_array($result))
$names[] = $r[0];
return $names;
@@ -430,8 +439,8 @@ function DB_get_names_of_new_logins($N)
{
$names = array();
- $result = mysql_query("SELECT fullname FROM User ORDER BY create_date DESC, id DESC LIMIT $N");
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT fullname FROM User ORDER BY create_date DESC, id DESC LIMIT $N");
+ while($r = DB_fetch_array($result))
$names[] = $r[0];
return $names;
@@ -439,21 +448,20 @@ function DB_get_names_of_new_logins($N)
function DB_update_game_timestamp($gameid)
{
- mysql_query("UPDATE Game SET mod_date = CURRENT_TIMESTAMP WHERE id=".DB_quote_smart($gameid));
+ DB_query("UPDATE Game SET mod_date = CURRENT_TIMESTAMP WHERE id=".DB_quote_smart($gameid));
return;
}
function DB_update_user_timestamp($userid)
{
- mysql_query("UPDATE User SET last_login = CURRENT_TIMESTAMP WHERE id=".DB_quote_smart($userid));
+ DB_query("UPDATE User SET last_login = CURRENT_TIMESTAMP WHERE id=".DB_quote_smart($userid));
return;
}
function DB_get_user_timestamp($userid)
{
- $result = mysql_query("SELECT last_login FROM User WHERE id=".DB_quote_smart($userid));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT last_login FROM User WHERE id=".DB_quote_smart($userid));
if($r)
return $r[0];
@@ -462,8 +470,7 @@ function DB_get_user_timestamp($userid)
}
function DB_get_user_timezone($userid)
{
- $result = mysql_query("SELECT timezone FROM User WHERE id=".DB_quote_smart($userid));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT timezone FROM User WHERE id=".DB_quote_smart($userid));
if($r)
return $r[0];
@@ -473,14 +480,14 @@ function DB_get_user_timezone($userid)
function DB_insert_comment($comment,$playid,$userid)
{
- mysql_query("INSERT INTO Comment VALUES (NULL,NULL,NULL,$userid,$playid, ".DB_quote_smart($comment).")");
+ DB_query("INSERT INTO Comment VALUES (NULL,NULL,NULL,$userid,$playid, ".DB_quote_smart($comment).")");
return;
}
function DB_insert_note($comment,$gameid,$userid)
{
- mysql_query("INSERT INTO Notes VALUES (NULL,NULL,NULL,$userid,$gameid, ".DB_quote_smart($comment).")");
+ DB_query("INSERT INTO Notes VALUES (NULL,NULL,NULL,$userid,$gameid, ".DB_quote_smart($comment).")");
return;
}
@@ -489,10 +496,10 @@ function DB_get_notes_by_userid_and_gameid($userid,$gameid)
{
$notes = array();
- $result = mysql_query("SELECT comment FROM Notes WHERE user_id=".DB_quote_smart($userid) .
- " AND game_id=".DB_quote_smart($gameid));
+ $result = DB_query("SELECT comment FROM Notes WHERE user_id=".DB_quote_smart($userid) .
+ " AND game_id=".DB_quote_smart($gameid));
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ while($r = DB_fetch_array($result))
$notes[] = $r[0];
return $notes;
@@ -501,8 +508,7 @@ function DB_get_notes_by_userid_and_gameid($userid,$gameid)
function DB_get_gametype_by_gameid($id)
{
- $result = mysql_query("SELECT type FROM Game WHERE id=".DB_quote_smart($id));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT type FROM Game WHERE id=".DB_quote_smart($id));
if($r)
return $r[0]."";
@@ -512,14 +518,13 @@ function DB_get_gametype_by_gameid($id)
function DB_set_gametype_by_gameid($id,$p)
{
- mysql_query("UPDATE Game SET type='".$p."' WHERE id=".DB_quote_smart($id));
+ DB_query("UPDATE Game SET type='".$p."' WHERE id=".DB_quote_smart($id));
return;
}
function DB_get_solo_by_gameid($id)
{
- $result = mysql_query("SELECT solo FROM Game WHERE id=".DB_quote_smart($id));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT solo FROM Game WHERE id=".DB_quote_smart($id));
if($r)
return $r[0]."";
@@ -530,8 +535,7 @@ function DB_get_solo_by_gameid($id)
function DB_get_startplayer_by_gameid($id)
{
- $result = mysql_query("SELECT startplayer FROM Game WHERE id=".DB_quote_smart($id));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT startplayer FROM Game WHERE id=".DB_quote_smart($id));
if($r)
return $r[0];
@@ -541,14 +545,13 @@ function DB_get_startplayer_by_gameid($id)
function DB_set_startplayer_by_gameid($id,$p)
{
- mysql_query("UPDATE Game SET startplayer='".$p."' WHERE id=".DB_quote_smart($id));
+ DB_query("UPDATE Game SET startplayer='".$p."' WHERE id=".DB_quote_smart($id));
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);
+ $r = DB_query_array("SELECT player FROM Game WHERE id=".DB_quote_smart($id));
if($r)
return $r[0];
@@ -557,7 +560,7 @@ function DB_get_player_by_gameid($id)
}
function DB_set_player_by_gameid($id,$p)
{
- mysql_query("UPDATE Game SET player='".DB_quote_smart($p)."' WHERE id=".DB_quote_smart($id));
+ DB_query("UPDATE Game SET player='".DB_quote_smart($p)."' WHERE id=".DB_quote_smart($id));
return;
}
@@ -565,8 +568,7 @@ function DB_set_player_by_gameid($id,$p)
function DB_get_ruleset_by_gameid($id)
{
- $result = mysql_query("SELECT ruleset FROM Game WHERE id=".DB_quote_smart($id));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT ruleset FROM Game WHERE id=".DB_quote_smart($id));
if($r)
return $r[0];
@@ -576,8 +578,7 @@ function DB_get_ruleset_by_gameid($id)
function DB_get_session_by_gameid($id)
{
- $result = mysql_query("SELECT session FROM Game WHERE id=".DB_quote_smart($id));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT session FROM Game WHERE id=".DB_quote_smart($id));
if($r)
return $r[0];
@@ -587,8 +588,7 @@ function DB_get_session_by_gameid($id)
function DB_get_max_session()
{
- $result = mysql_query("SELECT MAX(session) FROM Game");
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT MAX(session) FROM Game");
if($r)
return $r[0];
@@ -600,12 +600,12 @@ 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).
- " ORDER BY Game.create_date ASC");
- while($t = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_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).
+ " ORDER BY Game.create_date ASC");
+ while($t = DB_fetch_array($result))
$r[] = $t[0];
return $r;
@@ -615,25 +615,25 @@ function DB_get_ruleset($dullen,$schweinchen,$call)
{
$r = array();
- $result = mysql_query("SELECT id FROM Rulesets WHERE".
- " dullen=".DB_quote_smart($dullen)." AND ".
- " call=".DB_quote_smart($call)." AND ".
- " schweinchen=".DB_quote_smart($schweinchen));
+ $result = DB_query("SELECT id FROM Rulesets WHERE".
+ " dullen=".DB_quote_smart($dullen)." AND ".
+ " call=".DB_quote_smart($call)." AND ".
+ " schweinchen=".DB_quote_smart($schweinchen));
if($result)
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_fetch_array($result);
if($r)
return $r[0]; /* found ruleset */
else
{
/* create new one */
- $result = mysql_query("INSERT INTO Rulesets VALUES (NULL, NULL, ".
- DB_quote_smart($dullen).",".
- DB_quote_smart($schweinchen).",".
- DB_quote_smart($call).
- ", NULL)");
+ $result = DB_query("INSERT INTO Rulesets VALUES (NULL, NULL, ".
+ DB_quote_smart($dullen).",".
+ DB_quote_smart($schweinchen).",".
+ DB_quote_smart($call).
+ ", NULL)");
if($result)
- return mysql_insert_id();
+ return DB_insert_id();
};
return -1; /* something went wrong */
@@ -641,8 +641,7 @@ function DB_get_ruleset($dullen,$schweinchen,$call)
function DB_get_party_by_hash($hash)
{
- $result = mysql_query("SELECT party FROM Hand WHERE hash=".DB_quote_smart($hash));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT party FROM Hand WHERE hash=".DB_quote_smart($hash));
if($r)
return $r[0];
@@ -652,11 +651,9 @@ function DB_get_party_by_hash($hash)
function DB_get_party_by_gameid_and_userid($gameid,$userid)
{
- $result = mysql_query("SELECT party FROM Hand".
- " WHERE game_id=".DB_quote_smart($gameid).
- " AND user_id=".DB_quote_smart($userid));
- $r = mysql_fetch_array($result,MYSQL_NUM);
-
+ $r = DB_query_array("SELECT party FROM Hand".
+ " WHERE game_id=".DB_quote_smart($gameid).
+ " AND user_id=".DB_quote_smart($userid));
if($r)
return $r[0];
else
@@ -665,7 +662,7 @@ function DB_get_party_by_gameid_and_userid($gameid,$userid)
function DB_set_party_by_hash($hash,$party)
{
- mysql_query("UPDATE Hand SET party=".DB_quote_smart($party)." WHERE hash=".DB_quote_smart($hash));
+ DB_query("UPDATE Hand SET party=".DB_quote_smart($party)." WHERE hash=".DB_quote_smart($hash));
return;
}
@@ -674,9 +671,8 @@ function DB_get_PREF($myid)
global $PREF;
/* Cardset */
- $result = mysql_query("SELECT value from User_Prefs".
- " WHERE user_id='$myid' AND pref_key='cardset'" );
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT value from User_Prefs".
+ " WHERE user_id='$myid' AND pref_key='cardset'" );
if($r)
{
if($r[0]=="germancards" && (time()-strtotime( "2009-12-31 23:59:59")<0) ) /* licence only valid until then */
@@ -688,9 +684,8 @@ function DB_get_PREF($myid)
$PREF["cardset"]="english";
/* Email */
- $result = mysql_query("SELECT value FROM User_Prefs".
- " WHERE user_id='$myid' AND pref_key='email'" );
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT value FROM User_Prefs".
+ " WHERE user_id='$myid' AND pref_key='email'" );
if($r)
{
if($r[0]=="emailaddict")
@@ -706,10 +701,9 @@ function DB_get_PREF($myid)
function DB_get_email_pref_by_hash($hash)
{
- $result = mysql_query("SELECT value FROM Hand".
- " LEFT JOIN User_Prefs ON Hand.user_id=User_Prefs.user_id".
- " WHERE hash='$hash' AND pref_key='email'" );
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = EB_query_array("SELECT value FROM Hand".
+ " LEFT JOIN User_Prefs ON Hand.user_id=User_Prefs.user_id".
+ " WHERE hash='$hash' AND pref_key='email'" );
if($r)
{
if($r[0]=="emailaddict")
@@ -723,9 +717,8 @@ function DB_get_email_pref_by_hash($hash)
function DB_get_email_pref_by_uid($uid)
{
- $result = mysql_query("SELECT value FROM User_Prefs ".
- " WHERE user_id='$uid' AND pref_key='email'" );
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT value FROM User_Prefs ".
+ " WHERE user_id='$uid' AND pref_key='email'" );
if($r)
{
if($r[0]=="emailaddict")
@@ -739,16 +732,13 @@ function DB_get_email_pref_by_uid($uid)
function DB_get_unused_randomnumbers($userstr)
{
- $queryresult = mysql_query(" SELECT randomnumbers FROM Game".
- " WHERE randomnumbers NOT IN".
- " (SELECT randomnumbers FROM Game".
- " LEFT JOIN Hand ON Game.id=Hand.game_id".
- " WHERE user_id IN (". $userstr .")".
- " GROUP BY randomnumbers".
- " )");
-
-
- $r = mysql_fetch_array($queryresult,MYSQL_NUM);
+ $r = DB_query_array(" SELECT randomnumbers FROM Game".
+ " WHERE randomnumbers NOT IN".
+ " (SELECT randomnumbers FROM Game".
+ " LEFT JOIN Hand ON Game.id=Hand.game_id".
+ " WHERE user_id IN (". $userstr .")".
+ " GROUP BY randomnumbers".
+ " )");
if($r)
return $r[0];
else
@@ -757,12 +747,10 @@ function DB_get_unused_randomnumbers($userstr)
function DB_get_number_of_passwords_recovery($user)
{
- $queryresult = mysql_query("SELECT COUNT(*) FROM Recovery ".
- " WHERE user_id=$user ".
- " AND DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= create_date".
- " GROUP BY user_id " );
-
- $r = mysql_fetch_array($queryresult,MYSQL_NUM);
+ $r = DB_query_array("SELECT COUNT(*) FROM Recovery ".
+ " WHERE user_id=$user ".
+ " AND DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= create_date".
+ " GROUP BY user_id " );
if($r)
return $r[0];
else
@@ -771,17 +759,15 @@ function DB_get_number_of_passwords_recovery($user)
function DB_set_recovery_password($user,$newpw)
{
- mysql_query("INSERT INTO Recovery VALUES(NULL,".DB_quote_smart($user).
- ",".DB_quote_smart($newpw).",NULL)");
-
+ DB_query("INSERT INTO Recovery VALUES(NULL,".DB_quote_smart($user).
+ ",".DB_quote_smart($newpw).",NULL)");
return;
}
function DB_get_card_name($card)
{
- $queryresult = mysql_query("SELECT strength,suite FROM Card WHERE id='$card'");
+ $r = DB_query_array("SELECT strength,suite FROM Card WHERE id='$card'");
- $r = mysql_fetch_array($queryresult,MYSQL_NUM);
if($r)
return $r[0]." of ".$r[1];
else
@@ -794,9 +780,8 @@ function DB_get_current_playid($gameid)
if(!$trick) return NULL;
- $queryresult = mysql_query("SELECT id FROM Play WHERE trick_id='$trick' ORDER BY create_date DESC LIMIT 1");
+ $r = DB_query_array("SELECT id FROM Play WHERE trick_id='$trick' ORDER BY create_date DESC LIMIT 1");
- $r = mysql_fetch_array($queryresult,MYSQL_NUM);
if($r)
return $r[0];
@@ -805,9 +790,8 @@ function DB_get_current_playid($gameid)
function DB_get_call_by_hash($hash)
{
- $queryresult = mysql_query("SELECT point_call FROM Hand WHERE hash='$hash'");
+ $r = DB_query_array("SELECT point_call FROM Hand WHERE hash='$hash'");
- $r = mysql_fetch_array($queryresult,MYSQL_NUM);
if($r)
return $r[0];
@@ -820,9 +804,8 @@ function DB_get_partner_call_by_hash($hash)
if($partner)
{
- $queryresult = mysql_query("SELECT point_call FROM Hand WHERE hash='$partner'");
+ $r = DB_query_array("SELECT point_call FROM Hand WHERE hash='$partner'");
- $r = mysql_fetch_array($queryresult,MYSQL_NUM);
if($r)
return $r[0];
}
@@ -835,9 +818,8 @@ function DB_get_partner_hash_by_hash($hash)
$gameid = DB_get_gameid_by_hash($hash);
$party = DB_get_party_by_hash($hash);
- $queryresult = mysql_query("SELECT hash FROM Hand WHERE game_id='$gameid' AND party='$party' AND hash<>'$hash'");
+ $r = DB_query_array("SELECT hash FROM Hand WHERE game_id='$gameid' AND party='$party' AND hash<>'$hash'");
- $r = mysql_fetch_array($queryresult,MYSQL_NUM);
if($r)
return $r[0];
@@ -849,24 +831,20 @@ function DB_format_gameid($gameid)
$session = DB_get_session_by_gameid($gameid);
/* get number of game */
- $result = mysql_query("SELECT COUNT(*),create_date FROM Game".
- " WHERE session='$session' ".
- " AND TIMEDIFF(create_date, (SELECT create_date FROM Game WHERE id='$gameid'))<=0 ".
- " GROUP by session");
- $r = mysql_fetch_array($result,MYSQL_NUM);
-
+ $r = DB_query_array("SELECT COUNT(*),create_date FROM Game".
+ " WHERE session='$session' ".
+ " AND TIMEDIFF(create_date, (SELECT create_date FROM Game WHERE id='$gameid'))<=0 ".
+ " GROUP by session");
return $session.".".$r[0];
}
function DB_get_reminder($user,$gameid)
{
- $queryresult = mysql_query("SELECT COUNT(*) FROM Reminder ".
- " WHERE user_id=$user ".
- " AND game_id=$gameid ".
- " AND DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= create_date".
- " GROUP BY user_id " );
-
- $r = mysql_fetch_array($queryresult,MYSQL_NUM);
+ $r = DB_query_array("SELECT COUNT(*) FROM Reminder ".
+ " WHERE user_id=$user ".
+ " AND game_id=$gameid ".
+ " AND DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= create_date".
+ " GROUP BY user_id " );
if($r)
return $r[0];
else
@@ -875,19 +853,17 @@ function DB_get_reminder($user,$gameid)
function DB_set_reminder($user,$gameid)
{
- mysql_query("INSERT INTO Reminder ".
- " VALUES(NULL, ".DB_quote_smart($user).", ".DB_quote_smart($gameid).
- ", NULL) ");
+ DB_query("INSERT INTO Reminder ".
+ " VALUES(NULL, ".DB_quote_smart($user).", ".DB_quote_smart($gameid).
+ ", NULL) ");
return 0;
}
function DB_is_session_active($session)
{
- $queryresult = mysql_query("SELECT COUNT(*) FROM Game ".
- " WHERE session=$session ".
- " AND status<>'gameover' ");
-
- $r = mysql_fetch_array($queryresult,MYSQL_NUM);
+ $r = DB_query_array("SELECT COUNT(*) FROM Game ".
+ " WHERE session=$session ".
+ " AND status<>'gameover' ");
if($r)
return $r[0];
else
@@ -897,14 +873,13 @@ function DB_is_session_active($session)
function DB_get_score_by_gameid($gameid)
{
/* returns the points of a game from the point of the re parth (<0 if they lost) */
- $queryresult = mysql_query("SELECT COUNT(*),party FROM Score ".
- " WHERE game_id=$gameid ".
- " GROUP BY party ");
-
+ $queryresult = DB_query("SELECT COUNT(*),party FROM Score ".
+ " WHERE game_id=$gameid ".
+ " GROUP BY party ");
$re = 0;
$contra = 0;
- while($r = mysql_fetch_array($queryresult,MYSQL_NUM) )
+ while($r = DB_fetch_array($queryresult) )
{
if($r[1] == "re")
$re += $r[0];
@@ -920,17 +895,17 @@ function DB_get_gameids_of_finished_games_by_session($session)
$ids = array ();
if($session==0) /* return all games */
- $queryresult = mysql_query("SELECT id FROM Game ".
- " WHERE status='gameover' ".
- " ORDER BY create_date ASC");
+ $queryresult = DB_query("SELECT id FROM Game ".
+ " WHERE status='gameover' ".
+ " ORDER BY create_date ASC");
else /* return games in a session */
- $queryresult = mysql_query("SELECT id FROM Game ".
- " WHERE session=$session ".
- " AND status='gameover' ".
- " ORDER BY create_date ASC");
+ $queryresult = DB_query("SELECT id FROM Game ".
+ " WHERE session=$session ".
+ " AND status='gameover' ".
+ " ORDER BY create_date ASC");
$i=0;
- while($r = mysql_fetch_array($queryresult,MYSQL_NUM) )
+ while($r = DB_fetch_array($queryresult) )
{
$ids[$i] = $r[0];
$i++;
@@ -941,10 +916,9 @@ function DB_get_gameids_of_finished_games_by_session($session)
function DB_get_card_value_by_cardid($id)
{
- $queryresult = mysql_query("SELECT points FROM Card ".
- " WHERE id=$id ");
+ $r = DB_query_array("SELECT points FROM Card ".
+ " WHERE id=$id ");
- $r = mysql_fetch_array($queryresult,MYSQL_NUM);
if($r)
return $r[0];
else
@@ -964,40 +938,40 @@ function DB_get_userid($type,$var1="",$var2="")
switch($type)
{
case 'name':
- $result = mysql_query("SELECT id FROM User WHERE fullname=".DB_quote_smart($var1));
+ $result = DB_query("SELECT id FROM User WHERE fullname=".DB_quote_smart($var1));
break;
case 'hash':
- $result = mysql_query("SELECT user_id FROM Hand WHERE hash=".DB_quote_smart($var1));
+ $result = DB_query("SELECT user_id FROM Hand WHERE hash=".DB_quote_smart($var1));
break;
case 'password':
- $result = mysql_query("SELECT id FROM User WHERE password=".DB_quote_smart($var1));
+ $result = DB_query("SELECT id FROM User WHERE password=".DB_quote_smart($var1));
break;
case 'email':
- $result = mysql_query("SELECT id FROM User WHERE email=".DB_quote_smart($var1));
+ $result = DB_query("SELECT id FROM User WHERE email=".DB_quote_smart($var1));
break;
case 'email-password':
- $result = mysql_query("SELECT id FROM User WHERE email=".DB_quote_smart($var1)." AND password=".DB_quote_smart($var2));
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $result = DB_query("SELECT id FROM User WHERE email=".DB_quote_smart($var1)." AND password=".DB_quote_smart($var2));
+ $r = DB_fetch_array($result);
/* test if a recovery password has been set */
if(!$r)
{
echo "testing alternative password";
- $result = mysql_query("SELECT User.id FROM User".
- " LEFT JOIN Recovery ON User.id=Recovery.user_id".
- " WHERE email=".DB_quote_smart($var1).
- " AND Recovery.password=".DB_quote_smart($var2).
- " AND DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= Recovery.create_date");
+ $result = DB_query("SELECT User.id FROM User".
+ " LEFT JOIN Recovery ON User.id=Recovery.user_id".
+ " WHERE email=".DB_quote_smart($var1).
+ " AND Recovery.password=".DB_quote_smart($var2).
+ " AND DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= Recovery.create_date");
}
break;
case 'gameid-position':
- $result = mysql_query("SELECT user_id FROM Hand WHERE game_id=".
- DB_quote_smart($var1)." AND position=".
- DB_quote_smart($var2));
+ $result = DB_query("SELECT user_id FROM Hand WHERE game_id=".
+ DB_quote_smart($var1)." AND position=".
+ DB_quote_smart($var2));
break;
}
if(!$r)
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_fetch_array($result);
if($r)
return $r[0];
@@ -1014,26 +988,26 @@ function DB_get_email($type,$var1='',$var2='')
switch($type)
{
case 'name':
- $result = mysql_query("SELECT email FROM User WHERE fullname=".DB_quote_smart($var1)."");
+ $result = DB_query("SELECT email FROM User WHERE fullname=".DB_quote_smart($var1)."");
break;
case 'userid':
- $result = mysql_query("SELECT email FROM User WHERE id=".DB_quote_smart($var1)."");
+ $result = DB_query("SELECT email FROM User WHERE id=".DB_quote_smart($var1)."");
break;
case 'hash':
- $result = mysql_query("SELECT User.email FROM User ".
- "LEFT JOIN Hand ON Hand.user_id=User.id ".
- "WHERE Hand.hash=".DB_quote_smart($var1)."");
+ $result = DB_query("SELECT User.email FROM User ".
+ "LEFT JOIN Hand ON Hand.user_id=User.id ".
+ "WHERE Hand.hash=".DB_quote_smart($var1)."");
break;
case 'position-gameid':
- $result = mysql_query("SELECT email FROM User ".
- "LEFT JOIN Hand ON User.id=Hand.user_id ".
- "LEFT JOIN Game ON Game.id=Hand.game_id ".
- "WHERE Game.id=".DB_quote_smart($var2)." ".
- "AND Hand.position=".DB_quote_smart($var1)."");
+ $result = DB_query("SELECT email FROM User ".
+ "LEFT JOIN Hand ON User.id=Hand.user_id ".
+ "LEFT JOIN Game ON Game.id=Hand.game_id ".
+ "WHERE Game.id=".DB_quote_smart($var2)." ".
+ "AND Hand.position=".DB_quote_smart($var1)."");
break;
}
-
- $r = mysql_fetch_array($result,MYSQL_NUM);
+
+ $r = DB_fetch_array($result);
if($r)
return $r[0];
@@ -1049,17 +1023,15 @@ function DB_get_name($type,$var1='')
switch($type)
{
case 'hash':
- $result = mysql_query("SELECT fullname FROM Hand LEFT JOIN User ON Hand.user_id=User.id WHERE hash=".DB_quote_smart($var1));
+ $r = DB_query_array("SELECT fullname FROM Hand LEFT JOIN User ON Hand.user_id=User.id WHERE hash=".DB_quote_smart($var1));
break;
case 'email':
- $result = mysql_query("SELECT fullname FROM User WHERE email=".DB_quote_smart($var1));
+ $r = DB_query_array("SELECT fullname FROM User WHERE email=".DB_quote_smart($var1));
break;
case 'userid':
- $result = mysql_query("SELECT fullname FROM User WHERE id=".DB_quote_smart($var1));
+ $r = DB_query_array("SELECT fullname FROM User WHERE id=".DB_quote_smart($var1));
}
- $r = mysql_fetch_array($result,MYSQL_NUM);
-
if($r)
return $r[0];
else
diff --git a/include/functions.php b/include/functions.php
index 2e4c083..e60f69f 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -665,23 +665,23 @@ function display_table ()
{
global $gameid, $GT, $debug,$INDEX,$defaulttimezone;
- $result = mysql_query("SELECT User.fullname as name,".
- " Hand.position as position, ".
- " User.id, ".
- " Hand.party as party, ".
- " Hand.sickness as sickness, ".
- " Hand.point_call, ".
- " User.last_login, ".
- " Hand.hash, ".
- " User.timezone ".
- "FROM Hand ".
- "LEFT JOIN User ON User.id=Hand.user_id ".
- "WHERE Hand.game_id='".$gameid."' ".
- "ORDER BY position ASC");
+ $result = DB_query("SELECT User.fullname as name,".
+ " Hand.position as position, ".
+ " User.id, ".
+ " Hand.party as party, ".
+ " Hand.sickness as sickness, ".
+ " Hand.point_call, ".
+ " User.last_login, ".
+ " Hand.hash, ".
+ " User.timezone ".
+ "FROM Hand ".
+ "LEFT JOIN User ON User.id=Hand.user_id ".
+ "WHERE Hand.game_id='".$gameid."' ".
+ "ORDER BY position ASC");
echo "<div class=\"table\">\n".
" <img class=\"table\" src=\"pics/table.png\" alt=\"table\" />\n";
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ while($r = DB_fetch_array($result))
{
$name = $r[0];
$pos = $r[1];
@@ -812,16 +812,16 @@ function display_user_menu()
echo "<div class=\"usermenu\">\n".
"<a href=\"".$INDEX."\"> Go to my user page </a>";
- $result = mysql_query("SELECT Hand.hash,Hand.game_id,Game.player from Hand".
- " LEFT JOIN Game On Hand.game_id=Game.id".
- " WHERE Hand.user_id='$myid'".
- " AND Game.player='$myid'".
- " AND Game.status<>'gameover'".
- " ORDER BY Game.session" );
- if(mysql_num_rows($result))
+ $result = DB_query("SELECT Hand.hash,Hand.game_id,Game.player from Hand".
+ " LEFT JOIN Game On Hand.game_id=Game.id".
+ " WHERE Hand.user_id='$myid'".
+ " AND Game.player='$myid'".
+ " AND Game.status<>'gameover'".
+ " ORDER BY Game.session" );
+ if(DB_num_rows($result))
echo "<hr />It's your turn in these games:<br />\n";
- while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ while( $r = DB_fetch_array($result))
{
echo "<a href=\"".$INDEX."?action=game&me=".$r[0]."\">game ".DB_format_gameid($r[1])." </a><br />\n";
}
@@ -849,10 +849,10 @@ function generate_score_table($session)
/* get player id, names... from the first game */
$player = array();
- $result = mysql_query("SELECT User.id, User.fullname from Hand".
- " LEFT JOIN User On Hand.user_id=User.id".
- " WHERE Hand.game_id=".$gameids[0]);
- while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT User.id, User.fullname from Hand".
+ " LEFT JOIN User On Hand.user_id=User.id".
+ " WHERE Hand.game_id=".$gameids[0]);
+ while( $r = DB_fetch_array($result))
{
$player[] = array( 'id' => $r[0], 'points' => 0 );
$output.= " <td> ".substr($r[1],0,2)." </td>\n";
@@ -901,9 +901,9 @@ function generate_global_score_table()
/* get player id, names... from the User table */
$player = array();
- $result = mysql_query("SELECT User.id, User.fullname FROM User");
+ $result = DB_query("SELECT User.id, User.fullname FROM User");
- while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ while( $r = DB_fetch_array($result))
$player[] = array( 'id' => $r[0], 'name'=> $r[1], 'points' => 0 ,'nr' => 0);
/* get points and generate table */
diff --git a/include/game.php b/include/game.php
index cfb2b55..0d4f0a9 100644
--- a/include/game.php
+++ b/include/game.php
@@ -45,10 +45,9 @@ $session = DB_get_session_by_gameid($gameid);
DB_get_PREF($myid);
/* get rule set for this game */
-$result = mysql_query("SELECT * FROM Rulesets".
- " LEFT JOIN Game ON Game.ruleset=Rulesets.id ".
- " WHERE Game.id='$gameid'" );
-$r = mysql_fetch_array($result,MYSQL_NUM);
+$r = DB_query_array("SELECT * FROM Rulesets".
+ " LEFT JOIN Game ON Game.ruleset=Rulesets.id ".
+ " WHERE Game.id='$gameid'" );
$RULES["dullen"] = $r[2];
$RULES["schweinchen"] = $r[3];
@@ -600,7 +599,7 @@ switch($mystatus)
/* get hand id for user $trump */
$userhand = DB_get_handid('gameid-userid',$gameid,$trump);
/* copy trump from player A to B */
- $result = mysql_query("UPDATE Hand_Card SET hand_id='$myhand' WHERE hand_id='$userhand' AND card_id<'27'" );
+ $result = DB_query("UPDATE Hand_Card SET hand_id='$myhand' WHERE hand_id='$userhand' AND card_id<'27'" );
/* add hidden button with trump in it to get to the next point */
echo "</div><div class=\"poverty\">\n";
@@ -618,13 +617,12 @@ switch($mystatus)
/* if exchange is set to a value>0, exchange that card back to user $trump */
if($exchange >0)
{
- $result = mysql_query("UPDATE Hand_Card SET hand_id='$userhand'".
- " WHERE hand_id='$myhand' AND card_id='$exchange'" );
+ $result = DB_query("UPDATE Hand_Card SET hand_id='$userhand'".
+ " WHERE hand_id='$myhand' AND card_id='$exchange'" );
};
/* if number of cards == 12, set status to play for both users */
- $result = mysql_query("SELECT COUNT(*) FROM Hand_Card WHERE hand_id='$myhand'" );
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT COUNT(*) FROM Hand_Card WHERE hand_id='$myhand'" );
if(!$r)
{
myerror("error in poverty");
@@ -859,8 +857,7 @@ switch($mystatus)
}
/* get time from the last action of the game */
- $result = mysql_query("SELECT mod_date from Game WHERE id='$gameid' " );
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT mod_date from Game WHERE id='$gameid' " );
$gameend = time() - strtotime($r[0]);
/* handel comments in case player didn't play a card, allow comments a week after the end of the game */
@@ -885,23 +882,23 @@ switch($mystatus)
};
/* get everything relevant to display the tricks */
- $result = mysql_query("SELECT Hand_Card.card_id as card,".
- " Hand.position as position,".
- " Play.sequence as sequence, ".
- " Trick.id, ".
- " GROUP_CONCAT(CONCAT('<span>',User.fullname,': ',Comment.comment,'</span>')".
- " SEPARATOR '\n' ), ".
- " Play.create_date, ".
- " Hand.user_id ".
- "FROM Trick ".
- "LEFT JOIN Play ON Trick.id=Play.trick_id ".
- "LEFT JOIN Hand_Card ON Play.hand_card_id=Hand_Card.id ".
- "LEFT JOIN Hand ON Hand_Card.hand_id=Hand.id ".
- "LEFT JOIN Comment ON Play.id=Comment.play_id ".
- "LEFT JOIN User On User.id=Comment.user_id ".
- "WHERE Trick.game_id='".$gameid."' ".
- "GROUP BY Trick.id, sequence ".
- "ORDER BY Trick.id, sequence ASC");
+ $result = DB_query("SELECT Hand_Card.card_id as card,".
+ " Hand.position as position,".
+ " Play.sequence as sequence, ".
+ " Trick.id, ".
+ " GROUP_CONCAT(CONCAT('<span>',User.fullname,': ',Comment.comment,'</span>')".
+ " SEPARATOR '\n' ), ".
+ " Play.create_date, ".
+ " Hand.user_id ".
+ "FROM Trick ".
+ "LEFT JOIN Play ON Trick.id=Play.trick_id ".
+ "LEFT JOIN Hand_Card ON Play.hand_card_id=Hand_Card.id ".
+ "LEFT JOIN Hand ON Hand_Card.hand_id=Hand.id ".
+ "LEFT JOIN Comment ON Play.id=Comment.play_id ".
+ "LEFT JOIN User On User.id=Comment.user_id ".
+ "WHERE Trick.game_id='".$gameid."' ".
+ "GROUP BY Trick.id, sequence ".
+ "ORDER BY Trick.id, sequence ASC");
$trickNR = 1;
$lasttrick = DB_get_max_trickid($gameid);
@@ -938,7 +935,7 @@ switch($mystatus)
}
/* output tricks */
- while($r = mysql_fetch_array($result,MYSQL_NUM))
+ while($r = DB_fetch_array($result))
{
$pos = $r[1];
$seq = $r[2];
@@ -1022,9 +1019,8 @@ switch($mystatus)
/* check if we have card and that we haven't played it yet*/
/* set played in hand_card to true where hand_id and card_id*/
- $result = mysql_query("SELECT id FROM Hand_Card WHERE played='false' and ".
+ $r = DB_query_array("SELECT id FROM Hand_Card WHERE played='false' and ".
"hand_id='$handid' AND card_id=".DB_quote_smart($card));
- $r = mysql_fetch_array($result,MYSQL_NUM);
$handcardid = $r[0];
if($handcardid) /* everything ok, play card */
@@ -1034,19 +1030,19 @@ switch($mystatus)
/* check if a call was made, must do this before we set the card status to played */
if(myisset("call") && $_REQUEST["call"] == "120" && can_call(120,$me))
- $result = mysql_query("UPDATE Hand SET point_call='120' WHERE hash='$me' ");
+ $result = DB_query("UPDATE Hand SET point_call='120' WHERE hash='$me' ");
if(myisset("call") && $_REQUEST["call"] == "90" && can_call(90,$me))
- $result = mysql_query("UPDATE Hand SET point_call='90' WHERE hash='$me' ");
+ $result = DB_query("UPDATE Hand SET point_call='90' WHERE hash='$me' ");
if(myisset("call") && $_REQUEST["call"] == "60" && can_call(60,$me))
- $result = mysql_query("UPDATE Hand SET point_call='60' WHERE hash='$me' ");
+ $result = DB_query("UPDATE Hand SET point_call='60' WHERE hash='$me' ");
if(myisset("call") && $_REQUEST["call"] == "30" && can_call(30,$me))
- $result = mysql_query("UPDATE Hand SET point_call='30' WHERE hash='$me' ");
+ $result = DB_query("UPDATE Hand SET point_call='30' WHERE hash='$me' ");
if(myisset("call") && $_REQUEST["call"] == "0" && can_call(0,$me))
- $result = mysql_query("UPDATE Hand SET point_call='0' WHERE hash='$me' ");
+ $result = DB_query("UPDATE Hand SET point_call='0' WHERE hash='$me' ");
/* mark card as played */
- mysql_query("UPDATE Hand_Card SET played='true' WHERE hand_id='$handid' AND card_id=".
- DB_quote_smart($card));
+ DB_query("UPDATE Hand_Card SET played='true' WHERE hand_id='$handid' AND card_id=".
+ DB_quote_smart($card));
/* get trick id or start new trick */
$a = DB_get_current_trickid($gameid);
@@ -1142,8 +1138,8 @@ switch($mystatus)
$party2 = DB_get_party_by_gameid_and_userid($gameid,$uid2);
if($party1 != $party2)
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'$party1',$uid1,$uid2,'fox')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'$party1',$uid1,$uid2,'fox')");
}
}
@@ -1169,8 +1165,8 @@ switch($mystatus)
$uid1 = DB_get_userid('gameid-position',$gameid,$winner);
$party1 = DB_get_party_by_gameid_and_userid($gameid,$uid1);
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'karlchen')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'karlchen')");
}
/* check for doppelopf (>40 points)*/
$points = 0;
@@ -1183,12 +1179,12 @@ switch($mystatus)
$uid1 = DB_get_userid('gameid-position',$gameid,$winner);
$party1 = DB_get_party_by_gameid_and_userid($gameid,$uid1);
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'doko')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'doko')");
}
if($winner>0)
- mysql_query("UPDATE Trick SET winner='$winner' WHERE id='$trickid'");
+ DB_query("UPDATE Trick SET winner='$winner' WHERE id='$trickid'");
else
echo "ERROR during scoring";
@@ -1275,31 +1271,31 @@ switch($mystatus)
else /* send out final email */
{
/* individual score */
- $result = mysql_query("SELECT User.fullname, IFNULL(SUM(Card.points),0), Hand.party FROM Hand".
- " LEFT JOIN Trick ON Trick.winner=Hand.position AND Trick.game_id=Hand.game_id".
- " LEFT JOIN User ON User.id=Hand.user_id".
- " LEFT JOIN Play ON Trick.id=Play.trick_id".
- " LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id".
- " LEFT JOIN Card ON Card.id=Hand_Card.card_id".
- " WHERE Hand.game_id='$gameid'".
- " GROUP BY User.fullname" );
+ $result = DB_query("SELECT User.fullname, IFNULL(SUM(Card.points),0), Hand.party FROM Hand".
+ " LEFT JOIN Trick ON Trick.winner=Hand.position AND Trick.game_id=Hand.game_id".
+ " LEFT JOIN User ON User.id=Hand.user_id".
+ " LEFT JOIN Play ON Trick.id=Play.trick_id".
+ " LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id".
+ " LEFT JOIN Card ON Card.id=Hand_Card.card_id".
+ " WHERE Hand.game_id='$gameid'".
+ " GROUP BY User.fullname" );
$message = "The game is over. Thanks for playing :)\n";
$message .= "Final score:\n";
- while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ while( $r = DB_fetch_array($result) )
$message .= " ".$r[0]."(".$r[2].") ".$r[1]."\n";
- $result = mysql_query("SELECT Hand.party, IFNULL(SUM(Card.points),0) FROM Hand".
- " LEFT JOIN Trick ON Trick.winner=Hand.position AND Trick.game_id=Hand.game_id".
- " LEFT JOIN User ON User.id=Hand.user_id".
- " LEFT JOIN Play ON Trick.id=Play.trick_id".
- " LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id".
- " LEFT JOIN Card ON Card.id=Hand_Card.card_id".
- " WHERE Hand.game_id='$gameid'".
- " GROUP BY Hand.party" );
+ $result = DB_query("SELECT Hand.party, IFNULL(SUM(Card.points),0) FROM Hand".
+ " LEFT JOIN Trick ON Trick.winner=Hand.position AND Trick.game_id=Hand.game_id".
+ " LEFT JOIN User ON User.id=Hand.user_id".
+ " LEFT JOIN Play ON Trick.id=Play.trick_id".
+ " LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id".
+ " LEFT JOIN Card ON Card.id=Hand_Card.card_id".
+ " WHERE Hand.game_id='$gameid'".
+ " GROUP BY Hand.party" );
$message .= "\nTotals:\n";
$re = 0;
$contra = 0;
- while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ while( $r = DB_fetch_array($result) )
{
$message .= " ".$r[0]." ".$r[1]."\n";
if($r[0] == "re")
@@ -1392,38 +1388,38 @@ switch($mystatus)
{
for( $p=$call_contra;$p<=120; $p+=30 )
{
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'against$p')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'against$p')");
}
for( $p=$call_contra; $p<120; $p+=30)
{
if( $re >= $p )
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'made$p')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'made$p')");
}
}
if($winning_party!="re" and $call_re!=NULL)
{
for( $p=$call_re;$p<=120; $p+=30 )
{
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'against$p')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'against$p')");
}
for( $p=$call_re; $p<120; $p+=30)
{
if( $contra>=$p )
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'made$p')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'made$p')");
}
}
/* point in case contra won */
if($winning_party=="contra")
{
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'againstqueens')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'againstqueens')");
}
/* one point each for winning and each 30 points + calls */
@@ -1436,15 +1432,15 @@ switch($mystatus)
$offset = 1;
if($re>$p-$offset)
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'".(240-$p)."')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'".(240-$p)."')");
}
/* re called something and won */
foreach(array(0,30,60,90,120) as $p)
{
if($call_re!=NULL && $call_re<$p+1)
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'call$p')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'call$p')");
}
}
else if( $winning_party=="contra")
@@ -1456,15 +1452,15 @@ switch($mystatus)
$offset = 1;
if($contra>$p-$offset)
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'".(240-$p)."')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'".(240-$p)."')");
}
/* re called something and won */
foreach(array(0,30,60,90,120) as $p)
{
if($call_contra!=NULL && $call_contra<$p+1)
- mysql_query("INSERT INTO Score".
- " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'call$p')");
+ DB_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'call$p')");
}
}
@@ -1473,19 +1469,19 @@ switch($mystatus)
$message .= "\n";
$Tpoint = 0;
$message .= " Points Re: \n";
- $queryresult = mysql_query("SELECT score FROM Score ".
- " WHERE game_id=$gameid AND party='re'".
- " ");
- while($r = mysql_fetch_array($queryresult,MYSQL_NUM) )
+ $queryresult = DB_query("SELECT score FROM Score ".
+ " WHERE game_id=$gameid AND party='re'".
+ " ");
+ while($r = DB_fetch_array($queryresult) )
{
$message .= " ".$r[0]."\n";
$Tpoint ++;
}
$message .= " Points Contra: \n";
- $queryresult = mysql_query("SELECT score FROM Score ".
- " WHERE game_id=$gameid AND party='contra'".
- " ");
- while($r = mysql_fetch_array($queryresult,MYSQL_NUM) )
+ $queryresult = DB_query("SELECT score FROM Score ".
+ " WHERE game_id=$gameid AND party='contra'".
+ " ");
+ while($r = DB_fetch_array($queryresult) )
{
$message .= " ".$r[0]."\n";
$Tpoint --;
@@ -1568,15 +1564,15 @@ switch($mystatus)
/* add pic for re/contra
" <img class=\"arrow\" src=\"pics/arrow".($pos-1).".png\" alt=\"table\" />\n";*/
- $result = mysql_query("SELECT User.fullname, IFNULL(SUM(Card.points),0), Hand.party,Hand.position FROM Hand".
- " LEFT JOIN Trick ON Trick.winner=Hand.position AND Trick.game_id=Hand.game_id".
- " LEFT JOIN User ON User.id=Hand.user_id".
- " LEFT JOIN Play ON Trick.id=Play.trick_id".
- " LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id".
- " LEFT JOIN Card ON Card.id=Hand_Card.card_id".
- " WHERE Hand.game_id='$gameid'".
- " GROUP BY User.fullname" );
- while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ $result = DB_query("SELECT User.fullname, IFNULL(SUM(Card.points),0), Hand.party,Hand.position FROM Hand".
+ " LEFT JOIN Trick ON Trick.winner=Hand.position AND Trick.game_id=Hand.game_id".
+ " LEFT JOIN User ON User.id=Hand.user_id".
+ " LEFT JOIN Play ON Trick.id=Play.trick_id".
+ " LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id".
+ " LEFT JOIN Card ON Card.id=Hand_Card.card_id".
+ " WHERE Hand.game_id='$gameid'".
+ " GROUP BY User.fullname" );
+ while( $r = DB_fetch_array($result))
echo " <div class=\"card".($r[3]-1)."\">\n".
" <div class=\"score\">".$r[2]."<br /> ".$r[1]."</div>\n".
" </div>\n";
@@ -1662,36 +1658,36 @@ switch($mystatus)
}
else
{
- $result = mysql_query("SELECT Hand.party, IFNULL(SUM(Card.points),0) FROM Hand".
- " LEFT JOIN Trick ON Trick.winner=Hand.position AND Trick.game_id=Hand.game_id".
- " LEFT JOIN User ON User.id=Hand.user_id".
- " LEFT JOIN Play ON Trick.id=Play.trick_id".
- " LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id".
- " LEFT JOIN Card ON Card.id=Hand_Card.card_id".
- " WHERE Hand.game_id='$gameid'".
- " GROUP BY Hand.party" );
+ $result = DB_query("SELECT Hand.party, IFNULL(SUM(Card.points),0) FROM Hand".
+ " LEFT JOIN Trick ON Trick.winner=Hand.position AND Trick.game_id=Hand.game_id".
+ " LEFT JOIN User ON User.id=Hand.user_id".
+ " LEFT JOIN Play ON Trick.id=Play.trick_id".
+ " LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id".
+ " LEFT JOIN Card ON Card.id=Hand_Card.card_id".
+ " WHERE Hand.game_id='$gameid'".
+ " GROUP BY Hand.party" );
echo "<div class=\"total\"> Totals:<br />\n";
- while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ while( $r = DB_fetch_array($result))
echo " ".$r[0]." ".$r[1]."<br />\n";
- $queryresult = mysql_query("SELECT timediff(mod_date,create_date) ".
- " FROM Game WHERE id='$gameid'");
- $r = mysql_fetch_array($queryresult,MYSQL_NUM);
+ $queryresult = DB_query("SELECT timediff(mod_date,create_date) ".
+ " FROM Game WHERE id='$gameid'");
+ $r = DB_fetch_array($queryresult);
echo "<p>This game took ".$r[0]." hours.</p>";
echo "<div class=\"re\">\n Points Re: <br />\n";
- $queryresult = mysql_query("SELECT score FROM Score ".
- " WHERE game_id=$gameid AND party='re'".
- " ");
- while($r = mysql_fetch_array($queryresult,MYSQL_NUM) )
+ $queryresult = DB_query("SELECT score FROM Score ".
+ " WHERE game_id=$gameid AND party='re'".
+ " ");
+ while($r = DB_fetch_array($queryresult) )
echo " ".$r[0]."<br />\n";
echo "</div>\n";
echo "<div class=\"contra\">\n Points Contra: <br />\n";
- $queryresult = mysql_query("SELECT score FROM Score ".
- " WHERE game_id=$gameid AND party='contra'".
- " ");
- while($r = mysql_fetch_array($queryresult,MYSQL_NUM) )
+ $queryresult = DB_query("SELECT score FROM Score ".
+ " WHERE game_id=$gameid AND party='contra'".
+ " ");
+ while($r = DB_fetch_array($queryresult) )
echo " ".$r[0]."<br />\n";
echo "</div>\n";
@@ -1724,8 +1720,7 @@ switch($mystatus)
output_form_calls($me);
/* get time from the last action of the game */
- $result = mysql_query("SELECT mod_date from Game WHERE id='$gameid' " );
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_query_array("SELECT mod_date from Game WHERE id='$gameid' " );
$gameend = time() - strtotime($r[0]);
if($gamestatus == 'play' || $gameend < 60*60*24*7)
@@ -1749,13 +1744,13 @@ switch($mystatus)
{
$session = DB_get_session_by_gameid($gameid);
- $result = mysql_query("SELECT id,create_date FROM Game".
- " WHERE session=$session".
- " ORDER BY create_date DESC".
- " LIMIT 1");
+ $result = DB_query("SELECT id,create_date FROM Game".
+ " WHERE session=$session".
+ " ORDER BY create_date DESC".
+ " LIMIT 1");
$r = -1;
if($result)
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_fetch_array($result);
if(!$session || $gameid==$r[0])
{
diff --git a/include/newgame.php b/include/newgame.php
index 5db0f28..01a7124 100644
--- a/include/newgame.php
+++ b/include/newgame.php
@@ -90,15 +90,15 @@ else
}
if($session)
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre',".
- "'$ruleset','$session' ,NULL)");
+ DB_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre',".
+ "'$ruleset','$session' ,NULL)");
else
{
/* get max session and start a new one */
$max = DB_get_max_session();
$max++;
- mysql_query("UPDATE Game SET session='".$max."' WHERE id=".DB_quote_smart($followup));
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre',".
+ DB_query("UPDATE Game SET session='".$max."' WHERE id=".DB_quote_smart($followup));
+ DB_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre',".
"'$ruleset','$max' ,NULL)");
}
}
@@ -117,10 +117,10 @@ else
$max = DB_get_max_session();
$max++;
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre', ".
- "'$ruleset','$max' ,NULL)");
+ DB_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre', ".
+ "'$ruleset','$max' ,NULL)");
}
- $game_id = mysql_insert_id();
+ $game_id = DB_insert_id();
/* create hash */
$TIME = (string) time(); /* to avoid collisions */
@@ -130,28 +130,28 @@ else
$hashD = md5("AGameOfDoko".$game_id.$PlayerD.$EmailD.$TIME);
/* create hands */
- mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridA).
- ", ".DB_quote_smart($hashA).", 'start','1',NULL,NULL,NULL,NULL)");
- $hand_idA = mysql_insert_id();
- mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridB).
- ", ".DB_quote_smart($hashB).", 'start','2',NULL,NULL,NULL,NULL)");
- $hand_idB = mysql_insert_id();
- mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridC).
- ", ".DB_quote_smart($hashC).", 'start','3',NULL,NULL,NULL,NULL)");
- $hand_idC = mysql_insert_id();
- mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridD).
- ", ".DB_quote_smart($hashD).", 'start','4',NULL,NULL,NULL,NULL)");
- $hand_idD = mysql_insert_id();
+ DB_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridA).
+ ", ".DB_quote_smart($hashA).", 'start','1',NULL,NULL,NULL,NULL)");
+ $hand_idA = DB_insert_id();
+ DB_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridB).
+ ", ".DB_quote_smart($hashB).", 'start','2',NULL,NULL,NULL,NULL)");
+ $hand_idB = DB_insert_id();
+ DB_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridC).
+ ", ".DB_quote_smart($hashC).", 'start','3',NULL,NULL,NULL,NULL)");
+ $hand_idC = DB_insert_id();
+ DB_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridD).
+ ", ".DB_quote_smart($hashD).", 'start','4',NULL,NULL,NULL,NULL)");
+ $hand_idD = DB_insert_id();
/* save cards */
for($i=0;$i<12;$i++)
- mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idA', '".$randomNR[$i]."', 'false')");
+ DB_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idA', '".$randomNR[$i]."', 'false')");
for($i=12;$i<24;$i++)
- mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idB', '".$randomNR[$i]."', 'false')");
+ DB_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idB', '".$randomNR[$i]."', 'false')");
for($i=24;$i<36;$i++)
- mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idC', '".$randomNR[$i]."', 'false')");
+ DB_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idC', '".$randomNR[$i]."', 'false')");
for($i=36;$i<48;$i++)
- mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idD', '".$randomNR[$i]."', 'false')");
+ DB_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idD', '".$randomNR[$i]."', 'false')");
/* send out email, TODO: check for error with email */
$message = "\n".
diff --git a/include/register.php b/include/register.php
index 88b13a2..0dc204d 100644
--- a/include/register.php
+++ b/include/register.php
@@ -22,10 +22,10 @@ if(myisset("Rfullname","Remail","Rpassword","Rtimezone") )
}
if($ok)
{
- $r=mysql_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
- ",".DB_quote_smart($_REQUEST["Remail"]).
- ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
- ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL,NULL)");
+ $r=DB_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
+ ",".DB_quote_smart($_REQUEST["Remail"]).
+ ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
+ ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL,NULL)");
if($r)
{
diff --git a/include/reminder.php b/include/reminder.php
index a269478..8844e48 100644
--- a/include/reminder.php
+++ b/include/reminder.php
@@ -35,8 +35,7 @@ $gameid = DB_get_gameid_by_hash($me);
$myname = DB_get_name('hash',$me);
/* check if player hasn't done anything in a while */
-$result = mysql_query("SELECT mod_date,player,status from Game WHERE id='$gameid' " );
-$r = mysql_fetch_array($result,MYSQL_NUM);
+$r = DB_query_array("SELECT mod_date,player,status from Game WHERE id='$gameid' " );
if( (time()-strtotime($r[0]) > 60*60*24*7) && ($r[2]!='gameover') ) /* = 1 week */
{
$name = DB_get_name('userid',$r[1]);
diff --git a/include/stats.php b/include/stats.php
index bde6a09..cf9b412 100644
--- a/include/stats.php
+++ b/include/stats.php
@@ -5,8 +5,8 @@
if(!isset($HOST))
exit;
-$name = $_SESSION["name"];
-$email = DB_get_email('name',$name);
+$name = $_SESSION["name"];
+$email = DB_get_email('name',$name);
$myid = DB_get_userid('email',$email);
if(!$myid)
@@ -27,40 +27,39 @@ echo "<div class=\"user\">\n";
/* total number of games */
echo "<p>The number of finished games on this server is: ";
-$result = mysql_query("SELECT COUNT(*) from Game".
- " WHERE status='gameover'");
-$r = mysql_fetch_array($result,MYSQL_NUM);
+$r = DB_query_array("SELECT COUNT(*) from Game".
+ " WHERE status='gameover'");
$GameN = $r[0];
echo " $GameN </p>\n";
echo "<p>The contra party wins in ";
-$result = mysql_query("SELECT COUNT(*) from Score".
- " LEFT JOIN Game ON Game.id=game_id".
- " WHERE score='againstqueens'".
- " AND Game.status='gameover'");
-while( $r = mysql_fetch_array($result,MYSQL_NUM))
+$result = DB_query("SELECT COUNT(*) from Score".
+ " LEFT JOIN Game ON Game.id=game_id".
+ " WHERE score='againstqueens'".
+ " AND Game.status='gameover'");
+while( $r = DB_fetch_array($result))
echo $r[0];
echo " games.</p>\n";
/* number of solos */
echo "<p>These kind of games have been played this often: <br />";
-$result = mysql_query("SELECT COUNT(*) as c,type from Game".
- " WHERE status='gameover'".
- " GROUP BY type".
- " ORDER BY c DESC");
-while( $r = mysql_fetch_array($result,MYSQL_NUM))
+$result = DB_query("SELECT COUNT(*) as c,type from Game".
+ " WHERE status='gameover'".
+ " GROUP BY type".
+ " ORDER BY c DESC");
+while( $r = DB_fetch_array($result))
echo "".$r[1]." (".$r[0].") <br />";
echo " </p>\n";
/* break up solos in types */
echo "<p>These kind of solos have been played this often: <br />";
-$result = mysql_query("SELECT COUNT(*) as c,solo from Game".
- " WHERE status='gameover'".
- " AND type='solo'".
- " GROUP BY solo".
- " ORDER BY c DESC");
-while( $r = mysql_fetch_array($result,MYSQL_NUM))
+$result = DB_query("SELECT COUNT(*) as c,solo from Game".
+ " WHERE status='gameover'".
+ " AND type='solo'".
+ " GROUP BY solo".
+ " ORDER BY c DESC");
+while( $r = DB_fetch_array($result))
echo "".$r[1]." (".$r[0].")<br />";
echo "</p>\n";
@@ -77,41 +76,41 @@ echo "</p>\n";
*/
echo "<p>Most extra points (doko, fox, karlchen) in a single game:<br />\n";
-$result = mysql_query("SELECT COUNT(*) as c,fullname FROM Score".
- " LEFT JOIN User ON User.id=winner_id" .
- " WHERE score IN ('fox','doko','karlchen')".
- " GROUP BY game_id,fullname".
- " ORDER BY c DESC LIMIT 3" );
-while( $r = mysql_fetch_array($result,MYSQL_NUM))
+$result = DB_query("SELECT COUNT(*) as c,fullname FROM Score".
+ " LEFT JOIN User ON User.id=winner_id" .
+ " WHERE score IN ('fox','doko','karlchen')".
+ " GROUP BY game_id,fullname".
+ " ORDER BY c DESC LIMIT 3" );
+while( $r = DB_fetch_array($result))
echo $r[1]." (".$r[0].") <br />\n";
echo "</p>\n";
/* longest and shortest game */
-$r=mysql_query("SELECT timediff(mod_date,create_date) ,session,id".
- " FROM Game WHERE status='gameover'".
- " ORDER BY time_to_sec(timediff(mod_date,create_date)) ASC LIMIT 1");
+$r=DB_query("SELECT timediff(mod_date,create_date) ,session,id".
+ " FROM Game WHERE status='gameover'".
+ " ORDER BY time_to_sec(timediff(mod_date,create_date)) ASC LIMIT 1");
if($r)
{
- $short= mysql_fetch_array($r,MYSQL_NUM);
+ $short= DB_fetch_array($r);
$names = DB_get_all_names_by_gameid($short[2]);
echo "<p> The shortest game took only ".$short[0]." hours and was played by ".join(", ",$names).".<br />\n";
}
-$r=mysql_query("SELECT datediff(mod_date,create_date) ,session,id".
- " FROM Game WHERE status='gameover'".
- " ORDER BY time_to_sec(timediff(mod_date,create_date)) DESC LIMIT 1");
+$r=DB_query("SELECT datediff(mod_date,create_date) ,session,id".
+ " FROM Game WHERE status='gameover'".
+ " ORDER BY time_to_sec(timediff(mod_date,create_date)) DESC LIMIT 1");
if($r)
{
- $long= mysql_fetch_array($r,MYSQL_NUM);
+ $long= DB_fetch_array($r);
echo "The longest game took ".$long[0]." days.</p>\n";
}
-$r=mysql_query("SELECT COUNT(*) as c, session, id FROM Game ".
- " GROUP BY session ORDER BY c DESC LIMIT 1");
+$r=DB_query("SELECT COUNT(*) as c, session, id FROM Game ".
+ " GROUP BY session ORDER BY c DESC LIMIT 1");
if($r)
{
- $long = mysql_fetch_array($r,MYSQL_NUM);
+ $long = DB_fetch_array($r);
$names = DB_get_all_names_by_gameid($long[2]);
echo "The longest session is session ".$long[1]." with ".$long[0].
" games played by ".join(", ",$names).".</p>\n";
@@ -119,98 +118,98 @@ if($r)
/* most reminders */
echo "<p>These players got the most reminders per game:<br />\n";
-$result = mysql_query("SELECT COUNT(*) /" .
- " (SELECT COUNT(*) FROM Hand".
- " WHERE user_id=User.id) as c,".
- " fullname FROM Reminder".
- " LEFT JOIN User ON User.id=user_id".
- " GROUP BY user_id".
- " ORDER BY c DESC LIMIT 5" );
-while( $r = mysql_fetch_array($result,MYSQL_NUM))
+$result = DB_query("SELECT COUNT(*) /" .
+ " (SELECT COUNT(*) FROM Hand".
+ " WHERE user_id=User.id) as c,".
+ " fullname FROM Reminder".
+ " LEFT JOIN User ON User.id=user_id".
+ " GROUP BY user_id".
+ " ORDER BY c DESC LIMIT 5" );
+while( $r = DB_fetch_array($result))
echo $r[1]." (".$r[0].") <br />\n";
echo "</p>\n";
/* fox */
echo "<p>These players caught the most foxes per game:<br />\n";
-$result = mysql_query("SELECT COUNT(*) /" .
- " (SELECT COUNT(*) FROM Hand".
- " WHERE user_id=User.id) as c,".
- " fullname".
- " FROM Score".
- " LEFT JOIN User ON User.id=winner_id".
- " WHERE score='fox'".
- " GROUP BY winner_id".
- " ORDER BY c DESC LIMIT 5" );
-while( $r = mysql_fetch_array($result,MYSQL_NUM))
+$result = DB_query("SELECT COUNT(*) /" .
+ " (SELECT COUNT(*) FROM Hand".
+ " WHERE user_id=User.id) as c,".
+ " fullname".
+ " FROM Score".
+ " LEFT JOIN User ON User.id=winner_id".
+ " WHERE score='fox'".
+ " GROUP BY winner_id".
+ " ORDER BY c DESC LIMIT 5" );
+while( $r = DB_fetch_array($result))
echo $r[1]." (".$r[0].") <br />\n";
echo "</p>\n";
echo "<p>These players lost their fox most often per game:<br />\n";
-$result = mysql_query("SELECT COUNT(*) /" .
- " (SELECT COUNT(*) FROM Hand".
- " WHERE user_id=User.id) as c,".
- " fullname".
- " FROM Score".
- " LEFT JOIN User ON User.id=looser_id".
- " WHERE score='fox'".
- " GROUP BY looser_id".
- " ORDER BY c DESC LIMIT 5" );
-while( $r = mysql_fetch_array($result,MYSQL_NUM))
+$result = DB_query("SELECT COUNT(*) /" .
+ " (SELECT COUNT(*) FROM Hand".
+ " WHERE user_id=User.id) as c,".
+ " fullname".
+ " FROM Score".
+ " LEFT JOIN User ON User.id=looser_id".
+ " WHERE score='fox'".
+ " GROUP BY looser_id".
+ " ORDER BY c DESC LIMIT 5" );
+while( $r = DB_fetch_array($result))
echo $r[1]." (".$r[0].") <br />\n";
echo "</p>\n";
echo "<p>These players lost their fox least often per game:<br />\n";
-$result = mysql_query("SELECT COUNT(*) /" .
- " (SELECT COUNT(*) FROM Hand".
- " WHERE user_id=User.id) as c,".
- " fullname".
- " FROM Score".
- " LEFT JOIN User ON User.id=looser_id".
- " WHERE score='fox'".
- " GROUP BY looser_id".
- " ORDER BY c ASC LIMIT 5" );
-while( $r = mysql_fetch_array($result,MYSQL_NUM))
+$result = DB_query("SELECT COUNT(*) /" .
+ " (SELECT COUNT(*) FROM Hand".
+ " WHERE user_id=User.id) as c,".
+ " fullname".
+ " FROM Score".
+ " LEFT JOIN User ON User.id=looser_id".
+ " WHERE score='fox'".
+ " GROUP BY looser_id".
+ " ORDER BY c ASC LIMIT 5" );
+while( $r = DB_fetch_array($result))
echo $r[1]." (".$r[0].") <br />\n";
echo "</p>\n";
/* which position wins the most tricks */
echo "<p>Which positions at the table make the most tricks:<br />\n";
-$result = mysql_query("SELECT COUNT(*) AS c,winner FROM Trick".
- " GROUP BY winner".
- " ORDER BY winner ASC " );
-$r = mysql_fetch_array($result,MYSQL_NUM);
+$result = DB_query("SELECT COUNT(*) AS c,winner FROM Trick".
+ " GROUP BY winner".
+ " ORDER BY winner ASC " );
+$r = DB_fetch_array($result);
if($r[1]==NULL) /* ongoing games, no winner yet */
- $r = mysql_fetch_array($result,MYSQL_NUM);
+ $r = DB_fetch_array($result);
echo " left ".$r[0]." <br />\n";
-$r = mysql_fetch_array($result,MYSQL_NUM);
+$r = DB_fetch_array($result);
echo " top ".$r[0]." <br />\n";
-$r = mysql_fetch_array($result,MYSQL_NUM);
+$r = DB_fetch_array($result);
echo " right ".$r[0]." <br />\n";
-$r = mysql_fetch_array($result,MYSQL_NUM);
+$r = DB_fetch_array($result);
echo " bottom ".$r[0]." <br />\n";
echo "</p>\n";
/* most games */
echo "<p>Most games played on the server:<br />\n";
-$result = mysql_query("SELECT COUNT(*) as c, " .
- " fullname FROM Hand".
- " LEFT JOIN User ON User.id=user_id".
- " GROUP BY user_id".
- " ORDER BY c DESC LIMIT 7" );
-while( $r = mysql_fetch_array($result,MYSQL_NUM))
+$result = DB_query("SELECT COUNT(*) as c, " .
+ " fullname FROM Hand".
+ " LEFT JOIN User ON User.id=user_id".
+ " GROUP BY user_id".
+ " ORDER BY c DESC LIMIT 7" );
+while( $r = DB_fetch_array($result))
echo $r[1]." (".$r[0].") <br />\n";
echo "</p>\n";
/* most active games */
echo "<p>These players are involved in this many active games:<br />\n";
-$result = mysql_query("SELECT COUNT(*) as c, " .
- " fullname FROM Hand".
- " LEFT JOIN User ON User.id=user_id".
- " LEFT JOIN Game ON Game.id=game_id".
- " WHERE Game.status<>'gameover'".
- " GROUP BY user_id".
- " ORDER BY c DESC LIMIT 7" );
-while( $r = mysql_fetch_array($result,MYSQL_NUM))
+$result = DB_query("SELECT COUNT(*) as c, " .
+ " fullname FROM Hand".
+ " LEFT JOIN User ON User.id=user_id".
+ " LEFT JOIN Game ON Game.id=game_id".
+ " WHERE Game.status<>'gameover'".
+ " GROUP BY user_id".
+ " ORDER BY c DESC LIMIT 7" );
+while( $r = DB_fetch_array($result))
echo $r[1]." (".$r[0].") <br />\n";
echo "</p>\n";
diff --git a/include/user.php b/include/user.php
index 8feac01..fa4653d 100644
--- a/include/user.php
+++ b/include/user.php
@@ -111,26 +111,26 @@ if(myisset("forgot"))
{
case "germancards":
case "englishcards":
- $result = mysql_query("SELECT * from User_Prefs".
- " WHERE user_id='$myid' AND pref_key='cardset'" );
- if( mysql_fetch_array($result,MYSQL_NUM))
- $result = mysql_query("UPDATE User_Prefs SET value=".DB_quote_smart($setpref).
- " WHERE user_id='$myid' AND pref_key='cardset'" );
+ $result = DB_query("SELECT * from User_Prefs".
+ " WHERE user_id='$myid' AND pref_key='cardset'" );
+ if( DB_fetch_array($result))
+ $result = DB_query("UPDATE User_Prefs SET value=".DB_quote_smart($setpref).
+ " WHERE user_id='$myid' AND pref_key='cardset'" );
else
- $result = mysql_query("INSERT INTO User_Prefs VALUES(NULL,'$myid','cardset',".
- DB_quote_smart($setpref).")");
+ $result = DB_query("INSERT INTO User_Prefs VALUES(NULL,'$myid','cardset',".
+ DB_quote_smart($setpref).")");
echo "Ok, changed you preferences for the cards.\n";
break;
case "emailaddict":
case "emailnonaddict":
- $result = mysql_query("SELECT * from User_Prefs".
- " WHERE user_id='$myid' AND pref_key='email'" );
- if( mysql_fetch_array($result,MYSQL_NUM))
- $result = mysql_query("UPDATE User_Prefs SET value=".DB_quote_smart($setpref).
- " WHERE user_id='$myid' AND pref_key='email'" );
+ $result = DB_query("SELECT * from User_Prefs".
+ " WHERE user_id='$myid' AND pref_key='email'" );
+ if( DB_fetch_array($result))
+ $result = DB_query("UPDATE User_Prefs SET value=".DB_quote_smart($setpref).
+ " WHERE user_id='$myid' AND pref_key='email'" );
else
- $result = mysql_query("INSERT INTO User_Prefs VALUES(NULL,'$myid','email',".
- DB_quote_smart($setpref).")");
+ $result = DB_query("INSERT INTO User_Prefs VALUES(NULL,'$myid','email',".
+ DB_quote_smart($setpref).")");
echo "Ok, changed you preferences for sending out emails.\n";
break;
}
@@ -166,8 +166,8 @@ if(myisset("forgot"))
break;
case '1':
echo "Changed the password.<br />";
- mysql_query("UPDATE User SET password='".md5($_REQUEST["password1"]).
- "' WHERE id=".DB_quote_smart($myid));
+ DB_query("UPDATE User SET password='".md5($_REQUEST["password1"]).
+ "' WHERE id=".DB_quote_smart($myid));
break;
}
/* set password */
@@ -192,13 +192,13 @@ if(myisset("forgot"))
echo "</p>\n";
$output = array();
- $result = mysql_query("SELECT Hand.hash,Hand.game_id,Game.mod_date,Game.player,Game.status from Hand".
- " LEFT JOIN Game ON Game.id=Hand.game_id".
- " WHERE user_id='$myid'".
- " ORDER BY Game.session,Game.create_date" );
+ $result = DB_query("SELECT Hand.hash,Hand.game_id,Game.mod_date,Game.player,Game.status from Hand".
+ " LEFT JOIN Game ON Game.id=Hand.game_id".
+ " WHERE user_id='$myid'".
+ " ORDER BY Game.session,Game.create_date" );
$gamenrold = -1;
echo "<table>\n <tr><td>\n";
- while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ while( $r = DB_fetch_array($result))
{
$game = DB_format_gameid($r[1]);
$gamenr = (int) $game;
diff --git a/include/welcome.php b/include/welcome.php
index 7aeaf78..34709d3 100644
--- a/include/welcome.php
+++ b/include/welcome.php
@@ -8,16 +8,16 @@ if(!isset($HOST))
/* this outputs the default home page with some extra statistics on it */
$pre[0]=0;$game[0]=0;$done[0]=0;
-$r=mysql_query("SELECT COUNT(id) FROM Game GROUP BY status");
+$r=DB_query("SELECT COUNT(id) FROM Game GROUP BY status");
if($r) {
- $pre = mysql_fetch_array($r,MYSQL_NUM);
- $game = mysql_fetch_array($r,MYSQL_NUM);
- $done = mysql_fetch_array($r,MYSQL_NUM);
+ $pre = DB_fetch_array($r);
+ $game = DB_fetch_array($r);
+ $done = DB_fetch_array($r);
}
-$r=mysql_query("SELECT AVG(datediff(mod_date,create_date)) FROM Game where status='gameover' ");
+$r=DB_query("SELECT AVG(datediff(mod_date,create_date)) FROM Game where status='gameover' ");
if($r)
- $avgage= mysql_fetch_array($r,MYSQL_NUM);
+ $avgage= DB_fetch_array($r);
else
$avgage[0]=0;