annotate save.php @ 1112:28aa066720ed

Fixed typo
author Giulio Moro <giuliomoro@yahoo.it>
date Sun, 21 Feb 2016 03:35:27 +0000
parents 282dfb8076f5
children 2647dd909229 b5bf2f57187c 9ee921c8cdd3
rev   line source
n@1106 1 <?php
n@1106 2 header('Access-Control-Allow-Origin: *');
n@1106 3 header("Content-type: text/xml");
n@1106 4 $postText = file_get_contents('php://input');
n@1106 5 $sha1_hash = sha1($postText);
n@1106 6 $datetime = date('ymdHis');
n@1106 7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
n@1106 8 $fileHandle = fopen("saves/".$xmlfile, 'w');
n@1106 9 if ($fileHandle == FALSE)
n@1106 10 {
n@1106 11 // Filehandle failed
n@1106 12 $xml = '<response state="error"><message>Could not open file</message></response>';
n@1106 13 echo $xml;
n@1106 14 return;
n@1106 15 }
n@1106 16 $wbytes = fwrite($fileHandle, $postText);
n@1106 17 if ($wbytes == FALSE)
n@1106 18 {
n@1106 19 // FileWrite failed
n@1106 20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
n@1106 21 echo $xml;
n@1106 22 return;
n@1106 23 }
n@1106 24 fclose($fileHandle);
n@1106 25
n@1106 26 // Return JSON confirmation data
n@1106 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
n@1106 28 echo $xml;
n@1106 29 ?>