n@816: Could not open file';
n@820: echo $xml;
n@820: return;
n@820: }
n@820: $wbytes = fwrite($fileHandle, $postText);
n@820: if ($wbytes == FALSE)
n@820: {
n@820: // FileWrite failed
n@820: $xml = 'Could not write file "saves/'.$xmlfile.'"';
n@820: echo $xml;
n@820: return;
n@820: }
n@816: fclose($fileHandle);
n@820:
n@820: // Return JSON confirmation data
n@820: $xml = 'OK"saves/'.$xmlfile.'"';
n@820: echo $xml;
nicholas@824:
nicholas@824: // Random String generator from http://stackoverflow.com/questions/4356289/php-random-string-generator
nicholas@824: function generateRandomString($length = 10) {
nicholas@824: $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
nicholas@824: $charactersLength = strlen($characters);
nicholas@824: $randomString = '';
nicholas@824: for ($i = 0; $i < $length; $i++) {
nicholas@824: $randomString .= $characters[rand(0, $charactersLength - 1)];
nicholas@824: }
nicholas@824: return $randomString;
nicholas@824: }
n@816: ?>