annotate save.php @ 483:a275f9689af6 Dev_main

Adding volume control interface object. Minor discrete layout format change.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 22 Jan 2016 11:10:33 +0000
parents 9823ee8c823e
children a95d323a911e
rev   line source
n@292 1 <?php
b@343 2 header('Access-Control-Allow-Origin: *');
nicholas@345 3 header("Content-type: text/xml");
n@292 4 $postText = file_get_contents('php://input');
nicholas@357 5 $sha1_hash = sha1($postText);
n@292 6 $datetime = date('ymdHis');
nicholas@357 7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
n@292 8 $fileHandle = fopen("saves/".$xmlfile, 'w');
nicholas@345 9 if ($fileHandle == FALSE)
nicholas@345 10 {
nicholas@345 11 // Filehandle failed
nicholas@345 12 $xml = '<response state="error"><message>Could not open file</message></response>';
nicholas@345 13 echo $xml;
nicholas@345 14 return;
nicholas@345 15 }
nicholas@345 16 $wbytes = fwrite($fileHandle, $postText);
nicholas@345 17 if ($wbytes == FALSE)
nicholas@345 18 {
nicholas@345 19 // FileWrite failed
nicholas@345 20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
nicholas@345 21 echo $xml;
nicholas@345 22 return;
nicholas@345 23 }
n@292 24 fclose($fileHandle);
nicholas@345 25
nicholas@345 26 // Return JSON confirmation data
nicholas@345 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
nicholas@345 28 echo $xml;
n@292 29 ?>