Mercurial > hg > webaudioevaluationtool
annotate save.php @ 624:45df85a336d4 Dev_main
Add PDFs to repository, remove from .hgignore
author | Brecht De Man <b.deman@qmul.ac.uk> |
---|---|
date | Sun, 20 Mar 2016 11:01:26 +0100 |
parents | 0794fefefbd8 |
children | 0256f3748b27 |
rev | line source |
---|---|
n@292 | 1 <?php |
giuliomoro@583 | 2 error_reporting(0); |
b@343 | 3 header('Access-Control-Allow-Origin: *'); |
nicholas@345 | 4 header("Content-type: text/xml"); |
n@292 | 5 $postText = file_get_contents('php://input'); |
n@589 | 6 $file_key = $_GET['key']; |
n@589 | 7 $filename = "saves/save-".$file_key.".xml"; |
n@589 | 8 $fileHandle = fopen($filename, 'w'); |
nicholas@345 | 9 if ($fileHandle == FALSE) |
nicholas@345 | 10 { |
nicholas@345 | 11 // Filehandle failed |
nicholas@345 | 12 $xml = '<response state="error"><message>Could not open file</message></response>'; |
nicholas@345 | 13 echo $xml; |
nicholas@345 | 14 return; |
nicholas@345 | 15 } |
nicholas@345 | 16 $wbytes = fwrite($fileHandle, $postText); |
giuliomoro@556 | 17 if ($wbytes === FALSE) |
nicholas@345 | 18 { |
nicholas@345 | 19 // FileWrite failed |
n@600 | 20 $xml = '<response state="error"><message>Could not write file "'.$filename.'"</message></response>'; |
nicholas@345 | 21 echo $xml; |
nicholas@345 | 22 return; |
nicholas@345 | 23 } |
n@292 | 24 fclose($fileHandle); |
nicholas@345 | 25 |
n@600 | 26 // Return XML confirmation data |
n@600 | 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>'; |
nicholas@345 | 28 echo $xml; |
n@600 | 29 ?> |