annotate php/keygen.php @ 2297:b0b4d264d9a8

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