\n";
/* check if we need to set status to 'gameover' is done during playing of the card */
if($mystatus=='play')
break;
/* the following happens only when the gamestatus is 'gameover' */
/* check if game is over, display results */
if(DB_get_game_status_by_gameid($gameid)=='play')
{
echo "the game is over for you.. other people still need to play though";
}
else
{
echo "the game is over now...\n";
$result = mysql_query("SELECT fullname, SUM(score) FROM Score".
" LEFT JOIN Hand ON Hand.id=hand_id".
" LEFT JOIN User ON Hand.user_id=User.id".
" WHERE Hand.game_id=$gameid".
" GROUP BY fullname" );
while( $r = mysql_fetch_array($result,MYSQL_NUM))
echo " FINAL SCORE: ".$r[0]." ".$r[1]."";
/* suggest a new game with the same people in it, just rotated once */
$names = DB_get_all_names_by_gameid($gameid);
output_ask_for_new_game($names[1],$names[2],$names[3],$names[0],$gameid);
}
break;
default:
echo "error in testing the status";
}
exit();
}
/* user status page */
else if(myisset("email","password"))
{
/* test id and password, should really be done in one step */
$email = $_REQUEST["email"];
$password = $_REQUEST["password"];
if(strlen($password)!=32)
$password = md5($password);
$ok=1;
$uid = DB_get_userid_by_email_and_password($email,$password);
if(!$uid)
$ok=0;
if($ok)
{
$time = DB_get_user_timestamp($uid);
$unixtime =strtotime($time);
$offset = DB_get_user_timezone($uid);
$zone = return_timezone($offset);
date_default_timezone_set($zone);
echo "last login: ".date("r",$unixtime)."";
DB_update_user_timestamp($uid);
echo "

these are the games you are playing in:\n";
$result = mysql_query("SELECT Hand.hash,Hand.game_id,Game.mod_date from Hand".
" LEFT JOIN Game On Hand.game_id=Game.id".
" WHERE Hand.user_id='$uid' AND Game.status<>'gameover'" );
while( $r = mysql_fetch_array($result,MYSQL_NUM))
{
echo "game #".$r[1]." ";
if(time()-strtotime($r[2]) > 60*60*24*30)
echo " The game has been running for over a month. Do you want to cancel it? yes";
echo "";
}
echo "

\n";
echo "

and these are your games that are already done:\n";
$result = mysql_query("SELECT hash,game_id from Hand WHERE user_id='$uid' AND status='gameover'" );
while( $r = mysql_fetch_array($result,MYSQL_NUM))
echo "game #".$r[1]." ";
echo "