annotate save.php @ 763:519baf8648a9

APE: Each slider now a JS object to ease metric tracking. Resize function fixed.
author Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk>
date Tue, 08 Dec 2015 17:15:34 +0000
parents
children 2647dd909229 b5bf2f57187c 9ee921c8cdd3
rev   line source
nicholas@763 1 <?php
nicholas@763 2 header('Access-Control-Allow-Origin: *');
nicholas@763 3 header("Content-type: text/xml");
nicholas@763 4 $postText = file_get_contents('php://input');
nicholas@763 5 $sha1_hash = sha1($postText);
nicholas@763 6 $datetime = date('ymdHis');
nicholas@763 7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
nicholas@763 8 $fileHandle = fopen("saves/".$xmlfile, 'w');
nicholas@763 9 if ($fileHandle == FALSE)
nicholas@763 10 {
nicholas@763 11 // Filehandle failed
nicholas@763 12 $xml = '<response state="error"><message>Could not open file</message></response>';
nicholas@763 13 echo $xml;
nicholas@763 14 return;
nicholas@763 15 }
nicholas@763 16 $wbytes = fwrite($fileHandle, $postText);
nicholas@763 17 if ($wbytes == FALSE)
nicholas@763 18 {
nicholas@763 19 // FileWrite failed
nicholas@763 20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
nicholas@763 21 echo $xml;
nicholas@763 22 return;
nicholas@763 23 }
nicholas@763 24 fclose($fileHandle);
nicholas@763 25
nicholas@763 26 // Return JSON confirmation data
nicholas@763 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
nicholas@763 28 echo $xml;
nicholas@763 29 ?>