diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keygen.php	Tue Mar 08 14:35:51 2016 +0000
@@ -0,0 +1,36 @@
+<?php
+// This checks the key sent by the JavaScript against the current bunch of saves
+// XML Saves location - assumes it will be saves/
+$saves = glob("../saves/*.xml");
+
+$key_requested = $_GET['key'];
+
+$xml_good = "<response><state>OK</state><key>".$key_requested."</key></response>";
+$xml_bad = "<response><state>NO</state><key>".$key_requested."</key></response>";
+$xml_bad = "<response><state>ERROR</state><key>".$key_requested."</key></response>";
+if (is_array($saves))
+{
+    foreach($saves as $filename) {
+        $xml_string = file_get_contents($filename, FILE_TEXT);
+        $xml_object = simplexml_load_string($xml_string);
+        if ($xml_object != false) {
+            if (isset($value['key']))
+            {
+                if ($value['key'] == $key_requested) {
+                    echo $xml_bad;
+                    return;
+                }
+            }
+        }
+    }
+    echo $xml_good;
+    // TODO:
+    //  Generate the XML Base file and save it
+    //  Add start time
+    //  Add IP Address information
+    return;
+} else {
+    echo $xml_error;
+    return;
+}
+?>
\ No newline at end of file