# HG changeset patch # User Nicholas Jillings # Date 1448616453 0 # Node ID 75e1c1ce6604de24df4ef4d0c6ef290fb34af247 # Parent 16ee072037404e5a6a08e7e1d749d3069a2e5c23 Bug #1464 #1456, PHP server hashes file contents to differentiate file names. Confirmed working on multiple connections with same file contents. diff -r 16ee07203740 -r 75e1c1ce6604 save.php --- a/save.php Thu Nov 26 09:59:22 2015 +0000 +++ b/save.php Fri Nov 27 09:27:33 2015 +0000 @@ -2,8 +2,9 @@ header('Access-Control-Allow-Origin: *'); header("Content-type: text/xml"); $postText = file_get_contents('php://input'); + $sha1_hash = sha1($postText); $datetime = date('ymdHis'); - $xmlfile = "save".$datetime."-".generateRandomString(6).".xml"; + $xmlfile = "save".$datetime."-".$sha1_hash.".xml"; $fileHandle = fopen("saves/".$xmlfile, 'w'); if ($fileHandle == FALSE) { @@ -25,15 +26,4 @@ // Return JSON confirmation data $xml = 'OK"saves/'.$xmlfile.'"'; echo $xml; - - // Random String generator from http://stackoverflow.com/questions/4356289/php-random-string-generator - function generateRandomString($length = 10) { - $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $charactersLength = strlen($characters); - $randomString = ''; - for ($i = 0; $i < $length; $i++) { - $randomString .= $characters[rand(0, $charactersLength - 1)]; - } - return $randomString; -} ?> \ No newline at end of file