Mercurial > hg > webaudioevaluationtool
comparison save.php @ 1292:a6cfd378891c
Minor corrections to PHP save script.
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Thu, 10 Mar 2016 10:04:38 +0000 |
parents | 175cf75946f7 |
children | ba6b9e1aaef5 |
comparison
equal
deleted
inserted
replaced
1291:6b2ae5d87a64 | 1292:a6cfd378891c |
---|---|
1 <?php | 1 <?php |
2 error_reporting(0); | 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: *'); | 3 header('Access-Control-Allow-Origin: *'); |
10 header("Content-type: text/xml"); | 4 header("Content-type: text/xml"); |
11 $postText = file_get_contents('php://input'); | 5 $postText = file_get_contents('php://input'); |
12 $file_key = $_GET['key']; | 6 $file_key = $_GET['key']; |
13 $filename = "saves/save-".$file_key.".xml"; | 7 $filename = "saves/save-".$file_key.".xml"; |
21 } | 15 } |
22 $wbytes = fwrite($fileHandle, $postText); | 16 $wbytes = fwrite($fileHandle, $postText); |
23 if ($wbytes === FALSE) | 17 if ($wbytes === FALSE) |
24 { | 18 { |
25 // FileWrite failed | 19 // FileWrite failed |
26 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>'; | 20 $xml = '<response state="error"><message>Could not write file "'.$filename.'"</message></response>'; |
27 echo $xml; | 21 echo $xml; |
28 return; | 22 return; |
29 } | 23 } |
30 fclose($fileHandle); | 24 fclose($fileHandle); |
31 | 25 |
32 // Return JSON confirmation data | 26 // Return XML confirmation data |
33 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>'; | 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>'; |
34 echo $xml; | 28 echo $xml; |
35 ?> | 29 ?> |