mysql_select_db($DB_database) or die('Could not select database');
}
else
- return -1;
-
+ {
+ echo mysql_errno() . ": " . mysql_error(). "\n";
+ return -1;
+ }
return 0;
}
function DB_query($query)
{
/* debug/optimize the database
- $logfile=fopen('/tmp/DBlog.log','a+');
- fwrite($logfile,"EXPLAIN $query ;\n");
-
$time = microtime();
$return = mysql_query($query);
$time = $time - microtime();
- fwrite($logfile,"time of above query: $time\n");
-
- fclose($logfile);
+ if($time > 0.05) // this way we can find only the long ones
+ {
+ $logfile=fopen('/tmp/DBlog.log','a+');
+ fwrite($logfile,"EXPLAIN $query ;\n");
+ fwrite($logfile,"time of above query: $time\n");
+ fclose($logfile);
+ };
return $return;
*/
return 0;
}
-function DB_cancel_game($hash)
-{
- $gameid = DB_get_gameid_by_hash($hash);
-
- if(!$gameid)
- return;
-
- /* get the IDs of all players */
- $result = DB_query("SELECT id FROM Hand WHERE game_id=".DB_quote_smart($gameid));
- while($r = DB_fetch_array($result))
- {
- $id = $r[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]));
-
- 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 */
- 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;
-}
-
function DB_get_hand($me)
{
$cards = array();
/* test if a recovery password has been set */
if(!$r)
{
- echo "testing alternative password";
+ /* testing alternative password */
$result = DB_query("SELECT User.id FROM User".
" LEFT JOIN Recovery ON User.id=Recovery.user_id".
" WHERE email=".DB_quote_smart($var1).