annotate save.php @ 1309:e8b1aa4f2c0a

Python score/comment parsers use new <page> rather than deprecated <audioholder>. Added score_parser.php
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Thu, 18 Feb 2016 10:55:36 +0000
parents cc55cc323592
children 2647dd909229 b5bf2f57187c 9ee921c8cdd3
rev   line source
nickjillings@1306 1 <?php
nickjillings@1306 2 header('Access-Control-Allow-Origin: *');
nickjillings@1306 3 header("Content-type: text/xml");
nickjillings@1306 4 $postText = file_get_contents('php://input');
nickjillings@1306 5 $sha1_hash = sha1($postText);
nickjillings@1306 6 $datetime = date('ymdHis');
nickjillings@1306 7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
nickjillings@1306 8 $fileHandle = fopen("saves/".$xmlfile, 'w');
nickjillings@1306 9 if ($fileHandle == FALSE)
nickjillings@1306 10 {
nickjillings@1306 11 // Filehandle failed
nickjillings@1306 12 $xml = '<response state="error"><message>Could not open file</message></response>';
nickjillings@1306 13 echo $xml;
nickjillings@1306 14 return;
nickjillings@1306 15 }
nickjillings@1306 16 $wbytes = fwrite($fileHandle, $postText);
nickjillings@1306 17 if ($wbytes == FALSE)
nickjillings@1306 18 {
nickjillings@1306 19 // FileWrite failed
nickjillings@1306 20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
nickjillings@1306 21 echo $xml;
nickjillings@1306 22 return;
nickjillings@1306 23 }
nickjillings@1306 24 fclose($fileHandle);
nickjillings@1306 25
nickjillings@1306 26 // Return JSON confirmation data
nickjillings@1306 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
nickjillings@1306 28 echo $xml;
nickjillings@1306 29 ?>