".$card.":\n";
- }
- else
- {
- $tmp = explode(":",$history[sizeof($history)-1]);
- $tmp[sizeof($tmp)-1] = "".$player[$me]["number"]."->".$card.":";
- $history[sizeof($history)-1]=join(":",$tmp);
- }
- save_status();
-
- echo " you played ";
- display_card($card);
- /* send out email to players who want/need to get informed */
- for($i=0;$i<4;$i++)
- {
- $mynext=$next+1; if($mynext>3)$mynext-=4;
- if((ereg("c",$player[$hash[$i]]["option"]) || $i==$mynext) && $hash[$i]!=$me)
- {
- echo "
** $next** \n Hello ".$player[$hash[$i]]["name"].",\n";
- echo "\n";
- if($i==$mynext)
- echo "it's your turn now.\n";
- echo $player[$me]["name"]. "has played the following card ".card_to_name($card)."\n";
-
- echo " player 1
";
- echo " player 2
";
- echo " player 3
";
- echo " player 4
";
-
- }
- }
- }
- else
- echo "seems like you don't have that card
";
-
- }
-
- }
- else if(isset($_REQUEST["win"]) && strlen($history[sizeof($history)-1])>3)
- {
- $win=$_REQUEST["win"];
- $history[]=$win.":\n";
- /* count points of the last trick */
- $points=0;
- echo "
".$history[sizeof($history)-2]."is the last trick played
";
- $tmp = explode(":",$history[sizeof($history)-2]);
- for($i=0;$i<4;$i++)
- {
- $tmp2 = explode("->",$tmp[$i]);
- $c = $tmp2[1];
- $points += card_value($c);
- echo "adding card value ".card_value($c)."
";
- }
- $player[$hash[$win]]["points"]+=$points;
- echo "
".$player[$hash[$win]]["name"]." won: $points Points
";
-
- save_status();
- }
- echo "
";
-
- $tmp = explode(":",$history[sizeof($history)-1]);
-
- if(sizeof($tmp)==5)
- {
- ?>
-
-";
- if(strlen(trim($player[$me]["cards"]))==0)
- {
- echo "
game over, count points
";
- for($i=0;$i>4;$i++)
- {
- echo $player[$hash[$i]]["name"]." got ".$player[$hash[$i]]["points"]."
";
- }
- }
- }
- if($hash[$next]==$me && strlen(trim($player[$me]["cards"]))>0 )
- {
-
- echo "ITS YOUR TURN
";
- $allcards = trim($player[$me]["cards"]);
- $mycards = explode(";",$allcards);
-
- sort($mycards);
- echo "your cards are
";
- foreach($mycards as $card)
- {
- display_link_card($card,$me);
- }
- echo "
\n";
- }
- echo "
";
-
- }
- }
- }
+ 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)
+ {
+ $time = DB_get_user_timestamp($uid);
+ $unixtime =strtotime($time);
+
+ $offset = DB_get_user_timezone($uid);
+ $zone = return_timezone($offset);
+ date_default_timezone_set($zone);
+
+ 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 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";
+ echo "
";
+ }
+ echo "
\n";
+
+
+ echo "and these are your games that are already done:
\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 "
\n";
+
+ $names = DB_get_all_names();
+ echo "registered players:
\n";
+ foreach ($names as $name)
+ echo "$name
\n";
+ echo "
\n";
+
+ echo "Want to start a new game? remember 4 names from the list above and visit ".
+ "this page.
";
+ }
+ else
+ {
+ echo "sorry email and password don't match
";
+ }
+ exit();
+ }
+/* page for registration */
+else if(myisset("register") )
+ {
+ output_register();
+ }
+/* new user wants to register */
+ else if(myisset("Rfullname","Remail","Rpassword","Rtimezone") )
+ {
+ $ok=1;
+ if(DB_get_userid_by_name($_REQUEST["Rfullname"]))
+ {
+ echo "please chose another name
";
+ $ok=0;
+ }
+ if(DB_get_userid_by_email($_REQUEST["Remail"]))
+ {
+ echo "this email address is already used ?!
";
+ $ok=0;
+ }
+ if($ok)
+ {
+ $r=mysql_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
+ ",".DB_quote_smart($_REQUEST["Remail"]).
+ ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
+ ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL)");
+
+ if($r)
+ echo " added you to the database";
+ else
+ echo " something went wrong";
+ }
+ }
+/* default login page */
+else
+ {
+ output_home_page();
+ }
+
+output_footer();
+
+DB_close();
+
+/*
+ *Local Variables:
+ *mode: php
+ *mode: hs-minor
+ *End:
+ */
?>
-
-
+