# HG changeset patch # User Nicholas Jillings # Date 1448294557 0 # Node ID 1dfcfdb7a1ad3c530d05606873da8ba542ca0b05 # Parent 1b81ab727352094f8ec93b3a4512ef4f4d6c280d Feature #1456. PHP server adds a six character 'hash' to the end of the file. diff -r 1b81ab727352 -r 1dfcfdb7a1ad save.php --- a/save.php Mon Nov 23 15:48:07 2015 +0000 +++ b/save.php Mon Nov 23 16:02:37 2015 +0000 @@ -3,7 +3,7 @@ header("Content-type: text/xml"); $postText = file_get_contents('php://input'); $datetime = date('ymdHis'); - $xmlfile = "save".$datetime.".xml"; + $xmlfile = "save".$datetime."-".generateRandomString(6).".xml"; $fileHandle = fopen("saves/".$xmlfile, 'w'); if ($fileHandle == FALSE) { @@ -25,4 +25,15 @@ // 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