Mercurial > hg > webaudioevaluationtool
annotate save.php @ 755:c73996a0fb21
Bug #1486: Fixed rogue '+' appearing in move slider alert. Unlabelled axis have default of 'Axis ' and their index.
author | Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk> |
---|---|
date | Thu, 17 Dec 2015 13:03:39 +0000 |
parents | |
children | 2647dd909229 b5bf2f57187c 9ee921c8cdd3 |
rev | line source |
---|---|
nicholas@755 | 1 <?php |
nicholas@755 | 2 header('Access-Control-Allow-Origin: *'); |
nicholas@755 | 3 header("Content-type: text/xml"); |
nicholas@755 | 4 $postText = file_get_contents('php://input'); |
nicholas@755 | 5 $sha1_hash = sha1($postText); |
nicholas@755 | 6 $datetime = date('ymdHis'); |
nicholas@755 | 7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml"; |
nicholas@755 | 8 $fileHandle = fopen("saves/".$xmlfile, 'w'); |
nicholas@755 | 9 if ($fileHandle == FALSE) |
nicholas@755 | 10 { |
nicholas@755 | 11 // Filehandle failed |
nicholas@755 | 12 $xml = '<response state="error"><message>Could not open file</message></response>'; |
nicholas@755 | 13 echo $xml; |
nicholas@755 | 14 return; |
nicholas@755 | 15 } |
nicholas@755 | 16 $wbytes = fwrite($fileHandle, $postText); |
nicholas@755 | 17 if ($wbytes == FALSE) |
nicholas@755 | 18 { |
nicholas@755 | 19 // FileWrite failed |
nicholas@755 | 20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>'; |
nicholas@755 | 21 echo $xml; |
nicholas@755 | 22 return; |
nicholas@755 | 23 } |
nicholas@755 | 24 fclose($fileHandle); |
nicholas@755 | 25 |
nicholas@755 | 26 // Return JSON confirmation data |
nicholas@755 | 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>'; |
nicholas@755 | 28 echo $xml; |
nicholas@755 | 29 ?> |