summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--db.php27
-rw-r--r--functions.php12
-rw-r--r--index.php69
-rw-r--r--output.php11
4 files changed, 101 insertions, 18 deletions
diff --git a/db.php b/db.php
index 98e7724..64a80b9 100644
--- a/db.php
+++ b/db.php
@@ -704,5 +704,32 @@ function DB_set_party_by_hash($hash,$party)
return;
}
+function DB_get_PREF($myid)
+{
+ global $PREF;
+
+ $result = mysql_query("SELECT value from User_Prefs".
+ " WHERE user_id='$myid' AND pref_key='cardset'" );
+ $r = mysql_fetch_array($result,MYSQL_NUM);
+ if($r)
+ {
+ if($r[0]=="germancards" && (time()-strtotime( "2009-12-31 23:59:59")<0) ) /* licence only valid until then */
+ $PREF["cardset"]="altenburg";
+ else
+ $PREF["cardset"]="english";
+ }
+ else
+ $PREF["cardset"]="english";
+
+ $result = mysql_query("SELECT value from User_Prefs".
+ " WHERE user_id='$myid' AND pref_key='ccemail'" );
+ $r = mysql_fetch_array($result,MYSQL_NUM);
+ if($r)
+ $PREF["ccemail"]=$r[0];
+ else
+ $PREF["ccemail"]="no";
+
+ return;
+}
?> \ No newline at end of file
diff --git a/functions.php b/functions.php
index 75f1fed..f33dd1c 100644
--- a/functions.php
+++ b/functions.php
@@ -1,6 +1,6 @@
<?php
-function mymail($To,$Subject,$message)
+function mymail($To,$Subject,$message,$header="")
{
global $debug;
@@ -11,10 +11,16 @@ function mymail($To,$Subject,$message)
"<a href=\"\\0\">\\0</a>", $message);
//$message = ereg_replace("(http.*)[ <>]","<a href=\"\\1\">\\1 </a>",$message);
- echo "<br />To: $To<br />Subject: $Subject <br />$message<br />\n";
+ echo "<br />To: $To<br />";
+ if($header != "")
+ echo $header."<br />";
+ echo "Subject: $Subject <br />$message<br />\n";
}
else
- mail($To,$Subject,$message);
+ if($header != "")
+ mail($To,$Subject,$message,$header);
+ else
+ mail($To,$Subject,$message);
return;
}
diff --git a/index.php b/index.php
index 0620502..e8fffb7 100644
--- a/index.php
+++ b/index.php
@@ -230,18 +230,8 @@ else if(myisset("me"))
$myhand = DB_get_handid_by_hash($me);
/* get prefs and save them */
- $result = mysql_query("SELECT value from User_Prefs".
- " WHERE user_id='$myid' AND pref_key='cardset'" );
- $r = mysql_fetch_array($result,MYSQL_NUM);
- if($r)
- {
- if($r[0]=="germancards" && (time()-strtotime( "2009-12-31 23:59:59")<0) ) /* licence only valid until then */
- $PREF["cardset"]="altenburg";
- else
- $PREF["cardset"]="english";
- }
- else
- $PREF["cardset"]="english";
+ DB_get_PREF($myid);
+ /* end set pref */
/* get rule set for this game */
@@ -1312,11 +1302,27 @@ else if(myisset("me"))
$message .= "\n";
while( $r = mysql_fetch_array($result,MYSQL_NUM))
$message .= " FINAL SCORE: ".$r[0]." ".$r[1]."\n";
+
+ /* check who wants to be CC'ed on the email */
+ $h = array();
+ $header = "";
+ foreach($userids as $user)
+ {
+ $result = mysql_query("SELECT value from User_Prefs".
+ " WHERE user_id='$user' AND pref_key='ccemail'" );
+ $r = mysql_fetch_array($result,MYSQL_NUM);
+ if($r && $r[0]=="yes")
+ $h[] = DB_get_email_by_userid($user);
+ }
+ if(sizeof($h))
+ $header = "CC: ".join(",",$h)."\r\n";
foreach($userids as $user)
{
- $To = DB_get_email_by_userid($user);
- mymail($To,$EmailName."game over (game $gameid)",$message);
+ $To = DB_get_email_by_userid($user);
+ $hash = DB_get_hash_from_gameid_and_userid($gameid,$user)
+ $mymessage = $message."Use this link to have a look at the game: ".$host."?me=".$hash."\n\n" ;
+ mymail($To,$EmailName."game over (game $gameid)",$mymessage,$header);
}
}
@@ -1492,6 +1498,7 @@ else if(myisset("me"))
/* test id and password, should really be done in one step */
$email = $_REQUEST["email"];
$password = $_REQUEST["password"];
+
if(myisset("forgot"))
{
@@ -1528,6 +1535,8 @@ else if(myisset("me"))
if($ok)
{
+ DB_get_PREF($uid);
+
if(myisset("setpref"))
{
$setpref=$_REQUEST["setpref"];
@@ -1544,6 +1553,21 @@ else if(myisset("me"))
$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;
+ case "ccemail":
+ $result = mysql_query("SELECT * from User_Prefs".
+ " WHERE user_id='$uid' AND pref_key='ccemail'" );
+ if( mysql_fetch_array($result,MYSQL_NUM))
+ if($PREF["ccemail"]=="yes")
+ $result = mysql_query("UPDATE User_Prefs SET value=".DB_quote_smart("no").
+ " WHERE user_id='$uid' AND pref_key='ccemail'" );
+ else
+ $result = mysql_query("UPDATE User_Prefs SET value=".DB_quote_smart("yes").
+ " WHERE user_id='$uid' AND pref_key='ccemail'" );
+ else
+ $result = mysql_query("INSERT INTO User_Prefs VALUES(NULL,'$uid','ccemail',".DB_quote_smart("yes").")");
+ echo "Ok, changed you preferences for being CC'ed on emails.\n";
+ break;
+
}
}
else /* output default user page */
@@ -1562,10 +1586,25 @@ else if(myisset("me"))
DB_update_user_timestamp($uid);
+ echo "<p>these are your games that haven't started yet:<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='pre'" );
+ 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>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'" );
+ " WHERE Hand.user_id='$uid' AND Game.status='play'" );
while( $r = mysql_fetch_array($result,MYSQL_NUM))
{
echo "<a href=\"".$host."?me=".$r[0]."\">game #".$r[1]." </a>";
diff --git a/output.php b/output.php
index a224d6f..8288ee2 100644
--- a/output.php
+++ b/output.php
@@ -27,6 +27,8 @@ function output_link_to_user_page($email,$password)
function output_user_settings($email,$password)
{
+ global $PREF;
+
echo "<div class=\"useroptions\">\n";
echo "<h4> Settings </h4>\n";
echo "<form action=\"index.php\" method=\"post\">\n";
@@ -46,6 +48,15 @@ function output_user_settings($email,$password)
echo " <input type=\"hidden\" name=\"setpref\" value=\"germancards\" />\n";
echo " <input type=\"submit\" class=\"submitbutton\" value=\"use german cards\" /> <br />\n";
echo "</form>\n";
+ 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=\"hidden\" name=\"setpref\" value=\"ccemail\" />\n";
+ if($PREF["ccemail"]=="no")
+ echo " <input type=\"submit\" class=\"submitbutton\" value=\"CC me on final email\" /> <br />\n";
+ else
+ echo " <input type=\"submit\" class=\"submitbutton\" value=\"don't CC me on final email\" /> <br />\n";
+ echo "</form>\n";
echo "</div>\n";
return;
}