annotate save.php @ 1176:12ef00ae9dd5

Bug #1567: AB.js interfaces, the playback toggle now controls both playback start and playback stop commands. Button text updated to reflect.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 11 Feb 2016 14:16:09 +0000
parents c44fbf72f7f2
children 2647dd909229 b5bf2f57187c 9ee921c8cdd3
rev   line source
n@1116 1 <?php
n@1116 2 header('Access-Control-Allow-Origin: *');
n@1116 3 header("Content-type: text/xml");
n@1116 4 $postText = file_get_contents('php://input');
n@1116 5 $sha1_hash = sha1($postText);
n@1116 6 $datetime = date('ymdHis');
n@1116 7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
n@1116 8 $fileHandle = fopen("saves/".$xmlfile, 'w');
n@1116 9 if ($fileHandle == FALSE)
n@1116 10 {
n@1116 11 // Filehandle failed
n@1116 12 $xml = '<response state="error"><message>Could not open file</message></response>';
n@1116 13 echo $xml;
n@1116 14 return;
n@1116 15 }
n@1116 16 $wbytes = fwrite($fileHandle, $postText);
n@1116 17 if ($wbytes == FALSE)
n@1116 18 {
n@1116 19 // FileWrite failed
n@1116 20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
n@1116 21 echo $xml;
n@1116 22 return;
n@1116 23 }
n@1116 24 fclose($fileHandle);
n@1116 25
n@1116 26 // Return JSON confirmation data
n@1116 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
n@1116 28 echo $xml;
n@1116 29 ?>