X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=216a431b50ecc11e556fedc7138c055b431c88db;hp=cd404b3e7da1bef925975977fe9f39d47c75e944;hb=14e087ec31455a9d1780ffbf6a2cf883d9b6bfc5;hpb=6e709fb780a236b6518653ac392c26a684204462 diff --git a/index.php b/index.php index cd404b3..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.
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.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 "
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 "
registered players:
\n";
foreach ($names as $name)
- echo "$name
\n";
+ echo "$name, \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 {