annotate keygen.php @ 2202:61c8e13f1e2e

Merge branch 'master' of https://github.com/BrechtDeMan/WebAudioEvaluationTool
author www-data <www-data@sucuk.dcs.qmul.ac.uk>
date Fri, 08 Apr 2016 13:20:54 +0100
parents ba6b9e1aaef5
children
rev   line source
n@1239 1 <?php
n@1239 2 // This checks the key sent by the JavaScript against the current bunch of saves
n@1239 3 // XML Saves location - assumes it will be saves/
n@1241 4 $saves = glob("saves/*.xml");
n@1239 5
n@1239 6 $key_requested = $_GET['key'];
n@1239 7
n@1239 8 $xml_good = "<response><state>OK</state><key>".$key_requested."</key></response>";
n@1239 9 $xml_bad = "<response><state>NO</state><key>".$key_requested."</key></response>";
n@1243 10 $xml_error = "<response><state>ERROR</state><key>".$key_requested."</key></response>";
n@1239 11 if (is_array($saves))
n@1239 12 {
n@1239 13 foreach($saves as $filename) {
n@1239 14 $xml_string = file_get_contents($filename, FILE_TEXT);
n@1239 15 $xml_object = simplexml_load_string($xml_string);
n@1239 16 if ($xml_object != false) {
n@1239 17 if (isset($value['key']))
n@1239 18 {
n@1239 19 if ($value['key'] == $key_requested) {
n@1239 20 echo $xml_bad;
n@1239 21 return;
n@1239 22 }
n@1239 23 }
n@1239 24 }
n@1239 25 }
n@1239 26 echo $xml_good;
n@1239 27 // TODO:
n@1239 28 // Generate the XML Base file and save it
n@1241 29 $doc_struct = new SimpleXMLElement('<waetresult/>');
n@1241 30 $doc_struct->addAttribute("key",$key_requested);
n@1239 31 // Add start time
n@1239 32 // Add IP Address information
n@1241 33 // Save the file
n@1241 34 $doc_struct->asXML("saves/save-".$key_requested.".xml");
n@1239 35 return;
n@1239 36 } else {
n@1239 37 echo $xml_error;
n@1239 38 return;
n@1239 39 }
n@1239 40 ?>