added local time output
authorarun <arun@nubati.net>
Fri, 8 Dec 2006 14:00:56 +0000 (14:00 +0000)
committerarun <arun>
Fri, 8 Dec 2006 14:00:56 +0000 (14:00 +0000)
db.php
functions.php
index.php

diff --git a/db.php b/db.php
index 10c5de2ae3e62deecd928bb32cea868767fd1a9c..9f002053b45b30e3b209eb6700f71b0863834b12 100644 (file)
--- a/db.php
+++ b/db.php
@@ -349,4 +349,31 @@ function DB_get_all_names()
 
   return $names;
 }
 
   return $names;
 }
+
+function DB_update_user_timestamp($userid)
+{
+  mysql_query("UPDATE User SET last_login = CURRENT_TIMESTAMP WHERE id=".DB_quote_smart($userid));
+  return;
+}
+
+function DB_get_user_timestamp($userid)
+{
+  $result = mysql_query("SELECT last_login FROM User WHERE id=".DB_quote_smart($userid));
+  $r      = mysql_fetch_array($result,MYSQL_NUM);
+  
+  if($r)
+    return $r[0];
+  else
+    return NULL;
+}
+function DB_get_user_timezone($userid)
+{
+  $result = mysql_query("SELECT timezone FROM User WHERE id=".DB_quote_smart($userid));
+  $r      = mysql_fetch_array($result,MYSQL_NUM);
+  
+  if($r)
+    return $r[0];
+  else
+    return 0;
+}
 ?>
\ No newline at end of file
 ?>
\ No newline at end of file
index 49e0a1d21aade548bee7f718417e840bcfc50880..ce4851309f0da48a13e44446109dbd6c96d96799 100644 (file)
@@ -431,4 +431,18 @@ function display_cards($me,$myturn)
   return;
 }
 
   return;
 }
 
+function return_timezone($offset)
+{
+  switch($offset)
+    {
+    case '1':
+      $zone = "Europe/Berlin";
+      break;
+    default:
+      $zone = "Europe/London";
+    }
+  
+  return $zone;
+}
+
 ?>
\ No newline at end of file
 ?>
\ No newline at end of file
index 7db439913a9bf7c7bccd4c0bbb7f6bb3ba919655..8385576502c82c412843606ce9a0e4f96c3e067c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -171,6 +171,7 @@ else if(isset($_REQUEST["me"]))
         exit();
       }
     
         exit();
       }
     
+    DB_update_user_timestamp($myid);
     $myname   = DB_get_name_by_hash($me);
     $mystatus = DB_get_status_by_hash($me);
 
     $myname   = DB_get_name_by_hash($me);
     $mystatus = DB_get_status_by_hash($me);
 
@@ -541,7 +542,18 @@ else if(isset($_REQUEST["me"]))
 
     if($ok)
       {
 
     if($ok)
       {
-       echo "ok. your logged in, now what? :)<br />";
+       $time = DB_get_user_timestamp($uid);
+       $unixtime =strtotime($time);
+       
+       $offset = DB_get_user_timezone($uid);
+       $zone = return_timezone($offset);
+       date_default_timezone_set($zone);
+
+       echo "ok. your logged in, now what? :) <br />last login: ";
+       echo date("r",$unixtime)."<br />";
+
+       DB_update_user_timestamp($uid);
+
        $names = DB_get_all_names();
        echo "<p>registered players:<br />\n";
        foreach ($names as $name)
        $names = DB_get_all_names();
        echo "<p>registered players:<br />\n";
        foreach ($names as $name)
@@ -576,7 +588,9 @@ else if(isset($_REQUEST["register"]) )
                <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxsize="30" /></td>
               </tr><tr>
               <td><label for="Rtimezone">Timezone:</label></td>
                <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxsize="30" /></td>
               </tr><tr>
               <td><label for="Rtimezone">Timezone:</label></td>
-               <td><input type="text" id="Rtimezone" name="Rtimezone" size="4" maxsize="4" value="+1"/></td>
+               <td>
+                  <input type="text" id="Rtimezone" name="Rtimezone" size="4" maxsize="4" value="+1" />
+              </td>
               </tr><tr>
                <td colspan="2"> <input type="submit" value="register" /></td>
              </table>
               </tr><tr>
                <td colspan="2"> <input type="submit" value="register" /></td>
              </table>