Mercurial > hg > webaudioevaluationtool
annotate save.php @ 1842:2b0dd74c1310
Started Bug #1604: New test dialog windows now use <label> instead of span.
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Mon, 22 Feb 2016 14:20:50 +0000 |
parents | 616c602a6a6e |
children | dc4300033afc |
rev | line source |
---|---|
b@1478 | 1 <?php |
b@1508 | 2 header('Access-Control-Allow-Origin: *'); |
nickjillings@1510 | 3 header("Content-type: text/xml"); |
giuliomoro@1304 | 4 error_reporting(0); |
b@1478 | 5 $postText = file_get_contents('php://input'); |
nickjillings@1466 | 6 $sha1_hash = sha1($postText); |
b@1478 | 7 $datetime = date('ymdHis'); |
nickjillings@1466 | 8 $xmlfile = "save".$datetime."-".$sha1_hash.".xml"; |
b@1478 | 9 $fileHandle = fopen("saves/".$xmlfile, 'w'); |
nickjillings@1510 | 10 if ($fileHandle == FALSE) |
nickjillings@1510 | 11 { |
nickjillings@1510 | 12 // Filehandle failed |
nickjillings@1510 | 13 $xml = '<response state="error"><message>Could not open file</message></response>'; |
nickjillings@1510 | 14 echo $xml; |
nickjillings@1510 | 15 return; |
nickjillings@1510 | 16 } |
nickjillings@1510 | 17 $wbytes = fwrite($fileHandle, $postText); |
nickjillings@1510 | 18 if ($wbytes == FALSE) |
nickjillings@1510 | 19 { |
nickjillings@1510 | 20 // FileWrite failed |
nickjillings@1510 | 21 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>'; |
nickjillings@1510 | 22 echo $xml; |
nickjillings@1510 | 23 return; |
nickjillings@1510 | 24 } |
b@1478 | 25 fclose($fileHandle); |
nickjillings@1510 | 26 |
nickjillings@1510 | 27 // Return JSON confirmation data |
nickjillings@1510 | 28 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>'; |
nickjillings@1510 | 29 echo $xml; |
b@1478 | 30 ?> |