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