Mercurial > hg > webaudioevaluationtool
comparison save.php @ 1289:175cf75946f7
Merge
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Wed, 09 Mar 2016 14:36:47 +0000 |
parents | |
children | f4f9cde581aa |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 1289:175cf75946f7 |
---|---|
1 <?php | |
2 error_reporting(0); | |
3 try{ | |
4 date_default_timezone_get(); | |
5 } | |
6 catch(Exception $e){ | |
7 date_default_timezone_set('UTC'); // Sets to UTC if not specified anywhere in .ini | |
8 } | |
9 header('Access-Control-Allow-Origin: *'); | |
10 header("Content-type: text/xml"); | |
11 $postText = file_get_contents('php://input'); | |
12 $file_key = $_GET['key']; | |
13 $filename = "saves/save-".$file_key.".xml"; | |
14 $fileHandle = fopen($filename, 'w'); | |
15 if ($fileHandle == FALSE) | |
16 { | |
17 // Filehandle failed | |
18 $xml = '<response state="error"><message>Could not open file</message></response>'; | |
19 echo $xml; | |
20 return; | |
21 } | |
22 $wbytes = fwrite($fileHandle, $postText); | |
23 if ($wbytes === FALSE) | |
24 { | |
25 // FileWrite failed | |
26 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>'; | |
27 echo $xml; | |
28 return; | |
29 } | |
30 fclose($fileHandle); | |
31 | |
32 // Return JSON confirmation data | |
33 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>'; | |
34 echo $xml; | |
35 ?> |