if($EmailA=="" || $EmailB=="" || $EmailC=="" || $EmailD=="")
{
echo "couldn't find one of the names, please start a new game";
+ output_footer();
exit();
}
if($ruleset <0)
{
echo "Error defining ruleset: $ruleset";
+ output_footer();
exit();
};
{
echo "Can't find you in the database, please check the url.<br />\n";
echo "perhaps the game has been cancled, check by login in <a href=\"$host\">here</a>.";
+ output_footer();
exit();
}
{
echo "Can't find you in the database, please check the url.<br />\n";
echo "perhaps the game has been cancled, check by login in <a href=\"$host\">here</a>.";
+ output_footer();
exit();
}
$mystatus = DB_get_status_by_hash($me);
$mypos = DB_get_pos_by_hash($me);
- /* display the game number */
- echo "<p class=\"gamenumber\"> Game $gameid </p>\n";
/* display rule set */
- echo "<div class=\"ruleset\">\n Rules: <br />";
+ echo "<div class=\"ruleset\">\n";
$result = mysql_query("SELECT * FROM Rulesets LEFT JOIN Game ON Game.ruleset=Rulesets.id WHERE Game.id='$gameid'" );
$r = mysql_fetch_array($result,MYSQL_NUM);
$RULES["dullen"]=$r[2];
$RULES["schweinchen"]=$r[3];
-
- echo "10ofhearts : ".$r[2]."<br />";
- echo "schweinchen: ".$r[3]."<br />";
+
+ /* get some infos about the game */
+ $gametype = DB_get_gametype_by_gameid($gameid);
+ $gamestatus = DB_get_game_status_by_gameid($gameid);
+ $GT = $gametype;
+ if($gametype=="solo")
+ {
+ $gametype = DB_get_solo_by_gameid($gameid);
+ $GT = $gametype." ".$GT;
+ }
+ else
+ $gametype="normal";
+
+ if($gamestatus != 'pre')
+ echo " Gametype: $GT <br />\n";
+
+ echo "Rules: <br />\n";
+ echo "10ofhearts : ".$r[2]."<br />\n";
+ echo "schweinchen: ".$r[3]."<br />\n";
echo "</div>\n";
/* does anyone have both foxes */
$GAME["schweinchen-who"]=$hash;
}
};
-
/* mystatus gets the player through the different stages of a game.
* start: yes/no
/* check what kind of game we are playing */
$gametype = DB_get_gametype_by_gameid($gameid);
$startplayer = DB_get_startplayer_by_gameid($gameid);
-
+
/* nines? */
$nines = 0;
/* check for nines */
/* delete everything from the dB */
DB_cancel_game($me);
+ output_footer();
exit();
}
{
/* only set this after all poverty, etc. are handled*/
DB_set_game_status_by_gameid($gameid,'play');
+
+ /* email startplayer */
+ $startplayer = DB_get_startplayer_by_gameid($gameid);
+ $email = DB_get_email_by_pos_and_gameid($startplayer,$gameid);
+ $hash = DB_get_hash_from_game_and_pos($gameid,$startplayer);
+
+ $message = "It's your turn now.\n".
+ "Use this link to play a card: ".$host."?me=".$hash."\n\n" ;
+ mymail($email,$EmailName."ready, set, go... ",$message);
}
break;
/* display useful things in divs */
- /* display local time */
- echo "<div class=\"time\">\n Local times:<table>";
- $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 "<tr> <td>$name</td> <td>".date("Y-m-d H:i:s")."</td></tr>\n";
- };
- echo "</table>\n</div>\n";
-
- if($gamestatus != 'pre')
- display_status($GT);
-
/* display links to the users status page */
$result = mysql_query("SELECT email,password from User WHERE id='$myid'" );
$r = mysql_fetch_array($result,MYSQL_NUM);
- output_link_to_user_page($r[0],$r[1]);
- display_news();
+ display_links($r[0],$r[1]);
/* end display useful things*/
/* display the table and the names */
$result = mysql_query("SELECT User.fullname as name,".
- " Hand.position as position ".
+ " Hand.position as position, ".
+ " User.id ".
"FROM Hand ".
"LEFT JOIN User ON User.id=Hand.user_id ".
"WHERE Hand.game_id='".$gameid."' ".
{
$name = $r[0];
$pos = $r[1];
-
- echo " <span class=\"table".($pos-1)."\">$name</span>\n";
+ $user = $r[2];
+
+ $offset = DB_get_user_timezone($user);
+ $zone = return_timezone($offset);
+ date_default_timezone_set($zone);
+
+ echo " <span class=\"table".($pos-1)."\">\n";
+ echo " $name <br />\n";
+ echo " local time: ".date("Y-m-d H:i:s")."\n";
+ echo " </span>\n";
+
}
echo "</div>\n";
-
+
/* get everything relevant to display the tricks */
$result = mysql_query("SELECT Hand_Card.card_id as card,".
" Hand.position as position,".
$firstcard = ""; /* first card in a trick */
echo "\n<ul class=\"tricks\">\n";
- echo " <li> Hello $myname! History: </li>\n";
+ echo " <li class=\"nohighlight\"> Game $gameid: </li>\n";
while($r = mysql_fetch_array($result,MYSQL_NUM))
{
if($trick!=$lasttrick)
{
/* start of an old trick? */
- echo " <li onclick=\"hl('$trickNR');\"><a href=\"#\">Trick $trickNR</a>\n".
+ echo " <li onclick=\"hl('$trickNR');\" class=\"old\"><a href=\"#\">Trick $trickNR</a>\n".
" <div class=\"trick\" id=\"trick".$trickNR."\">\n".
" <img class=\"arrow\" src=\"pics/arrow".($pos-1).".png\" alt=\"table\" />\n";
}
else if($trick==$lasttrick)
{
/* start of a last trick? */
- echo " <li onclick=\"hl('$trickNR');\"><a href=\"#\">Current Trick</a>\n".
+ echo " <li onclick=\"hl('$trickNR');\" class=\"current\"><a href=\"#\">Trick $trickNR</a>\n".
" <div class=\"trick\" id=\"trick".$trickNR."\">\n".
" <img class=\"arrow\" src=\"pics/arrow".($pos-1).".png\" alt=\"table\" />\n";
};
/* mark card as played */
mysql_query("UPDATE Hand_Card SET played='true' WHERE hand_id='$handid' AND card_id=".
DB_quote_smart($card));
-
+ /* update Game timestamp */
+ DB_update_game_timestamp($gameid);
+
/* check for schweinchen */
- echo "schweinchen = ".$GAME["schweinchen"]." --$card-<br />";
+ //echo "schweinchen = ".$GAME["schweinchen"]." --$card-<br />";
if($card == 19 || $card == 20 )
{
$GAME["schweinchen"]++;
default:
echo "error in testing the status";
}
+ output_footer();
exit();
}
/* user status page */
/* 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_and_password($email,$password);
- if(!$uid)
- $ok=0;
-
- if($ok)
+
+ if(myisset("forgot"))
{
- $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)."<br />";
-
- DB_update_user_timestamp($uid);
+ $ok=1;
+
+ $uid = DB_get_userid_by_email($email);
+ if(!$uid)
+ $ok=0;
- echo "<p>these are the games you are playing in:<br />\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))
+ if($ok)
{
- echo "<a href=\"".$host."?me=".$r[0]."\">game #".$r[1]." </a>";
- 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? <a href=\"$host?cancle=1&me=".$r[0]."\">yes</a>".
- " (clicking here is final and can't be restored)";
- echo "<br />";
+ echo "Hmm, you forgot your passwort...nothing I can do at the moment:( ";
+ echo " you need to email Arun for now... in the future it will be all automated and an ";
+ echo "email with a new password will go to $email.";
}
- echo "</p>\n";
-
-
- echo "<p>and these are your games that are already done:<br />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 "<a href=\"".$host."?me=".$r[0]."\">#".$r[1]." </a>, ";
- echo "</p>\n";
-
- $names = DB_get_all_names();
- echo "<p>registered players:<br />\n";
- foreach ($names as $name)
- echo "$name, \n";
- echo "</p>\n";
-
- echo "<p>Want to start a new game? Visit <a href=\"".$host."?new\">this page.</a></p>";
- }
- else
- {
- echo "sorry email and password don't match <br />";
+ else
+ {
+ if($email=="")
+ echo "you need to give me an email address!";
+ else
+ echo "couldn't find a player with this email, please contact Arun, if you think this is a mistake";
+ }
}
+ else
+ {
+ 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)."<br />";
+
+ DB_update_user_timestamp($uid);
+
+ echo "<p>these are the games you are playing in:<br />\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 "<a href=\"".$host."?me=".$r[0]."\">game #".$r[1]." </a>";
+ 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? <a href=\"$host?cancle=1&me=".$r[0]."\">yes</a>".
+ " (clicking here is final and can't be restored)";
+ echo "<br />";
+ }
+ echo "</p>\n";
+
+
+ echo "<p>and these are your games that are already done:<br />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 "<a href=\"".$host."?me=".$r[0]."\">#".$r[1]." </a>, ";
+ echo "</p>\n";
+
+ $names = DB_get_all_names();
+ echo "<p>registered players:<br />\n";
+ foreach ($names as $name)
+ echo "$name, \n";
+ echo "</p>\n";
+
+ echo "<p>Want to start a new game? Visit <a href=\"".$host."?new\">this page.</a></p>";
+ }
+ else
+ {
+ echo "sorry email and password don't match <br />";
+ }
+ };
+ output_footer();
exit();
}
/* page for registration */
/* default login page */
else
{
- output_home_page();
+ $pre=0;$game=0;$done=0;
+ $r=mysql_query("SELECT COUNT(id) FROM Game GROUP BY status");
+ if($r) {
+ $pre = mysql_fetch_array($r,MYSQL_NUM);
+ $game = mysql_fetch_array($r,MYSQL_NUM);
+ $done = mysql_fetch_array($r,MYSQL_NUM);
+ }
+ output_home_page($pre[0],$game[0],$done[0]);
}
output_footer();