fix: hash collision after a game has been cancled and the gameid is being reused.
authorarun <arun@nubati.net>
Wed, 25 Apr 2007 08:17:43 +0000 (08:17 +0000)
committerarun <arun>
Wed, 25 Apr 2007 08:17:43 +0000 (08:17 +0000)
index.php

index 989a54716145cd2276b2228e2103da8ae4d9c0ed..83c8cb7c2a553480ab8c4f05bb4982b9a6ff081d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -109,10 +109,11 @@ if(myisset("new"))
     $game_id = mysql_insert_id();
     
     /* create hash */
     $game_id = mysql_insert_id();
     
     /* create hash */
-    $hashA = md5("AGameOfDoko".$game_id.$PlayerA.$EmailA);
-    $hashB = md5("AGameOfDoko".$game_id.$PlayerB.$EmailB);
-    $hashC = md5("AGameOfDoko".$game_id.$PlayerC.$EmailC);
-    $hashD = md5("AGameOfDoko".$game_id.$PlayerD.$EmailD);
+    $TIME  = (string) time(); /* to avoid collisions */
+    $hashA = md5("AGameOfDoko".$game_id.$PlayerA.$EmailA.$TIME);
+    $hashB = md5("AGameOfDoko".$game_id.$PlayerB.$EmailB.$TIME);
+    $hashC = md5("AGameOfDoko".$game_id.$PlayerC.$EmailC.$TIME);
+    $hashD = md5("AGameOfDoko".$game_id.$PlayerD.$EmailD.$TIME);
     
     /* create hands */
     mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridA).
     
     /* create hands */
     mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridA).