Mercurial > hg > webaudioevaluationtool
annotate save.php @ 2128:098aaf69bdbe
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 | d071acc7160e |
children | 310b4640b93d |
rev | line source |
---|---|
b@1478 | 1 <?php |
nickjillings@2128 | 2 date_default_timezone_set("Europe/London"); |
b@1969 | 3 header('Access-Control-Allow-Origin: *'); |
nickjillings@1971 | 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@1971 | 11 if ($fileHandle == FALSE) |
nickjillings@1971 | 12 { |
nickjillings@1971 | 13 // Filehandle failed |
nickjillings@1971 | 14 $xml = '<response state="error"><message>Could not open file</message></response>'; |
nickjillings@1971 | 15 echo $xml; |
nickjillings@1971 | 16 return; |
nickjillings@1971 | 17 } |
nickjillings@1971 | 18 $wbytes = fwrite($fileHandle, $postText); |
giuliomoro@2123 | 19 if ($wbytes === FALSE) |
nickjillings@1971 | 20 { |
nickjillings@1971 | 21 // FileWrite failed |
nickjillings@1971 | 22 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>'; |
nickjillings@1971 | 23 echo $xml; |
nickjillings@1971 | 24 return; |
nickjillings@1971 | 25 } |
b@1478 | 26 fclose($fileHandle); |
nickjillings@1971 | 27 |
nickjillings@1971 | 28 // Return JSON confirmation data |
nickjillings@1971 | 29 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>'; |
nickjillings@1971 | 30 echo $xml; |
giuliomoro@2122 | 31 ?> |