X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=83c8cb7c2a553480ab8c4f05bb4982b9a6ff081d;hp=e86854cea5addfe466f243cd0d628f4f337af8ac;hb=f76fa7b25a6b09c2443680e1ae915cd949704d4e;hpb=d0237ebe9fa2aa6916b644766d97ff43ac4b945e diff --git a/index.php b/index.php index e86854c..83c8cb7 100644 --- a/index.php +++ b/index.php @@ -1,520 +1,145 @@ - - -
-Game $gameid has been cancled.
You need to wait longer before you can cancle a game...
\n"; + } +/* handle request from one specific player for one game, + * (the hash is set on a per game base) */ +else if(myisset("me")) { -?> -no game in progress, please input 4 names and email addresses, please make sure that the addresses are correct!
- \n"; - } - } -/* *** - * * * - * *** - * * * - * *** - * yes? email him his hand, ask for solo, poverty, email every move or every card? - */ - if(isset($_REQUEST["b"])) + echo "you need to answer the question.
"; + DB_set_hand_status_by_hash($me,'start'); + } + else + { + if($_REQUEST["in"] == "no") + { + /* cancle the game */ + $message = "Hello, \n\n". + "the game has been canceled due to the request of one of the players.\n"; + + $userids = DB_get_all_userid_by_gameid($gameid); + foreach($userids as $user) + { + $To = DB_get_email_by_userid($user); + mymail($To,$EmailName."game canceled",$message); + } + + /* delete everything from the dB */ + DB_cancel_game($me); + } + else + { + echo "thanks for joining the game..."; + + $mycards = DB_get_hand($me); + sort($mycards); + echo "your cards are:
\n";
+ foreach($mycards as $card)
+ display_card($card,$PREF["cardset"]);
+ echo "
Game $gameid has been cancled.
your cards are:
\n";
- foreach($mycards as $card)
- display_card($card);
- echo "
aehm... at the moment poverty is not implented. so I guess you need to play a normal game, even if you have less than 3 trump :(...sorry
- - \n"; - } - } + echo "couldn't find a player with this email, please contact Arun, if you think this is a mistake"; + } } - - if(isset($_REQUEST["c"])) + else + { + /* verify password and email */ + 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) + { + if(myisset("setpref")) + { + $setpref=$_REQUEST["setpref"]; + switch($setpref) + { + case "germancards": + case "englishcards": + $result = mysql_query("SELECT * from User_Prefs". + " WHERE user_id='$uid' 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='$uid' AND pref_key='cardset'" ); + else + $result = mysql_query("INSERT INTO User_Prefs VALUES(NULL,'$uid','cardset',".DB_quote_smart($setpref).")"); + echo "Ok, changed you preferences for the cards.\n"; + break; + } + } + else /* output default user page */ + { + $time = DB_get_user_timestamp($uid); + $unixtime =strtotime($time); + + $offset = DB_get_user_timezone($uid); + $zone = return_timezone($offset); + date_default_timezone_set($zone); + + /* display links to settings */ + output_user_settings($email,$password); + + echo "last login: ".date("r",$unixtime)."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".
+ " (clicking here is final and can't be restored)";
+ echo "
";
+ }
+ 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 "#".$r[1]." , ";
+ echo "
registered players:
\n";
+ foreach ($names as $name)
+ echo "$name, \n";
+ echo "
Want to start a new game? Visit this page.
"; + } + } + else + { + echo "sorry email and password don't matchjust wait for the game to start
\n"; - } - else if(!isset($_REQUEST["solo"]) || - !isset($_REQUEST["wedding"]) || - !isset($_REQUEST["poverty"]) || - !isset($_REQUEST["nines"]) ) - {/* player still needs to fill out the form */ - echo "go back to "; - echo " here and fill out the formThe game can start now, it's your turn, please use this link to play a card.
\n"; - } - else if($game["init"]==4) - { - $message = "The game can start now, it's your turn, please use this link to play a card:\n". - $host."?me=".$hash[$game["startplayer"]]."\n"; - mymail($player[$hash[$game["startplayer"]]]["email"],"[DoKo-debug] let's go",$message); - echo "The game has started. An email has been sent out to the first player.
\n"; - } - else - { - echo "You're in. Once everyone has filled out the form, ". - "the game will start and you'll get an eamil on your turn.
\n"; - } - } + echo "please chose another nameAn email with the game information has been sent.
\n"; - } - else - { - echo "can't find this email address, sorry.
\n"; - }; - } /* end recovery */ - } + if($r) + echo " added you to the database"; else - { /* $me is set */ - $me = $_REQUEST["me"]; - - /* show history */ - /* old tricks as list */ - echo "