annotate keygen.php @ 649:d1c58546814c Dev_main

Calibration sliders update on mouse move trigger
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Tue, 29 Mar 2016 14:37:07 +0100
parents 5b125fb39142
children ba6b9e1aaef5
rev   line source
n@584 1 <?php
n@584 2 // This checks the key sent by the JavaScript against the current bunch of saves
n@584 3 // XML Saves location - assumes it will be saves/
n@587 4 $saves = glob("saves/*.xml");
n@584 5
n@584 6 $key_requested = $_GET['key'];
n@584 7
n@584 8 $xml_good = "<response><state>OK</state><key>".$key_requested."</key></response>";
n@584 9 $xml_bad = "<response><state>NO</state><key>".$key_requested."</key></response>";
n@590 10 $xml_error = "<response><state>ERROR</state><key>".$key_requested."</key></response>";
n@584 11 if (is_array($saves))
n@584 12 {
n@584 13 foreach($saves as $filename) {
n@584 14 $xml_string = file_get_contents($filename, FILE_TEXT);
n@584 15 $xml_object = simplexml_load_string($xml_string);
n@584 16 if ($xml_object != false) {
n@584 17 if (isset($value['key']))
n@584 18 {
n@584 19 if ($value['key'] == $key_requested) {
n@584 20 echo $xml_bad;
n@584 21 return;
n@584 22 }
n@584 23 }
n@584 24 }
n@584 25 }
n@584 26 echo $xml_good;
n@584 27 // TODO:
n@584 28 // Generate the XML Base file and save it
n@587 29 $doc_struct = new SimpleXMLElement('<waetresult/>');
n@587 30 $doc_struct->addAttribute("key",$key_requested);
n@584 31 // Add start time
n@584 32 // Add IP Address information
n@587 33 // Save the file
n@587 34 $doc_struct->asXML("saves/save-".$key_requested.".xml");
n@584 35 return;
n@584 36 } else {
n@584 37 echo $xml_error;
n@584 38 return;
n@584 39 }
n@584 40 ?>