Mercurial > hg > webaudioevaluationtool
annotate save.php @ 1315:d9b9f707f862
Updated author list for WAC 2016
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Sun, 21 Feb 2016 11:15:52 +0000 |
parents | |
children | 2647dd909229 b5bf2f57187c 9ee921c8cdd3 |
rev | line source |
---|---|
nickjillings@1315 | 1 <?php |
nickjillings@1315 | 2 header('Access-Control-Allow-Origin: *'); |
nickjillings@1315 | 3 header("Content-type: text/xml"); |
nickjillings@1315 | 4 $postText = file_get_contents('php://input'); |
nickjillings@1315 | 5 $sha1_hash = sha1($postText); |
nickjillings@1315 | 6 $datetime = date('ymdHis'); |
nickjillings@1315 | 7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml"; |
nickjillings@1315 | 8 $fileHandle = fopen("saves/".$xmlfile, 'w'); |
nickjillings@1315 | 9 if ($fileHandle == FALSE) |
nickjillings@1315 | 10 { |
nickjillings@1315 | 11 // Filehandle failed |
nickjillings@1315 | 12 $xml = '<response state="error"><message>Could not open file</message></response>'; |
nickjillings@1315 | 13 echo $xml; |
nickjillings@1315 | 14 return; |
nickjillings@1315 | 15 } |
nickjillings@1315 | 16 $wbytes = fwrite($fileHandle, $postText); |
nickjillings@1315 | 17 if ($wbytes == FALSE) |
nickjillings@1315 | 18 { |
nickjillings@1315 | 19 // FileWrite failed |
nickjillings@1315 | 20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>'; |
nickjillings@1315 | 21 echo $xml; |
nickjillings@1315 | 22 return; |
nickjillings@1315 | 23 } |
nickjillings@1315 | 24 fclose($fileHandle); |
nickjillings@1315 | 25 |
nickjillings@1315 | 26 // Return JSON confirmation data |
nickjillings@1315 | 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>'; |
nickjillings@1315 | 28 echo $xml; |
nickjillings@1315 | 29 ?> |