LAYOUT: last login and logout text where displayed incorrectly sometimes
[e-DoKo.git] / functions.php
index 69e208c0e7d1b1deb328d819ff1e15d76a0a9288..c835f89897906c6f188690f70bacb022bcc5bf1f 100644 (file)
@@ -390,26 +390,6 @@ function display_cards($me,$myturn)
   return;
 }
 
-function return_timezone($offset)
-{
-  switch($offset)
-    {
-    case '1':
-      $zone = "Europe/Berlin";
-      break;
-    case '-8':
-      $zone = "America/Vancouver";
-      break;
-    case '13':
-      $zone = "Pacific/Auckland";
-      break;
-    default:
-      $zone = "Europe/London";
-    }
-
-  return $zone;
-}
-
 function have_suit($cards,$c)
 {
   global $CARDS;
@@ -669,14 +649,15 @@ function display_table ()
                        "        Hand.sickness as sickness, ".
                        "        Hand.point_call, ".
                        "        User.last_login, ".
-                       "        Hand.hash        ".
+                       "        Hand.hash,       ".
+                       "        User.timezone    ".
                        "FROM Hand ".
                        "LEFT JOIN User ON User.id=Hand.user_id ".
                        "WHERE Hand.game_id='".$gameid."' ".
                        "ORDER BY position ASC");
 
   echo "<div class=\"table\">\n".
-    "  <img src=\"pics/table.png\" alt=\"table\" />\n";
+    "  <img class=\"table\" src=\"pics/table.png\" alt=\"table\" />\n";
   while($r = mysql_fetch_array($result,MYSQL_NUM))
     {
       $name  = $r[0];
@@ -685,12 +666,12 @@ function display_table ()
       $party = $r[3];
       $sickness  = $r[4];
       $call      = $r[5];
-      $lastlogin = strtotime($r[6]);
       $hash      = $r[7];
+      $timezone  = $r[8];
+      date_default_timezone_set($timezone);
+      $timenow   = strtotime(date("Y-m-d H:i:s"));
+      $lastlogin = strtotime($r[6]);
 
-      $offset = DB_get_user_timezone($user);
-      $zone   = return_timezone($offset);
-      date_default_timezone_set($zone);
 
       echo "  <div class=\"table".($pos-1)."\">\n";
       if(!$debug)
@@ -790,7 +771,7 @@ function display_table ()
        }
 
       echo "    <br />\n";
-      echo "    <span title=\"".date("Y-m-d H:i:s")."\">local time</span>\n";
+      echo "    <span title=\"".date("Y-m-d H:i:s",$timenow).  "\">local time</span>\n";
       echo "    <span title=\"".date("Y-m-d H:i:s",$lastlogin)."\">last login</span>\n";
       echo "   </div>\n";
 
@@ -806,13 +787,14 @@ function display_user_menu()
 {
   global $wiki,$myid,$host;
   echo "<div class=\"usermenu\">\n".
-    "<a href=\"index.php\"> go to my user page </a>";
+    "<a href=\"index.php\"> Go to my user page </a>";
 
   $result = mysql_query("SELECT Hand.hash,Hand.game_id,Game.player from Hand".
                        " LEFT JOIN Game On Hand.game_id=Game.id".
                        " WHERE Hand.user_id='$myid'".
                        " AND Game.player='$myid'".
-                       " AND Game.status<>'gameover'" );
+                       " AND Game.status<>'gameover'".
+                       " ORDER BY Game.session" );
   if(mysql_num_rows($result))
       echo "<hr />It's your turn in these games:<br />\n";
 
@@ -821,8 +803,9 @@ function display_user_menu()
       echo "<a href=\"".$host."?me=".$r[0]."\">game ".DB_format_gameid($r[1])." </a><br />\n";
     }
 
-  echo "<hr /> <a href=\"".$host."?new\">start a new game</a>\n";
+  echo "<hr /> <a href=\"".$host."?new\">Start a new game</a>\n";
 
+  echo "<hr /> <a href=\"".substr($host,0,-9)."stats.php\">Statistics</a>\n";
 
   echo
     "<hr />Report bugs in the <a href=\"". $wiki."\">wiki</a>\n";