Mercurial > hg > webaudioevaluationtool
comparison save.php @ 767:d7f2912bf487
test_create: Specification Node handles complete XML to DOM and DOM to XML conversions
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Fri, 04 Dec 2015 18:34:04 +0000 |
parents | |
children | 2647dd909229 b5bf2f57187c 9ee921c8cdd3 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 767:d7f2912bf487 |
---|---|
1 <?php | |
2 header('Access-Control-Allow-Origin: *'); | |
3 header("Content-type: text/xml"); | |
4 $postText = file_get_contents('php://input'); | |
5 $sha1_hash = sha1($postText); | |
6 $datetime = date('ymdHis'); | |
7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml"; | |
8 $fileHandle = fopen("saves/".$xmlfile, 'w'); | |
9 if ($fileHandle == FALSE) | |
10 { | |
11 // Filehandle failed | |
12 $xml = '<response state="error"><message>Could not open file</message></response>'; | |
13 echo $xml; | |
14 return; | |
15 } | |
16 $wbytes = fwrite($fileHandle, $postText); | |
17 if ($wbytes == FALSE) | |
18 { | |
19 // FileWrite failed | |
20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>'; | |
21 echo $xml; | |
22 return; | |
23 } | |
24 fclose($fileHandle); | |
25 | |
26 // Return JSON confirmation data | |
27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>'; | |
28 echo $xml; | |
29 ?> |