comparison keygen.php @ 584:d8be8a1111b6 Dev_main

Adding PHP Keygen
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Tue, 08 Mar 2016 14:35:51 +0000
parents
children 0d6d7618f6da
comparison
equal deleted inserted replaced
583:6833d8c2b52e 584:d8be8a1111b6
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_bad = "<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 // Add start time
30 // Add IP Address information
31 return;
32 } else {
33 echo $xml_error;
34 return;
35 }
36 ?>