summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--css/standard.css14
-rw-r--r--db.php26
-rw-r--r--index.php138
-rw-r--r--output.php6
4 files changed, 129 insertions, 55 deletions
diff --git a/css/standard.css b/css/standard.css
index 704610c..c1ec28b 100644
--- a/css/standard.css
+++ b/css/standard.css
@@ -252,4 +252,18 @@ ul.tricks li div div.card3 span{
border:2px solid gray;
padding-top:0.5em;
clear:left;
+}
+
+.over {
+ text-align:center;
+ margin-bottom:0.1em;
+}
+
+.submitbutton {
+ border:0;
+ background-color: #efe;
+ }
+
+.submitbutton:hover {
+background-color:#afa;
} \ No newline at end of file
diff --git a/db.php b/db.php
index b3651bd..7b6ba17 100644
--- a/db.php
+++ b/db.php
@@ -70,6 +70,21 @@ function DB_get_email_by_userid($id)
return "";
}
+function DB_get_email_by_pos_and_gameid($pos,$gameid)
+{
+ $result = mysql_query("SELECT email FROM User ".
+ "LEFT JOIN Hand ON User.id=Hand.user_id ".
+ "LEFT JOIN Game ON Game.id=Hand.game_id ".
+ "WHERE Game.id=".DB_quote_smart($gameid)." ".
+ "AND Hand.position=".DB_quote_smart($pos)."");
+ $r = mysql_fetch_array($result,MYSQL_NUM);
+
+ if($r)
+ return $r[0];
+ else
+ return "";
+}
+
function DB_get_email_by_hash($hash)
{
$result = mysql_query("SELECT User.email FROM User LEFT JOIN Hand ON Hand.user_id=User.id WHERE Hand.hash=".DB_quote_smart($hash)."");
@@ -179,6 +194,17 @@ function DB_get_name_by_hash($hash)
return "";
}
+function DB_get_name_by_email($email)
+{
+ $result = mysql_query("SELECT fullname FROM User WHERE email=".DB_quote_smart($email));
+ $r = mysql_fetch_array($result,MYSQL_NUM);
+
+ if($r)
+ return $r[0];
+ else
+ return "";
+}
+
function DB_get_name_by_userid($id)
{
$result = mysql_query("SELECT fullname FROM User WHERE id=".DB_quote_smart($id));
diff --git a/index.php b/index.php
index a0029f0..58afe8d 100644
--- a/index.php
+++ b/index.php
@@ -406,7 +406,7 @@ else if(myisset("me"))
/* 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 */
@@ -588,6 +588,15 @@ else if(myisset("me"))
{
/* 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;
@@ -1049,62 +1058,87 @@ else if(myisset("me"))
/* 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&amp;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&amp;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();
}
diff --git a/output.php b/output.php
index 3ff0442..a85c2bb 100644
--- a/output.php
+++ b/output.php
@@ -18,7 +18,7 @@ function output_link_to_user_page($email,$password)
echo "<form action=\"index.php\" method=\"post\">\n";
echo " <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
echo " <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
- echo " <input type=\"submit\" value=\"go to my user page\" />\n";
+ echo " <input type=\"submit\" class=\"submitbutton\" value=\"go to my user page\" />\n";
echo "</form>\n";
echo "</div>\n";
@@ -258,8 +258,8 @@ function output_home_page($pre,$game,$done)
<td><label for="password">Password:</label></td>
<td><input type="password" id="password" name="password" size="20" maxlength="30" /></td>
</tr><tr>
- <td> <input type="submit" value="login" /></td>
- <td></td>
+ <td> <input type="submit" class="submitbutton" name="login" value="login" /></td>
+ <td> <input type="submit" class="submitbutton" name="forgot" value="Forgot your password?" /></td>
</tr>
</table>
</fieldset>