Mercurial > hg > webaudioevaluationtool
comparison save.php @ 748:b9785aaab2a4
Bug #1349: PHP returns XML confirmation or error and message. Core responds. Bug #1449 not a bug
author | Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk> |
---|---|
date | Fri, 20 Nov 2015 15:39:01 +0000 |
parents | c64529e5dee4 |
children | b448ed356355 888292c88c33 |
comparison
equal
deleted
inserted
replaced
747:6fb0b21d6f85 | 748:b9785aaab2a4 |
---|---|
1 <?php | 1 <?php |
2 header('Access-Control-Allow-Origin: *'); | 2 header('Access-Control-Allow-Origin: *'); |
3 header("Content-type: text/xml"); | |
3 $postText = file_get_contents('php://input'); | 4 $postText = file_get_contents('php://input'); |
4 $datetime = date('ymdHis'); | 5 $datetime = date('ymdHis'); |
5 $xmlfile = "save".$datetime.".xml"; | 6 $xmlfile = "save".$datetime.".xml"; |
6 $fileHandle = fopen("saves/".$xmlfile, 'w'); | 7 $fileHandle = fopen("saves/".$xmlfile, 'w'); |
7 fwrite($fileHandle, $postText); | 8 if ($fileHandle == FALSE) |
9 { | |
10 // Filehandle failed | |
11 $xml = '<response state="error"><message>Could not open file</message></response>'; | |
12 echo $xml; | |
13 return; | |
14 } | |
15 $wbytes = fwrite($fileHandle, $postText); | |
16 if ($wbytes == FALSE) | |
17 { | |
18 // FileWrite failed | |
19 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>'; | |
20 echo $xml; | |
21 return; | |
22 } | |
8 fclose($fileHandle); | 23 fclose($fileHandle); |
24 | |
25 // Return JSON confirmation data | |
26 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>'; | |
27 echo $xml; | |
9 ?> | 28 ?> |