X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=1a825de1223eecbaee350a8c832f2e5cec1c8168;hp=f2228988735f7ae6b926a33eb4b972afc453d8b7;hb=88321df4d58a8d42f484ec202b0b4ec30f2d4e97;hpb=c54caff489a4eece8eb69321df364e184c4f4632 diff --git a/index.php b/index.php index f222898..1a825de 100644 --- a/index.php +++ b/index.php @@ -1,521 +1,146 @@ - - -
-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 $gameid 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 "
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) + { + DB_get_PREF($uid); + + 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; + case "ccemail": + $result = mysql_query("SELECT * from User_Prefs". + " WHERE user_id='$uid' AND pref_key='ccemail'" ); + if( mysql_fetch_array($result,MYSQL_NUM)) + if($PREF["ccemail"]=="yes") + $result = mysql_query("UPDATE User_Prefs SET value=".DB_quote_smart("no"). + " WHERE user_id='$uid' AND pref_key='ccemail'" ); + else + $result = mysql_query("UPDATE User_Prefs SET value=".DB_quote_smart("yes"). + " WHERE user_id='$uid' AND pref_key='ccemail'" ); + else + $result = mysql_query("INSERT INTO User_Prefs VALUES(NULL,'$uid','ccemail',".DB_quote_smart("yes").")"); + echo "Ok, changed you preferences for being CC'ed on emails.\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 your games that haven't started yet:
\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='pre'" );
+ 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 "
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='play'" );
+ 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 "