summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/cancelgame.php8
-rw-r--r--include/game.php24
-rw-r--r--include/newgame.php21
-rw-r--r--include/output.php8
-rw-r--r--include/preferences.php6
-rw-r--r--include/reminder.php10
-rw-r--r--include/stats.php2
-rw-r--r--include/user.php216
8 files changed, 125 insertions, 170 deletions
diff --git a/include/cancelgame.php b/include/cancelgame.php
index 5b85534..43d3274 100644
--- a/include/cancelgame.php
+++ b/include/cancelgame.php
@@ -10,9 +10,7 @@ output_status();
if(!myisset("me"))
{
echo "Hmm, you really shouldn't mess with the urls.<br />\n";
- output_footer();
- DB_close();
- exit();
+ return;
}
$me = $_REQUEST["me"];
@@ -23,9 +21,7 @@ if(!$myid)
{
echo "Can't find you in the database, please check the url.<br />\n";
echo "perhaps the game has been canceled, check by login in <a href=\"$INDEX\">here</a>.";
- output_footer();
- DB_close();
- exit();
+ return;
}
DB_update_user_timestamp($myid);
diff --git a/include/game.php b/include/game.php
index 0350d9e..25e2b2f 100644
--- a/include/game.php
+++ b/include/game.php
@@ -9,9 +9,7 @@ if(!isset($HOST))
if(!myisset("me"))
{
echo "Hmm, you really shouldn't mess with the urls.<br />\n";
- output_footer();
- DB_close();
- exit();
+ return;
}
$me = $_REQUEST["me"];
@@ -21,17 +19,11 @@ if(!$myid)
{
echo "Can't find you in the database, please check the url.<br />\n";
echo "perhaps the game has been canceled, check by login in <a href=\"$INDEX\">here</a>.";
- output_footer();
- DB_close();
- exit();
+ return;
}
global $GAME,$RULES,$CARDS;
-/* user might get here by clicking on the link in an email, so session might not be set */
-if(isset($_SESSION["name"]))
- output_status($_SESSION["name"]);
-
/* the user has done something, update the timestamp */
DB_update_user_timestamp($myid);
@@ -501,9 +493,7 @@ switch($mystatus)
echo "The game has been canceled because ".DB_get_name('userid',$nines).
" has five or more nines and nobody is playing solo.\n";
- output_footer();
- DB_close();
- exit();
+ return;
}
else if($poverty==1) /* one person has poverty */
{
@@ -832,9 +822,7 @@ switch($mystatus)
DB_cancel_game($me);
echo "<p style=\"background-color:red\";>Game ".DB_format_gameid($gameid)." has been canceled.<br /><br /></p>";
- output_footer();
- DB_close();
- exit();
+ return;
}
else
{
@@ -1894,8 +1882,4 @@ switch($mystatus)
output_ask_for_new_game($names[1],$names[2],$names[3],$names[0],$gameid);
}
}
-
- output_footer();
- DB_close();
- exit();
?> \ No newline at end of file
diff --git a/include/newgame.php b/include/newgame.php
index feb5216..db6b62d 100644
--- a/include/newgame.php
+++ b/include/newgame.php
@@ -20,7 +20,6 @@ else
return;
DB_update_user_timestamp($myid);
- output_status();
if( !myisset("PlayerA", "PlayerB","PlayerC","PlayerD","dullen","schweinchen","callrule" ))
{
@@ -45,9 +44,7 @@ else
if(!in_array($name,array($PlayerA,$PlayerB,$PlayerC,$PlayerD)))
{
echo "<div class=\"message\">You need to be one of the players to start a <a href=\"$INDEX?action=new\">new game</a>.</div>";
- output_footer();
- DB_close();
- exit();
+ return;
}
/* what rules were selected */
@@ -65,9 +62,7 @@ else
if($EmailA=="" || $EmailB=="" || $EmailC=="" || $EmailD=="")
{
echo "couldn't find one of the names, please start a new game";
- output_footer();
- DB_close();
- exit();
+ return;
}
/* get user ids */
@@ -94,16 +89,12 @@ else
if( DB_is_session_active($session) > 0 )
{
echo "<p class=\"message\"> There is already a game going on in session $session, you can't start a new one</p>";
- output_footer();
- DB_close();
- exit();
+ return;
}
else if ( DB_is_session_active($session) < 0 )
{
echo "<p class=\"message\"> ERROR: status of session $session couldn't be determined.</p>";
- output_footer();
- DB_close();
- exit();
+ return;
}
if($session)
@@ -126,9 +117,7 @@ else
if($ruleset <0)
{
myerror("Error defining ruleset: $ruleset");
- output_footer();
- DB_close();
- exit();
+ return;
};
/* get max session */
$max = DB_get_max_session();
diff --git a/include/output.php b/include/output.php
index 2f846be..81f01c5 100644
--- a/include/output.php
+++ b/include/output.php
@@ -372,7 +372,13 @@ function output_status()
date_default_timezone_set($zone);
echo "<div class=\"lastlogin\">last login: ".date("r",$unixtime)."</div>\n";
- };
+ }
+ else
+ {
+ echo "\n<div class=\"status\">\n";
+ echo "<a href=\"".$INDEX."\">login</a>\n";
+ echo "</div>\n";
+ }
return;
}
diff --git a/include/preferences.php b/include/preferences.php
index 8a6050d..0382193 100644
--- a/include/preferences.php
+++ b/include/preferences.php
@@ -18,7 +18,6 @@ $changed_cards = 0;
$changed_timezone = 0;
$changed_autosetup = 0;
-output_status();
display_user_menu();
/* get old infos */
@@ -206,8 +205,5 @@ echo " </table>\n";
echo " </form>\n";
echo "</div>\n";
-output_footer();
-DB_close();
-exit();
-
+return;
?> \ No newline at end of file
diff --git a/include/reminder.php b/include/reminder.php
index 8844e48..9c297cd 100644
--- a/include/reminder.php
+++ b/include/reminder.php
@@ -5,14 +5,10 @@
if(!isset($HOST))
exit;
-output_status();
-
if(!myisset("me"))
{
echo "Hmm, you really shouldn't mess with the urls.<br />\n";
- output_footer();
- DB_close();
- exit();
+ return;
}
$me = $_REQUEST["me"];
@@ -23,9 +19,7 @@ if(!$myid)
{
echo "Can't find you in the database, please check the url.<br />\n";
echo "perhaps the game has been canceled, check by login in <a href=\"$INDEX\">here</a>.";
- output_footer();
- DB_close();
- exit();
+ return;
}
DB_update_user_timestamp($myid);
diff --git a/include/stats.php b/include/stats.php
index cff6a84..97e1979 100644
--- a/include/stats.php
+++ b/include/stats.php
@@ -12,8 +12,6 @@ $myid = DB_get_userid('email',$email);
if(!$myid)
return;
-output_status();
-
$PREF = DB_get_PREF($myid);
DB_update_user_timestamp($myid);
diff --git a/include/user.php b/include/user.php
index 7b4880d..19eb27b 100644
--- a/include/user.php
+++ b/include/user.php
@@ -6,17 +6,17 @@ if(!isset($HOST))
exit;
/* test id and password, should really be done in one step */
-if(!isset($_SESSION["name"]))
+if(!isset($_SESSION["name"]))
{
$email = $_REQUEST["email"];
$password = $_REQUEST["password"];
}
- else
- {
- $name = $_SESSION["name"];
- $email = DB_get_email('name',$name);
- $password = DB_get_passwd_by_name($name);
- };
+else
+ {
+ $name = $_SESSION["name"];
+ $email = DB_get_email('name',$name);
+ $password = DB_get_passwd_by_name($name);
+ };
/* user has forgotten his password */
if(myisset("forgot"))
@@ -81,111 +81,103 @@ if(myisset("forgot"))
"or else try <a href=\"$INDEX\">again</a>.";
}
}
- else
- { /* normal user page */
-
- /* verify password and email */
- if(strlen($password)!=32)
- $password = md5($password);
-
- $ok = 1;
- $myid = DB_get_userid('email-password',$email,$password);
- if(!$myid)
- $ok = 0;
-
- if($ok)
- {
- /* user information is ok */
- $myname = DB_get_name('email',$email);
- $_SESSION["name"] = $myname;
- output_status();
+else
+ { /* normal user page */
- $PREF = DB_get_PREF($myid);
+ /* verify password and email */
+ if(strlen($password)!=32)
+ $password = md5($password);
- DB_update_user_timestamp($myid);
-
- display_user_menu();
-
- /* display all games the user has played */
- echo "<div class=\"user\">";
- echo "<h4>These are all your games:</h4>\n";
- echo "<p>Session: <br />\n";
- echo "<span class=\"gamestatuspre\"> p </span> = pre-game phase ";
- echo "<span class=\"gamestatusplay\">P </span> = game in progess ";
- echo "<span class=\"gamestatusover\">F </span> = game finished <br />";
- echo "</p>\n";
-
- $output = array();
- $result = DB_query("SELECT Hand.hash,Hand.game_id,Game.mod_date,Game.player,Game.status from Hand".
- " LEFT JOIN Game ON Game.id=Hand.game_id".
- " WHERE user_id='$myid'".
- " ORDER BY Game.session,Game.create_date" );
- $gamenrold = -1;
- echo "<table>\n <tr><td>\n";
- while( $r = DB_fetch_array($result))
- {
- $game = DB_format_gameid($r[1]);
- $gamenr = (int) $game;
- if($gamenrold < $gamenr)
- {
- if($gamenrold!=-1)
- echo "</td></tr>\n <tr> <td>$gamenr:</td>\n";
- else
- echo "$gamenr:</td>\n";
- $gamenrold = $gamenr;
- echo "<td class=\"usergames\">\n";
- }
- if($r[4]=='pre')
- echo "\n <span class=\"gamestatuspre\"><a href=\"".$INDEX."?action=game&amp;me=".$r[0]."\">p </a></span> ";
- else if ($r[4]=='gameover')
- echo "\n <span class=\"gamestatusover\"><a href=\"".$INDEX."?action=game&amp;me=".$r[0]."\">F </a></span> ";
- else
- echo "\n <span class=\"gamestatusplay\"><a href=\"".$INDEX."?action=game&amp;me=".$r[0]."\">P </a></span> ";
- if($r[4] != 'gameover')
- {
- echo "</td>\n<td>\n ";
- if($r[3]==$myid || !$r[3])
- echo "(it's <strong>your</strong> turn)\n";
- else
- {
- $name = DB_get_name('userid',$r[3]);
- $gameid = $r[1];
- if(DB_get_reminder($r[3],$gameid)==0)
- if(time()-strtotime($r[2]) > 60*60*24*7)
- echo "".
- "<a href=\"$INDEX?action=reminder&amp;me=".$r[0]."\">Send a reminder.</a>";
- echo "(it's $name's turn)\n";
- };
- if(time()-strtotime($r[2]) > 60*60*24*30)
- echo "".
- "<a href=\"$INDEX?action=cancel&amp;me=".$r[0]."\">Cancel?</a>".
- " (clicking here is final and can't be restored)";
-
- }
- }
- echo "</td></tr>\n</table>\n";
-
- /* display last 5 users that have signed up to e-DoKo */
- $names = DB_get_names_of_new_logins(5);
- echo "<h4>New Players:</h4>\n<p>\n";
- echo implode(", ",$names).",...\n";
- echo "</p>\n";
-
- /* display last 5 users that logged on */
- $names = DB_get_names_of_last_logins(5);
- echo "<h4>Players last logged in:</h4>\n<p>\n";
- echo implode(", ",$names).",...\n";
- echo "</p>\n";
-
- echo "</div>\n";
- }
- else
- {
- echo "<div class=\"message\">Sorry email and password don't match. Please <a href=\"$INDEX\">try again</a>. </div>";
- }
- };
-output_footer();
-DB_close();
-exit();
-
+ $ok = 1;
+ $myid = DB_get_userid('email-password',$email,$password);
+ if(!$myid)
+ $ok = 0;
+
+ if($ok)
+ {
+ /* user information is ok */
+ $myname = DB_get_name('email',$email);
+ $_SESSION["name"] = $myname;
+
+ $PREF = DB_get_PREF($myid);
+
+ DB_update_user_timestamp($myid);
+
+ display_user_menu();
+
+ /* display all games the user has played */
+ echo "<div class=\"user\">";
+ echo "<h4>These are all your games:</h4>\n";
+ echo "<p>Session: <br />\n";
+ echo "<span class=\"gamestatuspre\"> p </span> = pre-game phase ";
+ echo "<span class=\"gamestatusplay\">P </span> = game in progess ";
+ echo "<span class=\"gamestatusover\">F </span> = game finished <br />";
+ echo "</p>\n";
+
+ $output = array();
+ $result = DB_query("SELECT Hand.hash,Hand.game_id,Game.mod_date,Game.player,Game.status from Hand".
+ " LEFT JOIN Game ON Game.id=Hand.game_id".
+ " WHERE user_id='$myid'".
+ " ORDER BY Game.session,Game.create_date" );
+ $gamenrold = -1;
+ echo "<table>\n <tr><td>\n";
+ while( $r = DB_fetch_array($result))
+ {
+ $game = DB_format_gameid($r[1]);
+ $gamenr = (int) $game;
+ if($gamenrold < $gamenr)
+ {
+ if($gamenrold!=-1)
+ echo "</td></tr>\n <tr> <td>$gamenr:</td>\n";
+ else
+ echo "$gamenr:</td>\n";
+ $gamenrold = $gamenr;
+ echo "<td class=\"usergames\">\n";
+ }
+ if($r[4]=='pre')
+ echo " <span class=\"gamestatuspre\"><a href=\"".$INDEX."?action=game&amp;me=".$r[0]."\">p </a></span>\n";
+ else if ($r[4]=='gameover')
+ echo " <span class=\"gamestatusover\"><a href=\"".$INDEX."?action=game&amp;me=".$r[0]."\">F </a></span>\n";
+ else
+ echo " <span class=\"gamestatusplay\"><a href=\"".$INDEX."?action=game&amp;me=".$r[0]."\">P </a></span>\n";
+ if($r[4] != 'gameover')
+ {
+ echo "</td>\n<td>\n ";
+ if($r[3]==$myid || !$r[3])
+ echo "(it's <strong>your</strong> turn)\n";
+ else
+ {
+ $name = DB_get_name('userid',$r[3]);
+ $gameid = $r[1];
+ if(DB_get_reminder($r[3],$gameid)==0)
+ if(time()-strtotime($r[2]) > 60*60*24*7)
+ echo "<a href=\"$INDEX?action=reminder&amp;me=".$r[0]."\">Send a reminder.</a>";
+ echo "(it's $name's turn)\n";
+ };
+ if(time()-strtotime($r[2]) > 60*60*24*30)
+ echo "<a href=\"$INDEX?action=cancel&amp;me=".$r[0]."\">Cancel?</a>".
+ " (clicking here is final and can't be restored)";
+ }
+ }
+ echo "</td></tr>\n</table>\n";
+
+ /* display last 5 users that have signed up to e-DoKo */
+ $names = DB_get_names_of_new_logins(5);
+ echo "<h4>New Players:</h4>\n<p>\n";
+ echo implode(", ",$names).",...\n";
+ echo "</p>\n";
+
+ /* display last 5 users that logged on */
+ $names = DB_get_names_of_last_logins(5);
+ echo "<h4>Players last logged in:</h4>\n<p>\n";
+ echo implode(", ",$names).",...\n";
+ echo "</p>\n";
+
+ echo "</div>\n";
+ }
+ else
+ {
+ echo "<div class=\"message\">Sorry email and password don't match. Please <a href=\"$INDEX\">try again</a>. </div>";
+ }
+ };
?> \ No newline at end of file