comparison save.php @ 1088:3705f68a38b7

The version I use and works, addresses issues #1622, #1616, partially #1620
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 22 Feb 2016 04:17:19 +0000
parents
children 9ee921c8cdd3
comparison
equal deleted inserted replaced
-1:000000000000 1088:3705f68a38b7
1 <?php
2 header('Access-Control-Allow-Origin: *');
3 header("Content-type: text/xml");
4 error_reporting(0);
5 $postText = file_get_contents('php://input');
6 $sha1_hash = sha1($postText);
7 $datetime = date('ymdHis');
8 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
9 $fileHandle = fopen("saves/".$xmlfile, 'w');
10 if ($fileHandle == FALSE)
11 {
12 // Filehandle failed
13 $xml = '<response state="error"><message>Could not open file</message></response>';
14 echo $xml;
15 return;
16 }
17 $wbytes = fwrite($fileHandle, $postText);
18 if ($wbytes == FALSE)
19 {
20 // FileWrite failed
21 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
22 echo $xml;
23 return;
24 }
25 fclose($fileHandle);
26
27 // Return JSON confirmation data
28 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
29 echo $xml;
30 ?>