X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=aec7c7d1ef7f27808183fab71876b442a927bf79;hp=f2228988735f7ae6b926a33eb4b972afc453d8b7;hb=1f6dbb2039311c94e7932fac52626442d215d2b5;hpb=c54caff489a4eece8eb69321df364e184c4f4632 diff --git a/index.php b/index.php index f222898..aec7c7d 100644 --- a/index.php +++ b/index.php @@ -1,521 +1,144 @@ - - -
-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.
".$r[0]." | (".$r[2].") | ".$r[1]." |
".$r[0]." | ".$r[1]." |
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; + } + } + 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,Game.player 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($r[3])
+ {
+ if($r[3]==$uid)
+ echo "(it's your turn)\n";
+ else
+ {
+ $name = DB_get_name_by_userid($r[3]);
+ echo "(it's $name's turn)\n";
+ };
+ }
+ 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,Game.player 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($r[3])
+ {
+ if($r[3]==$uid)
+ echo "(it's your turn)\n";
+ else
+ {
+ $name = DB_get_name_by_userid($r[3]);
+ echo "(it's $name's turn)\n";
+ };
+ }
+ 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";
+ $output = array();
+ $result = mysql_query("SELECT hash,game_id from Hand WHERE user_id='$uid' AND status='gameover'" );
+ while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ $output[] = "#".$r[1]." ";
+ echo implode(", ",$output)."
Registered players:
\n";
+ echo implode(", ",$names)."\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 "