annotate save.php @ 1401:fae9a971f6b3

APE: Separate metric trackers for each scale to differentiate movements.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Fri, 11 Dec 2015 10:21:48 +0000
parents 8147e19de61b
children 2647dd909229 b5bf2f57187c 9ee921c8cdd3
rev   line source
nickjillings@1400 1 <?php
nickjillings@1400 2 header('Access-Control-Allow-Origin: *');
nickjillings@1400 3 header("Content-type: text/xml");
nickjillings@1400 4 $postText = file_get_contents('php://input');
nickjillings@1400 5 $sha1_hash = sha1($postText);
nickjillings@1400 6 $datetime = date('ymdHis');
nickjillings@1400 7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
nickjillings@1400 8 $fileHandle = fopen("saves/".$xmlfile, 'w');
nickjillings@1400 9 if ($fileHandle == FALSE)
nickjillings@1400 10 {
nickjillings@1400 11 // Filehandle failed
nickjillings@1400 12 $xml = '<response state="error"><message>Could not open file</message></response>';
nickjillings@1400 13 echo $xml;
nickjillings@1400 14 return;
nickjillings@1400 15 }
nickjillings@1400 16 $wbytes = fwrite($fileHandle, $postText);
nickjillings@1400 17 if ($wbytes == FALSE)
nickjillings@1400 18 {
nickjillings@1400 19 // FileWrite failed
nickjillings@1400 20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
nickjillings@1400 21 echo $xml;
nickjillings@1400 22 return;
nickjillings@1400 23 }
nickjillings@1400 24 fclose($fileHandle);
nickjillings@1400 25
nickjillings@1400 26 // Return JSON confirmation data
nickjillings@1400 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
nickjillings@1400 28 echo $xml;
nickjillings@1400 29 ?>