X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=cf556803ad17b6f8a84f9ac26b4baf21594064d8;hp=6208038dce9bfb09ddb3fef18139418394938b40;hb=1bb3313519b27a11d6634b584301f4d65f3ff364;hpb=320ebe96e21e08d5fad1a4ccbef241d5defd92bc diff --git a/index.php b/index.php index 6208038..cf55680 100644 --- a/index.php +++ b/index.php @@ -1,70 +1,20 @@ - - - - e-Doko - - - - - -
-

Welcome to E-Doko

-
- -

Please add 4 names, please make sure that the names are correct!

-
- Name: - Name: - Name: - Name: - - -
-\n"; echo "perhaps the game has been cancled."; - exit(); + 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); - - /* get game id */ - $gameid = DB_get_gameid_by_hash($me); switch($mystatus) { @@ -190,7 +140,6 @@ else if(isset($_REQUEST["me"])) check_want_to_play($me); DB_set_hand_status_by_hash($me,'init'); break; - case 'init': if( !isset($_REQUEST["in"]) || !isset($_REQUEST["update"])) { @@ -201,8 +150,8 @@ else if(isset($_REQUEST["me"])) { if($_REQUEST["in"] == "no") { - echo "TODO: email everyone that the game has been canceld
"; - /*something like + echo "TODO: email everyone that the game has been canceled.
"; + /*something like need to modify for DB backend for($i=0;$i<4;$i++) { $message = "Hello ".$player[$hash[$i]]["name"].",\n\n". @@ -210,6 +159,7 @@ else if(isset($_REQUEST["me"])) mymail($player[$hash[$i]]["email"],"[DoKo-Debug] the game has been canceled",$message); } */ + /* delete everything from the dB */ DB_cancel_game($me); } else @@ -292,17 +242,43 @@ else if(isset($_REQUEST["me"])) break; case 'play': - case 'gameover': /* gameover and play, so that the tricks are visible for both */ - display_news(); + case 'gameover': /*both entries here, so that the tricks are visible for both in case of 'play' there is a break later that skips the last part*/ + /* display local time */ + echo "
\n Local times:"; + $users = array(); + $users = DB_get_all_userid_by_gameid($gameid); + foreach($users as $user) + { + $offset = DB_get_user_timezone($user); + $zone = return_timezone($offset); + date_default_timezone_set($zone); + $name = DB_get_name_by_userid($user); + + echo "\n"; + }; + echo "
$name ".date("Y-m-d H:i:s")."
\n
\n"; display_status(); - $gamestatus =DB_get_game_status_by_gameid($gameid); + /* display links to other games */ + echo "
\n"; + $result = mysql_query("SELECT email,password from User WHERE id='$myid'" ); + $r = mysql_fetch_array($result,MYSQL_NUM); + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + + display_news(); + + $gamestatus = DB_get_game_status_by_gameid($gameid); if($gamestatus == 'pre') { echo "you need to wait for the others...
"; break; } - /* get trick ids */ + /* get everythin relevant to display the tricks */ $result = mysql_query("SELECT Hand_Card.card_id as card,". " User.fullname as name,". " Hand.position as position,". @@ -325,17 +301,17 @@ else if(isset($_REQUEST["me"])) $lasttrick = DB_get_max_trickid($gameid); $play = array(); /* needed to calculate winner later */ - $seq=1; - $pos=0; + $seq = 1; + $pos = 0; echo "\n\n"; @@ -473,7 +450,14 @@ else if(isset($_REQUEST["me"])) } if($next==5) $next=1; - echo "TODO: email next player at pos $next
"; + /* email next player */ + $next_hash = DB_get_hash_from_game_and_pos($gameid,$next); + $email = DB_get_email_by_hash($next_hash); + + $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); + if($debug) echo "DEBUG: next player
\n"; @@ -533,7 +517,7 @@ else if(isset($_REQUEST["me"])) $names = DB_get_all_names_by_gameid($gameid); echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n"; - echo "
\n"; + echo "\n"; echo " \n"; echo " \n"; echo " \n"; @@ -548,14 +532,20 @@ else if(isset($_REQUEST["me"])) } exit(); } +/* user status page */ else if(isset($_REQUEST["email"]) && isset($_REQUEST["password"])) { + /* test id and password, should really be done in one step */ + $email = $_REQUEST["email"]; + $password = $_REQUEST["password"]; + + if(strlen($password)!=32) + $password = md5($password); + $ok=1; - $uid = DB_get_userid_by_email($_REQUEST["email"]); + $uid = DB_get_userid_by_email_and_password($email,$password); if(!$uid) $ok=0; - if(!DB_get_userid_by_passwd(md5($_REQUEST["password"]))) - $ok=0; if($ok) { @@ -566,15 +556,14 @@ else if(isset($_REQUEST["me"])) $zone = return_timezone($offset); date_default_timezone_set($zone); - echo "ok. your logged in, now what? :)
last login: "; - echo date("r",$unixtime)."
"; + echo "last login: ".date("r",$unixtime)."
"; 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'" ); while( $r = mysql_fetch_array($result,MYSQL_NUM)) - echo "game #".$r[1]."
"; + echo "game #".$r[1]."
"; echo "

\n"; $names = DB_get_all_names(); @@ -583,7 +572,7 @@ else if(isset($_REQUEST["me"])) echo "$name
\n"; echo "

\n"; echo "

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

"; + "this page.

"; } else { @@ -591,8 +580,10 @@ else if(isset($_REQUEST["me"])) } exit(); } +/* page for registration */ else if(isset($_REQUEST["register"]) ) { + echo "IMPORTANT: passwords are going over the net as clear text, so pick an easy password. No need to pick anything complicated here ;)

"; echo "TODO: convert timezone into a menu
\n"; echo "TODO: figure out a way to handle passwrods
\n"; ?> @@ -621,6 +612,7 @@ else if(isset($_REQUEST["register"]) )
-

If you want to play a game of Doppelkopf, you found the right place ;)

-

Please register, in case you haven't done yet
- or login with you email-address or name and password here: -

-
- Login - - - - - - - -
-
-
- -

- - - - - -