X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=216a431b50ecc11e556fedc7138c055b431c88db;hp=157c7bdc8a30b7fdce115e8bef76a36ccafa053d;hb=14e087ec31455a9d1780ffbf6a2cf883d9b6bfc5;hpb=08de22eff38ad5fc17174d8515b5eb90e8dc8841 diff --git a/index.php b/index.php index 157c7bd..216a431 100644 --- a/index.php +++ b/index.php @@ -1,11 +1,18 @@ \n"; + echo "perhaps the game has been cancled, check by login in here."; + exit(); + } + + DB_update_user_timestamp($myid); + + /* get some information from the DB */ + $gameid = DB_get_gameid_by_hash($me); + $myname = DB_get_name_by_hash($me); + $mystatus = DB_get_status_by_hash($me); + $mypos = DB_get_pos_by_hash($me); + + /* check if game really is old enough */ + $result = mysql_query("SELECT mod_date from Game WHERE id='$gameid' " ); + $r = mysql_fetch_array($result,MYSQL_NUM); + if(time()-strtotime($r[0]) > 60*60*24*30) + { + $message = "Hello, \n\n". + "Game $gameid has been cancled since nothing happend for a while and $myname requested it.\n"; + + $userids = DB_get_all_userid_by_gameid($gameid); + foreach($userids as $user) + { + $To = DB_get_email_by_userid($user); + mymail($To,$EmailName."game cancled (timed out)",$message); + } + + /* delete everything from the dB */ + DB_cancel_game($me); + + echo "

Game $gameid has been cancled.

"; + } + else + echo "

You need to wait longer before you can cancle a game...

\n"; +} else if(myisset("me")) - { - /* handle request from one specific player, - * the hash is set on a per game base - */ - - $me = $_REQUEST["me"]; - - /* test for valid ID */ - $myid = DB_get_userid_by_hash($me); - if(!$myid) - { - echo "Can't find you in the database, please check the url.
\n"; - echo "perhaps the game has been cancled, check by login in here."; - exit(); - } - - DB_update_user_timestamp($myid); - - /* get some information from the DB */ - $gameid = DB_get_gameid_by_hash($me); - $myname = DB_get_name_by_hash($me); - $mystatus = DB_get_status_by_hash($me); - $mypos = DB_get_pos_by_hash($me); - +{ + /* handle request from one specific player, +` * the hash is set on a per game base + */ + + $me = $_REQUEST["me"]; + + /* test for valid ID */ + $myid = DB_get_userid_by_hash($me); + if(!$myid) + { + echo "Can't find you in the database, please check the url.
\n"; + echo "perhaps the game has been cancled, check by login in here."; + exit(); + } + + DB_update_user_timestamp($myid); + + /* get some information from the DB */ + $gameid = DB_get_gameid_by_hash($me); + $myname = DB_get_name_by_hash($me); + $mystatus = DB_get_status_by_hash($me); + $mypos = DB_get_pos_by_hash($me); + + echo "

Game $gameid

\n"; + switch($mystatus) { case 'start': @@ -161,7 +223,7 @@ else if(myisset("me")) foreach($userids as $user) { $To = DB_get_email_by_userid($user); - mymail($To,"[DoKo] game cancled",$message); + mymail($To,$EmailName."game cancled",$message); } /* delete everything from the dB */ @@ -191,7 +253,7 @@ else if(myisset("me")) echo "checking if you selected solo or nines...
". " if you have a wedding, please send an email to the other players.
". " if you have poverty you need to play a normal game,sorry...
". - " At the moment you need to reload this page to finish the setup.
"; + " Please click here to finish the setup.
"; if(!myisset("solo","wedding","poverty","nines") ) { /* all these variables have a pre-selected default, @@ -251,7 +313,7 @@ else if(myisset("me")) * tell people about it. */ echo "
checking if someone else selected solo or nines... wedding and poverty not handled at the moment
". - "reload this page to finish the setup
"; + " Please click here to finish the setup.
"; /* only set this after all poverty, etc. are handeled*/ DB_set_hand_status_by_hash($me,'play'); @@ -292,7 +354,7 @@ else if(myisset("me")) foreach($userids as $user) { $To = DB_get_email_by_userid($user); - mymail($To,"[DoKo] game cancled",$message); + mymail($To,$EmailName."game cancled",$message); } /* delete everything from the dB */ @@ -602,7 +664,7 @@ else if(myisset("me")) foreach($userids as $user) { $To = DB_get_email_by_userid($user); - mymail($To,"[DoKo] game over",$message); + mymail($To,$EmailName."game over",$message); } } @@ -645,7 +707,7 @@ else if(myisset("me")) $message = "It's your turn now.\n". "Use this link to play a card: ".$host."?me=".$next_hash."\n\n" ; - mymail($email,"[DoKo-debug] a card has been played",$message); + mymail($email,$EmailName."a card has been played",$message); if($debug) echo "DEBUG:\n"; if($myturn && !myisset("card")) @@ -720,9 +782,22 @@ else if(myisset("me")) 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); + + $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"); + $r=-1; + if($result) + $r = mysql_fetch_array($result,MYSQL_NUM); + + if(!$session || $gameid==$r) + { + /* 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: @@ -759,25 +834,32 @@ else if(myisset("me")) DB_update_user_timestamp($uid); echo "

these are the games you are playing in:
\n"; - $result = mysql_query("SELECT hash,game_id from Hand WHERE user_id='$uid' AND status<>'gameover'" ); + $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]."
"; + { + 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 (clicking here is final and can't be restored)"; + echo "
"; + } echo "

\n"; - echo "

and these are your games that are already done:
\n"; + + echo "

and these are your games that are already done:
Game: \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 "#".$r[1]." , "; echo "

\n"; $names = DB_get_all_names(); echo "

registered players:
\n"; foreach ($names as $name) - echo "$name
\n"; + echo "$name, \n"; echo "

\n"; - echo "

Want to start a new game? remember 4 names from the list above and visit ". - "this page.

"; + echo "

Want to start a new game? Visit this page.

"; } else {