Mercurial > hg > webaudioevaluationtool
annotate save.php @ 2212:279733b3b67e
Move pythonServer-legacy.py to scripts
author | Brecht De Man <b.deman@qmul.ac.uk> |
---|---|
date | Wed, 13 Apr 2016 15:46:12 +0100 |
parents | 686f1fb84d7c |
children |
rev | line source |
---|---|
b@1478 | 1 <?php |
giuliomoro@2146 | 2 error_reporting(0); |
b@1969 | 3 header('Access-Control-Allow-Origin: *'); |
nickjillings@1971 | 4 header("Content-type: text/xml"); |
b@1478 | 5 $postText = file_get_contents('php://input'); |
nickjillings@2150 | 6 $file_key = $_GET['key']; |
nickjillings@2150 | 7 $filename = "saves/save-".$file_key.".xml"; |
nickjillings@2150 | 8 $fileHandle = fopen($filename, 'w'); |
nickjillings@1971 | 9 if ($fileHandle == FALSE) |
nickjillings@1971 | 10 { |
nickjillings@1971 | 11 // Filehandle failed |
nickjillings@1971 | 12 $xml = '<response state="error"><message>Could not open file</message></response>'; |
nickjillings@1971 | 13 echo $xml; |
nickjillings@1971 | 14 return; |
nickjillings@1971 | 15 } |
nickjillings@1971 | 16 $wbytes = fwrite($fileHandle, $postText); |
giuliomoro@2123 | 17 if ($wbytes === FALSE) |
nickjillings@1971 | 18 { |
nickjillings@1971 | 19 // FileWrite failed |
nickjillings@1292 | 20 $xml = '<response state="error"><message>Could not write file "'.$filename.'"</message></response>'; |
nickjillings@1971 | 21 echo $xml; |
nickjillings@1971 | 22 return; |
nickjillings@1971 | 23 } |
b@1478 | 24 fclose($fileHandle); |
nickjillings@1971 | 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@1971 | 28 echo $xml; |
nickjillings@1292 | 29 ?> |