Mercurial > hg > webaudioevaluationtool
comparison php/keygen.php @ 2224:760719986df3
Tidy up file locations.
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Thu, 14 Apr 2016 13:54:24 +0100 |
parents | |
children | d26623bd65e0 |
comparison
equal
deleted
inserted
replaced
2222:4d1aa94202e3 | 2224:760719986df3 |
---|---|
1 <?php | |
2 // This checks the key sent by the JavaScript against the current bunch of saves | |
3 // XML Saves location - assumes it will be saves/ | |
4 $saves = glob("../saves/*.xml"); | |
5 | |
6 $key_requested = $_GET['key']; | |
7 | |
8 $xml_good = "<response><state>OK</state><key>".$key_requested."</key></response>"; | |
9 $xml_bad = "<response><state>NO</state><key>".$key_requested."</key></response>"; | |
10 $xml_error = "<response><state>ERROR</state><key>".$key_requested."</key></response>"; | |
11 if (is_array($saves)) | |
12 { | |
13 foreach($saves as $filename) { | |
14 $xml_string = file_get_contents($filename, FILE_TEXT); | |
15 $xml_object = simplexml_load_string($xml_string); | |
16 if ($xml_object != false) { | |
17 if (isset($value['key'])) | |
18 { | |
19 if ($value['key'] == $key_requested) { | |
20 echo $xml_bad; | |
21 return; | |
22 } | |
23 } | |
24 } | |
25 } | |
26 echo $xml_good; | |
27 // TODO: | |
28 // Generate the XML Base file and save it | |
29 $doc_struct = new SimpleXMLElement('<waetresult/>'); | |
30 $doc_struct->addAttribute("key",$key_requested); | |
31 // Add start time | |
32 // Add IP Address information | |
33 // Save the file | |
34 $doc_struct->asXML("saves/save-".$key_requested.".xml"); | |
35 return; | |
36 } else { | |
37 echo $xml_error; | |
38 return; | |
39 } | |
40 ?> |