annotate save.php @ 614:ecca9c11d2f2 multiple-tests-concatenation

removed garbage
author Giulio Moro <giuliomoro@yahoo.it>
date Sun, 13 Mar 2016 15:33:36 +0000
parents 0256f3748b27
children
rev   line source
n@292 1 <?php
giuliomoro@608 2 // error_reporting(0);
giuliomoro@607 3 $saveFilenamePrefix = isset($_GET['saveFilenamePrefix']) ? $_GET['saveFilenamePrefix'].'-' : '';
b@343 4 header('Access-Control-Allow-Origin: *');
nicholas@345 5 header("Content-type: text/xml");
n@292 6 $postText = file_get_contents('php://input');
n@589 7 $file_key = $_GET['key'];
giuliomoro@608 8 $filename = 'saves/'.$saveFilenamePrefix.'save-'.$file_key.".xml";
n@589 9 $fileHandle = fopen($filename, 'w');
nicholas@345 10 if ($fileHandle == FALSE)
nicholas@345 11 {
nicholas@345 12 // Filehandle failed
nicholas@345 13 $xml = '<response state="error"><message>Could not open file</message></response>';
nicholas@345 14 echo $xml;
nicholas@345 15 return;
nicholas@345 16 }
nicholas@345 17 $wbytes = fwrite($fileHandle, $postText);
giuliomoro@556 18 if ($wbytes === FALSE)
nicholas@345 19 {
nicholas@345 20 // FileWrite failed
n@600 21 $xml = '<response state="error"><message>Could not write file "'.$filename.'"</message></response>';
nicholas@345 22 echo $xml;
nicholas@345 23 return;
nicholas@345 24 }
n@292 25 fclose($fileHandle);
nicholas@345 26
n@600 27 // Return XML confirmation data
n@600 28 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>';
nicholas@345 29 echo $xml;
n@600 30 ?>