added two new features: local time and a link to the user page
authorarun <arun@nubati.net>
Wed, 13 Dec 2006 18:32:33 +0000 (18:32 +0000)
committerarun <arun>
Wed, 13 Dec 2006 18:32:33 +0000 (18:32 +0000)
css/standard.css
db.php
functions.php
index.php

index 4e6650aa9e6e12ff1775045e74806e26f56f48df..028930305fcd72750f48cb53b124c85b5d2fd5bf 100644 (file)
@@ -198,6 +198,12 @@ ul.oldtrick li div div.card3 span span{
   border-top:0;
 }
 
   border-top:0;
 }
 
+.time,.over { 
+  float:right;
+  border:2px solid black;
+  clear:right;
+ }
+
 .bug {
   float:left;
   width:10em;
 .bug {
   float:left;
   width:10em;
diff --git a/db.php b/db.php
index f8937486685eff28431f2d59f648cc056d13fba8..4b18d9c526f23e411ffbcec7b98a06dfb1c7c57b 100644 (file)
--- a/db.php
+++ b/db.php
@@ -100,6 +100,16 @@ function DB_get_userid_by_email($email)
   else
     return 0;
 }
   else
     return 0;
 }
+function DB_get_userid_by_email_and_password($email,$password)
+{
+  $result = mysql_query("SELECT id FROM User WHERE email=".DB_quote_smart($email)." AND password=".DB_quote_smart($password));
+  $r      = mysql_fetch_array($result,MYSQL_NUM);
+  
+  if($r)
+    return $r[0];
+  else
+    return 0;
+}
 
 function DB_get_handid_by_hash($hash)
 {
 
 function DB_get_handid_by_hash($hash)
 {
@@ -145,6 +155,17 @@ function DB_get_name_by_hash($hash)
     return "";
 }
 
     return "";
 }
 
+function DB_get_name_by_userid($id)
+{
+  $result = mysql_query("SELECT fullname FROM User  WHERE id=".DB_quote_smart($id));
+  $r      = mysql_fetch_array($result,MYSQL_NUM);
+  
+  if($r)
+    return $r[0];
+  else
+    return "";
+}
+
 function DB_get_status_by_hash($hash)
 {
   $result = mysql_query("SELECT status FROM Hand WHERE hash=".DB_quote_smart($hash));
 function DB_get_status_by_hash($hash)
 {
   $result = mysql_query("SELECT status FROM Hand WHERE hash=".DB_quote_smart($hash));
index 390f6c9dde0cb8a05ca234296843a2e002752911..6bd50af740d23f59b84e322b532752f8e373c803 100644 (file)
@@ -404,7 +404,7 @@ function display_news()
   global $wiki;
   echo "<div class=\"bug\"> ".
     "Please hit shift+reload.<br /><hr />".
   global $wiki;
   echo "<div class=\"bug\"> ".
     "Please hit shift+reload.<br /><hr />".
-    "Fixed a few bugs, comments might be working again <br /><hr />".
+    "added local time display, let me know what you think<br /><hr />".
     "If you find more bugs, please list them in the <a href=\"".$wiki.
     "\">wiki</a>.</div>\n";
   return;
     "If you find more bugs, please list them in the <a href=\"".$wiki.
     "\">wiki</a>.</div>\n";
   return;
index a3b0891875dd7433785027e16ba301bf3848b913..40920debcf9072f8879233a7e4fb71752e2cca74 100644 (file)
--- a/index.php
+++ b/index.php
@@ -5,7 +5,7 @@
   <head>
      <title>e-Doko</title>
      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
   <head>
      <title>e-Doko</title>
      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
-     <link rel="stylesheet" type="text/css" href="standard.css" />     
+     <link rel="stylesheet" type="text/css" href="css/standard.css" /> 
      <script type="text/javascript">
        function hl(num) {
          if(document.getElementById){
      <script type="text/javascript">
        function hl(num) {
          if(document.getElementById){
@@ -283,6 +283,32 @@ else if(isset($_REQUEST["me"]))
        display_news();
        display_status();
 
        display_news();
        display_status();
 
+       /* display local time */
+       echo "<div class=\"time\">\n Local times:<table>";
+       $users = array();
+       $users = DB_get_all_userid_by_gameid($gameid);
+       foreach($users as $user)
+         {
+           $offset = DB_get_user_timezone($user);
+           $zone = return_timezone($offset);
+           date_default_timezone_set($zone);
+           $name = DB_get_name_by_userid($user);
+           
+           echo "<tr> <td>$name</td> <td>".date("Y-m-d H:i:s")."</td></tr>\n";
+         };
+       echo "</table>\n</div>\n";
+
+       /* display links to other games */
+       echo "<div class=\"over\">\n";
+       $result = mysql_query("SELECT email,password from User WHERE id='$myid'" );
+       $r = mysql_fetch_array($result,MYSQL_NUM);
+       echo "<form action=\"index.php\" method=\"post\">\n";
+       echo "  <input type=\"hidden\" name=\"email\" value=\"".$r[0]."\" />\n";
+       echo "  <input type=\"hidden\" name=\"password\" value=\"".$r[1]."\" />\n";
+       echo "  <input type=\"submit\" value=\"go to my user page\" />\n";
+       echo "</form>\n";
+       echo "</div>\n";
+
        $gamestatus = DB_get_game_status_by_gameid($gameid);
        if($gamestatus == 'pre')
          {
        $gamestatus = DB_get_game_status_by_gameid($gameid);
        if($gamestatus == 'pre')
          {
@@ -528,7 +554,7 @@ else if(isset($_REQUEST["me"]))
            $names = DB_get_all_names_by_gameid($gameid);
            
            echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n";
            $names = DB_get_all_names_by_gameid($gameid);
            
            echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n";
-           echo "<form action=\"index.php\" methog=\"post\">\n";
+           echo "<form action=\"index.php\" method=\"post\">\n";
            echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"".($names[1])."\" />\n";
            echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"".($names[2])."\" />\n";
            echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"".($names[3])."\" />\n";
            echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"".($names[1])."\" />\n";
            echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"".($names[2])."\" />\n";
            echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"".($names[3])."\" />\n";
@@ -547,12 +573,16 @@ else if(isset($_REQUEST["me"]))
  else if(isset($_REQUEST["email"]) && isset($_REQUEST["password"]))
   {
     /* test id and password, should really be done in one step */
  else if(isset($_REQUEST["email"]) && isset($_REQUEST["password"]))
   {
     /* test id and password, should really be done in one step */
+    $email     = $_REQUEST["email"];
+    $password  = $_REQUEST["password"];
+
+    if(strlen($password)!=32)
+      $password = md5($password);
+
     $ok=1;
     $ok=1;
-    $uid = DB_get_userid_by_email($_REQUEST["email"]);
+    $uid = DB_get_userid_by_email_and_password($email,$password);
     if(!$uid)
       $ok=0;
     if(!$uid)
       $ok=0;
-    if(!DB_get_userid_by_passwd(md5($_REQUEST["password"])))
-      $ok=0;
 
     if($ok)
       {
 
     if($ok)
       {
@@ -591,6 +621,7 @@ else if(isset($_REQUEST["me"]))
 /* page for registration */
 else if(isset($_REQUEST["register"]) )
   {
 /* page for registration */
 else if(isset($_REQUEST["register"]) )
   {
+    echo "IMPORTANT: passwords are going over the net as clear text, so pick an easy password. No need to pick anything complicated here ;)<br /><br />";
     echo "TODO: convert timezone into a menu<br />\n";
     echo "TODO: figure out a way to handle passwrods <br />\n";
 ?>
     echo "TODO: convert timezone into a menu<br />\n";
     echo "TODO: figure out a way to handle passwrods <br />\n";
 ?>