comparison save.php @ 0:d2eb0e6ccaaf

initial commit
author Giulio Moro <giuliomoro@yahoo.it>
date Wed, 20 Apr 2016 16:26:57 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d2eb0e6ccaaf
1 <?php
2 // error_reporting(0);
3 $saveFilenamePrefix = isset($_GET['saveFilenamePrefix']) ? $_GET['saveFilenamePrefix'].'-' : '';
4 header('Access-Control-Allow-Origin: *');
5 header("Content-type: text/xml");
6 $postText = file_get_contents('php://input');
7 $file_key = $_GET['key'];
8 $filename = 'saves/'.$saveFilenamePrefix.'save-'.$file_key.".xml";
9 $fileHandle = fopen($filename, '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 "'.$filename.'"</message></response>';
22 echo $xml;
23 return;
24 }
25 fclose($fileHandle);
26
27 // Return XML confirmation data
28 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>';
29 echo $xml;
30 ?>