added timezone for .nz
[e-DoKo.git] / index.php
index 7db439913a9bf7c7bccd4c0bbb7f6bb3ba919655..4a38ed8c9bde2ba498a86c0266c7aab1d9afe85c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -98,8 +98,13 @@ else if( isset($_REQUEST["PlayerA"]) &&
     
     /* create game */
     $followup = NULL;
-    if(isset($_REQUEST["followup"])) $followup= $_REQUEST["followup"];
-    mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', NULL, NULL,'pre',$followup ,NULL)");
+    if(isset($_REQUEST["followup"])) 
+      {
+       $followup= $_REQUEST["followup"];
+       mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', NULL, NULL,'pre','$followup' ,NULL)");
+      }
+    else
+      mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', NULL, NULL,'pre', NULL ,NULL)");
     $game_id = mysql_insert_id();
     
     
@@ -171,6 +176,7 @@ else if(isset($_REQUEST["me"]))
         exit();
       }
     
+    DB_update_user_timestamp($myid);
     $myname   = DB_get_name_by_hash($me);
     $mystatus = DB_get_status_by_hash($me);
 
@@ -288,7 +294,13 @@ else if(isset($_REQUEST["me"]))
       case 'gameover': /* gameover and play, so that the tricks are visible for both */
        display_news();
        display_status();
-               
+
+       $gamestatus =DB_get_game_status_by_gameid($gameid);
+       if($gamestatus == 'pre')
+         {
+           echo "you need to wait for the others... <br />";
+           break;
+         }
        /* get trick ids */
        $result = mysql_query("SELECT Hand_Card.card_id as card,".
                              "       User.fullname as name,".
@@ -541,7 +553,24 @@ else if(isset($_REQUEST["me"]))
 
     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);
+
+       echo "<p>these are the games you are playing in:<br />\n";
+       $result = mysql_query("SELECT hash,game_id from Hand WHERE user_id='$uid' AND status<>'gameover'" );
+       while( $r = mysql_fetch_array($result,MYSQL_NUM))
+         echo "<a href=\"http://doko.nubati.net/database/index.php?me=".$r[0]."\">game #".$r[1]." </a><br />";
+       echo "</p>\n";
+
        $names = DB_get_all_names();
        echo "<p>registered players:<br />\n";
        foreach ($names as $name)
@@ -576,7 +605,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="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>