annotate save.php @ 1868:ce5596e255d1

Created mean test/page plots, element histogram plots. Latex and tables included. Can download charts as PNG
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Wed, 24 Feb 2016 13:03:08 +0000
parents 40f256900cb5
children 8c56eda17acd
rev   line source
b@1478 1 <?php
nickjillings@1862 2 try{
nickjillings@1862 3 date_default_timezone_get();
nickjillings@1862 4 }
nickjillings@1862 5 catch(Exception $e){
nickjillings@1862 6 date_default_timezone_set('UTC'); // Sets to UTC if not specified anywhere in .ini
nickjillings@1862 7 }
b@1508 8 header('Access-Control-Allow-Origin: *');
nickjillings@1510 9 header("Content-type: text/xml");
giuliomoro@1304 10 error_reporting(0);
b@1478 11 $postText = file_get_contents('php://input');
nickjillings@1466 12 $sha1_hash = sha1($postText);
b@1478 13 $datetime = date('ymdHis');
nickjillings@1466 14 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
b@1478 15 $fileHandle = fopen("saves/".$xmlfile, 'w');
nickjillings@1510 16 if ($fileHandle == FALSE)
nickjillings@1510 17 {
nickjillings@1510 18 // Filehandle failed
nickjillings@1510 19 $xml = '<response state="error"><message>Could not open file</message></response>';
nickjillings@1510 20 echo $xml;
nickjillings@1510 21 return;
nickjillings@1510 22 }
nickjillings@1510 23 $wbytes = fwrite($fileHandle, $postText);
giuliomoro@1856 24 if ($wbytes === FALSE)
nickjillings@1510 25 {
nickjillings@1510 26 // FileWrite failed
nickjillings@1510 27 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
nickjillings@1510 28 echo $xml;
nickjillings@1510 29 return;
nickjillings@1510 30 }
b@1478 31 fclose($fileHandle);
nickjillings@1510 32
nickjillings@1510 33 // Return JSON confirmation data
nickjillings@1510 34 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
nickjillings@1510 35 echo $xml;
giuliomoro@1855 36 ?>