annotate save.php @ 22:1f375b7d75fd tip

updated warning for breaks during test
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 13 May 2016 19:01:08 +0100
parents d2eb0e6ccaaf
children
rev   line source
giuliomoro@0 1 <?php
giuliomoro@0 2 // error_reporting(0);
giuliomoro@0 3 $saveFilenamePrefix = isset($_GET['saveFilenamePrefix']) ? $_GET['saveFilenamePrefix'].'-' : '';
giuliomoro@0 4 header('Access-Control-Allow-Origin: *');
giuliomoro@0 5 header("Content-type: text/xml");
giuliomoro@0 6 $postText = file_get_contents('php://input');
giuliomoro@0 7 $file_key = $_GET['key'];
giuliomoro@0 8 $filename = 'saves/'.$saveFilenamePrefix.'save-'.$file_key.".xml";
giuliomoro@0 9 $fileHandle = fopen($filename, 'w');
giuliomoro@0 10 if ($fileHandle == FALSE)
giuliomoro@0 11 {
giuliomoro@0 12 // Filehandle failed
giuliomoro@0 13 $xml = '<response state="error"><message>Could not open file</message></response>';
giuliomoro@0 14 echo $xml;
giuliomoro@0 15 return;
giuliomoro@0 16 }
giuliomoro@0 17 $wbytes = fwrite($fileHandle, $postText);
giuliomoro@0 18 if ($wbytes === FALSE)
giuliomoro@0 19 {
giuliomoro@0 20 // FileWrite failed
giuliomoro@0 21 $xml = '<response state="error"><message>Could not write file "'.$filename.'"</message></response>';
giuliomoro@0 22 echo $xml;
giuliomoro@0 23 return;
giuliomoro@0 24 }
giuliomoro@0 25 fclose($fileHandle);
giuliomoro@0 26
giuliomoro@0 27 // Return XML confirmation data
giuliomoro@0 28 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>';
giuliomoro@0 29 echo $xml;
giuliomoro@0 30 ?>