added session to database
[e-DoKo.git] / index.php
index 7996e0d2f9ef6db64e2e275b64cb653b5add3b25..e58bae69b437e6bb81b01607e4c4dbe28d8d8bb3 100644 (file)
--- a/index.php
+++ b/index.php
@@ -63,7 +63,17 @@ else if( myisset("PlayerA", "PlayerB","PlayerC","PlayerD" ))
   if(myisset("followup") )
     {
       $followup= $_REQUEST["followup"];
-      mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre','$followup' ,NULL)");
+      $session = DB_get_session_by_gameid($followup);
+      if($session)
+       mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre','$session' ,NULL)");
+      else
+       {
+         /* get max session */
+         $max = DB_get_max_session();
+         $max++;
+         mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre','$max' ,NULL)");
+         mysql_query("UPDATE Game SET session='".$max."' WHERE id=".DB_quote_smart($followup));
+       }
     }
   else
     mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre', NULL ,NULL)");
@@ -146,7 +156,7 @@ else if(myisset("cancle","me"))
   if(time()-strtotime($r[0]) > 60*60*24*30)
     {
       $message = "Hello, \n\n".
-       "Game $gameid has been cancled because, since nothing happend for a while and $myname requested it.\n";
+       "Game $gameid has been cancled since nothing happend for a while and $myname requested it.\n";
       
       $userids = DB_get_all_userid_by_gameid($gameid);
       foreach($userids as $user)
@@ -824,20 +834,19 @@ else if(myisset("me"))
        echo "</p>\n";
 
 
-       echo "<p>and these are your games that are already done:<br />\n";
+       echo "<p>and these are your games that are already done:<br />Game: \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=\"".$host."?me=".$r[0]."\">game #".$r[1]." </a><br />";
+         echo "<a href=\"".$host."?me=".$r[0]."\">#".$r[1]." </a>, ";
        echo "</p>\n";
 
        $names = DB_get_all_names();
        echo "<p>registered players:<br />\n";
        foreach ($names as $name)
-         echo "$name <br />\n";
+         echo "$name\n";
        echo "</p>\n";
 
-       echo "<p>Want to start a new game? remember 4 names from the list above and visit ".
-         "<a href=\"".$host."?new\">this page.</a></p>";
+       echo "<p>Want to start a new game? Visit <a href=\"".$host."?new\">this page.</a></p>";
       }
     else
       {