annotate save.php @ 429:9bf8ecbcdc8a Dev_main

Index page now links to example APE project, example MUSHRA project, test creator, analysis page, citing info, GNU license, and instructions. Instructions and example project contain info on checkboxes.
author Brecht De Man <b.deman@qmul.ac.uk>
date Fri, 18 Dec 2015 18:26:46 +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 ?>