Mercurial > hg > webaudioevaluationtool
annotate save.php @ 2202:61c8e13f1e2e
Merge branch 'master' of https://github.com/BrechtDeMan/WebAudioEvaluationTool
author | www-data <www-data@sucuk.dcs.qmul.ac.uk> |
---|---|
date | Fri, 08 Apr 2016 13:20:54 +0100 |
parents | ba6b9e1aaef5 |
children |
rev | line source |
---|---|
BrechtDeMan@715 | 1 <?php |
giuliomoro@1238 | 2 error_reporting(0); |
BrechtDeMan@746 | 3 header('Access-Control-Allow-Origin: *'); |
nicholas@748 | 4 header("Content-type: text/xml"); |
BrechtDeMan@715 | 5 $postText = file_get_contents('php://input'); |
n@1242 | 6 $file_key = $_GET['key']; |
n@1242 | 7 $filename = "saves/save-".$file_key.".xml"; |
n@1242 | 8 $fileHandle = fopen($filename, 'w'); |
nicholas@748 | 9 if ($fileHandle == FALSE) |
nicholas@748 | 10 { |
nicholas@748 | 11 // Filehandle failed |
nicholas@748 | 12 $xml = '<response state="error"><message>Could not open file</message></response>'; |
nicholas@748 | 13 echo $xml; |
nicholas@748 | 14 return; |
nicholas@748 | 15 } |
nicholas@748 | 16 $wbytes = fwrite($fileHandle, $postText); |
giuliomoro@1215 | 17 if ($wbytes === FALSE) |
nicholas@748 | 18 { |
nicholas@748 | 19 // FileWrite failed |
n@1093 | 20 $xml = '<response state="error"><message>Could not write file "'.$filename.'"</message></response>'; |
nicholas@748 | 21 echo $xml; |
nicholas@748 | 22 return; |
nicholas@748 | 23 } |
BrechtDeMan@715 | 24 fclose($fileHandle); |
nicholas@748 | 25 |
n@1093 | 26 // Return XML confirmation data |
n@1093 | 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>'; |
nicholas@748 | 28 echo $xml; |
n@1093 | 29 ?> |