LAYOUT: last login and logout text where displayed incorrectly sometimes
authorArun Persaud <arun@nubati.net>
Sun, 16 Dec 2007 22:50:35 +0000 (23:50 +0100)
committerArun Persaud <arun@nubati.net>
Sun, 16 Dec 2007 22:57:06 +0000 (23:57 +0100)
in a previous commit I moved those tings to the output_header function.
Turns out you can't do that, so here is the fix.

db.php
index.php
output.php
stats.php

diff --git a/db.php b/db.php
index 54f57066f2981b4b907c5fdc5b769defc68f9c00..39ab45c5c3b563aec2f7cf7d6c336522ee1cee11 100644 (file)
--- a/db.php
+++ b/db.php
@@ -609,7 +609,7 @@ function DB_get_user_timezone($userid)
   if($r)
     return $r[0];
   else
-    return 0;
+    return "Europe/London";
 }
 
 function DB_insert_comment($comment,$playid,$userid)
index 6584f0e5b9b229199b18f03b1160a6880b7ea304..de6cdfe5b415f2cd6a942cfc469ec235ea15934c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -34,6 +34,7 @@ if(myisset("logout"))
   }
 else if(myisset("new"))
   {
+    output_status();
     if( isset($_SESSION["name"]) )
       {
        $names = DB_get_all_names();
@@ -188,11 +189,14 @@ else if(myisset("new"))
     mymail($EmailC,"You are invited to a game of DoKo","Hello $PlayerC,\n".$message.$hashC);
     mymail($EmailD,"You are invited to a game of DoKo","Hello $PlayerD,\n".$message.$hashD);
 
-    echo "You started a new game. The emails have been sent out!";
+    output_status();
+    echo "<div class=\"message\">You started a new game. The emails have been sent out!</div>\n";
   }    /* end set up a new game */
 /* cancle a game, if nothing has happend in the last N minutes */
 else if(myisset("cancle","me"))
   {
+    output_status();
+
     $me = $_REQUEST["me"];
 
     /* test for valid ID */
@@ -240,6 +244,8 @@ else if(myisset("cancle","me"))
 /* send out a reminder */
 else if(myisset("remind","me"))
   {
+    output_status();
+
     $me = $_REQUEST["me"];
 
     /* test for valid ID */
@@ -307,6 +313,8 @@ else if(myisset("me"))
        exit();
       }
 
+    output_status();
+
     if(isset($_SESSION["name"]))
       output_status($_SESSION["name"]);
 
@@ -1108,7 +1116,8 @@ else if(myisset("me"))
       $r       = mysql_fetch_array($result,MYSQL_NUM);
       $gameend = time() - strtotime($r[0]);
 
-      /* handel comments in case player didn't play a card, allow comments a week after the end of the game */      if( (!myisset("card") && $mystatus=='play') || ($mystatus=='gameover' && ($gameend < 60*60*24*7)) )
+      /* handel comments in case player didn't play a card, allow comments a week after the end of the game */
+      if( (!myisset("card") && $mystatus=='play') || ($mystatus=='gameover' && ($gameend < 60*60*24*7)) )
        if(myisset("comment"))
          {
            $comment = $_REQUEST["comment"];
@@ -1980,6 +1989,10 @@ else if( myisset("email","password") || isset($_SESSION["name"]) )
 
        if($ok)
         {
+          $myname = DB_get_name_by_email($email);
+          $_SESSION["name"] = $myname;
+          output_status();
+
           DB_get_PREF($myid);
 
           if(myisset("setpref"))
@@ -2052,9 +2065,6 @@ else if( myisset("email","password") || isset($_SESSION["name"]) )
             }
           else /* output default user page */
             {
-              $myname = DB_get_name_by_email($email);
-              $_SESSION["name"] = $myname;
-
               /* display links to settings */
               output_user_settings();
 
index 29fd8f3bb58283dde836eb87654ac572a10b0974..5d84d46c50f227d7b41690e665c16c1df13db5dc 100644 (file)
@@ -334,26 +334,6 @@ function output_header()
 <h1> Welcome to E-Doko <sup style="color:#888;">(beta)</sup> </h1>
 </div>
 <?php
-   if(isset($_SESSION["name"]))
-     {
-       $name = $_SESSION["name"];
-
-       /* logout info */
-       echo "<div class=\"status\">\n";
-       echo $name;
-       echo " <a href=\"index.php?logout=1\">logout</a>\n";
-       echo "</div>";
-
-       /* last logon time */
-       $myid   = DB_get_userid_by_name($name);
-       $zone   = DB_get_user_timezone($myid);
-       date_default_timezone_set($zone);
-
-       $time     = DB_get_user_timestamp($myid);
-       $unixtime = strtotime($time);
-
-       echo "<div class=\"lastlogin\">last login: ".date("r",$unixtime)."</div>";
-     };
 
   echo "<div class=\"main\">";
   return;
@@ -384,9 +364,28 @@ function output_footer()
   return;
 }
 
-function output_status($name)
+function output_status()
 {
+   if(isset($_SESSION["name"]))
+     {
+       $name = $_SESSION["name"];
+
+       /* logout info */
+       echo "<div class=\"status\">\n";
+       echo $name;
+       echo " <a href=\"index.php?logout=1\">logout</a>\n";
+       echo "</div>";
 
+       /* last logon time */
+       $myid  = DB_get_userid_by_name($name);
+       $zone  = DB_get_user_timezone($myid);
+       date_default_timezone_set($zone);
+
+       $time     = DB_get_user_timestamp($myid);
+       $unixtime = strtotime($time);
+
+       echo "<div class=\"lastlogin\">last login: ".date("r",$unixtime)."</div>";
+     };
   return;
 }
 
index 68a09afbb6953156f4b23cb9a68015e217d67b93..bab9823aa163c4114c527c60226dd13b96b8beb1 100644 (file)
--- a/stats.php
+++ b/stats.php
@@ -38,7 +38,6 @@ else if( isset($_SESSION["name"]) )
      $email     = DB_get_email_by_name($name);
      $password  = DB_get_passwd_by_name($name);
 
-
      /* verify password and email */
      if(strlen($password)!=32)
        $password = md5($password);
@@ -50,6 +49,8 @@ else if( isset($_SESSION["name"]) )
 
      if($ok)
        {
+        output_status();
+
         DB_get_PREF($myid);
 
         DB_update_user_timestamp($myid);