annotate save.php @ 1861:2334ab797100

Bug #1620: Defaults to Europe/London timezone.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Tue, 23 Feb 2016 16:57:06 +0000
parents 96b83aa64be3
children 310b4640b93d
rev   line source
b@1478 1 <?php
nickjillings@1861 2 date_default_timezone_set("Europe/London");
b@1508 3 header('Access-Control-Allow-Origin: *');
nickjillings@1510 4 header("Content-type: text/xml");
giuliomoro@1304 5 error_reporting(0);
b@1478 6 $postText = file_get_contents('php://input');
nickjillings@1466 7 $sha1_hash = sha1($postText);
b@1478 8 $datetime = date('ymdHis');
nickjillings@1466 9 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
b@1478 10 $fileHandle = fopen("saves/".$xmlfile, 'w');
nickjillings@1510 11 if ($fileHandle == FALSE)
nickjillings@1510 12 {
nickjillings@1510 13 // Filehandle failed
nickjillings@1510 14 $xml = '<response state="error"><message>Could not open file</message></response>';
nickjillings@1510 15 echo $xml;
nickjillings@1510 16 return;
nickjillings@1510 17 }
nickjillings@1510 18 $wbytes = fwrite($fileHandle, $postText);
giuliomoro@1856 19 if ($wbytes === FALSE)
nickjillings@1510 20 {
nickjillings@1510 21 // FileWrite failed
nickjillings@1510 22 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
nickjillings@1510 23 echo $xml;
nickjillings@1510 24 return;
nickjillings@1510 25 }
b@1478 26 fclose($fileHandle);
nickjillings@1510 27
nickjillings@1510 28 // Return JSON confirmation data
nickjillings@1510 29 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
nickjillings@1510 30 echo $xml;
giuliomoro@1855 31 ?>