annotate save.php @ 1818:1f80c5b9aecb

Add DMRN Proposal
author DaveM <djmoffat@users.noreply.github.com>
date Mon, 07 Dec 2015 11:21:01 +0000
parents 65b97da472dc
children 47bfd9594617
rev   line source
b@1478 1 <?php
b@1508 2 header('Access-Control-Allow-Origin: *');
nickjillings@1510 3 header("Content-type: text/xml");
b@1478 4 $postText = file_get_contents('php://input');
nickjillings@1466 5 $sha1_hash = sha1($postText);
b@1478 6 $datetime = date('ymdHis');
nickjillings@1466 7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
b@1478 8 $fileHandle = fopen("saves/".$xmlfile, 'w');
nickjillings@1510 9 if ($fileHandle == FALSE)
nickjillings@1510 10 {
nickjillings@1510 11 // Filehandle failed
nickjillings@1510 12 $xml = '<response state="error"><message>Could not open file</message></response>';
nickjillings@1510 13 echo $xml;
nickjillings@1510 14 return;
nickjillings@1510 15 }
nickjillings@1510 16 $wbytes = fwrite($fileHandle, $postText);
nickjillings@1510 17 if ($wbytes == FALSE)
nickjillings@1510 18 {
nickjillings@1510 19 // FileWrite failed
nickjillings@1510 20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
nickjillings@1510 21 echo $xml;
nickjillings@1510 22 return;
nickjillings@1510 23 }
b@1478 24 fclose($fileHandle);
nickjillings@1510 25
nickjillings@1510 26 // Return JSON confirmation data
nickjillings@1510 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
nickjillings@1510 28 echo $xml;
b@1478 29 ?>