NEW FEATURE: show the time a game took at the end of the game
[e-DoKo.git] / functions.php
index 69e208c0e7d1b1deb328d819ff1e15d76a0a9288..0ce3104701f2175c24d53f6e63053904ba8846d7 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;
@@ -660,7 +640,7 @@ function can_call($what,$hash)
 
 function display_table ()
 {
-  global $gameid, $GT, $debug,$host;
+  global $gameid, $GT, $debug,$INDEX,$defaulttimezone;
 
   $result = mysql_query("SELECT  User.fullname as name,".
                        "        Hand.position as position, ".
@@ -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,18 +666,18 @@ function display_table ()
       $party = $r[3];
       $sickness  = $r[4];
       $call      = $r[5];
-      $lastlogin = strtotime($r[6]);
       $hash      = $r[7];
-
-      $offset = DB_get_user_timezone($user);
-      $zone   = return_timezone($offset);
-      date_default_timezone_set($zone);
+      $timezone  = $r[8];
+      date_default_timezone_set($defaulttimezone);
+      $lastlogin = strtotime($r[6]);
+      date_default_timezone_set($timezone);
+      $timenow   = strtotime(date("Y-m-d H:i:s"));
 
       echo "  <div class=\"table".($pos-1)."\">\n";
       if(!$debug)
        echo "   $name \n";
       else
-       echo "   <a href=\"".$host."?me=".$hash."\">$name</a>\n";
+       echo "   <a href=\"".$INDEX."?me=".$hash."\">$name</a>\n";
 
       /* add hints for poverty, wedding, solo, etc */
       if($GT=="poverty" && $party=="re")
@@ -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";
 
@@ -804,28 +785,30 @@ function display_table ()
 
 function display_user_menu()
 {
-  global $wiki,$myid,$host;
+  global $wiki,$myid,$INDEX,$STATS;
   echo "<div class=\"usermenu\">\n".
-    "<a href=\"index.php\"> go to my user page </a>";
+    "<a href=\"".$INDEX."\"> 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";
 
   while( $r = mysql_fetch_array($result,MYSQL_NUM))
     {
-      echo "<a href=\"".$host."?me=".$r[0]."\">game ".DB_format_gameid($r[1])." </a><br />\n";
+      echo "<a href=\"".$INDEX."?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=\"".$INDEX."?new\">Start a new game</a>\n";
 
+  echo "<hr /> <a href=\"".$STATS."\">Statistics</a>\n";
 
   echo
-    "<hr />Report bugs in the <a href=\"". $wiki."\">wiki</a>\n";
+    "<hr />Report bugs in the <a href=\"".$wiki."\">wiki</a>\n";
   echo  "</div>\n";
   return;
 }