Mercurial > hg > webaudioevaluationtool
annotate save.php @ 1294:e7a819fe85bf
Intermediate saves can be used to resume a test. Note, previous saves will NOT work for resumption. To resume, use the save XML as the ?url= option.
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Thu, 10 Mar 2016 15:33:39 +0000 |
parents | a6cfd378891c |
children | ba6b9e1aaef5 |
rev | line source |
---|---|
nickjillings@1289 | 1 <?php |
nickjillings@1289 | 2 error_reporting(0); |
nickjillings@1289 | 3 header('Access-Control-Allow-Origin: *'); |
nickjillings@1289 | 4 header("Content-type: text/xml"); |
nickjillings@1289 | 5 $postText = file_get_contents('php://input'); |
nickjillings@1289 | 6 $file_key = $_GET['key']; |
nickjillings@1289 | 7 $filename = "saves/save-".$file_key.".xml"; |
nickjillings@1289 | 8 $fileHandle = fopen($filename, 'w'); |
nickjillings@1289 | 9 if ($fileHandle == FALSE) |
nickjillings@1289 | 10 { |
nickjillings@1289 | 11 // Filehandle failed |
nickjillings@1289 | 12 $xml = '<response state="error"><message>Could not open file</message></response>'; |
nickjillings@1289 | 13 echo $xml; |
nickjillings@1289 | 14 return; |
nickjillings@1289 | 15 } |
nickjillings@1289 | 16 $wbytes = fwrite($fileHandle, $postText); |
nickjillings@1289 | 17 if ($wbytes === FALSE) |
nickjillings@1289 | 18 { |
nickjillings@1289 | 19 // FileWrite failed |
nickjillings@1292 | 20 $xml = '<response state="error"><message>Could not write file "'.$filename.'"</message></response>'; |
nickjillings@1289 | 21 echo $xml; |
nickjillings@1289 | 22 return; |
nickjillings@1289 | 23 } |
nickjillings@1289 | 24 fclose($fileHandle); |
nickjillings@1289 | 25 |
nickjillings@1292 | 26 // Return XML confirmation data |
nickjillings@1292 | 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>'; |
nickjillings@1289 | 28 echo $xml; |
nickjillings@1292 | 29 ?> |