annotate save.php @ 1154:3ba07a441364

Adding volume control interface object. Minor discrete layout format change.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 22 Jan 2016 11:10:33 +0000
parents 3edcbbea168b
children 2647dd909229 b5bf2f57187c 9ee921c8cdd3
rev   line source
n@1118 1 <?php
n@1118 2 header('Access-Control-Allow-Origin: *');
n@1118 3 header("Content-type: text/xml");
n@1118 4 $postText = file_get_contents('php://input');
n@1118 5 $sha1_hash = sha1($postText);
n@1118 6 $datetime = date('ymdHis');
n@1118 7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
n@1118 8 $fileHandle = fopen("saves/".$xmlfile, 'w');
n@1118 9 if ($fileHandle == FALSE)
n@1118 10 {
n@1118 11 // Filehandle failed
n@1118 12 $xml = '<response state="error"><message>Could not open file</message></response>';
n@1118 13 echo $xml;
n@1118 14 return;
n@1118 15 }
n@1118 16 $wbytes = fwrite($fileHandle, $postText);
n@1118 17 if ($wbytes == FALSE)
n@1118 18 {
n@1118 19 // FileWrite failed
n@1118 20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
n@1118 21 echo $xml;
n@1118 22 return;
n@1118 23 }
n@1118 24 fclose($fileHandle);
n@1118 25
n@1118 26 // Return JSON confirmation data
n@1118 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
n@1118 28 echo $xml;
n@1118 29 ?>