annotate keygen.php @ 1241:879b0b20b20c

WIP. Adding intermediate save options. Will require mass editing of save engine as it stands, so still WIP (note: this version will not work on python server).
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Wed, 09 Mar 2016 11:12:06 +0000
parents a54422902bbd
children 5b125fb39142
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@1239 10 $xml_bad = "<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 ?>