changeset 2626:f41389149eab

#49: Embed the test file into the initial save.
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 19 Jan 2017 11:20:04 +0000
parents e3cf3c24149e
children 0bce959c42ed
files php/requestKey.php
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/php/requestKey.php	Thu Jan 19 10:47:42 2017 +0000
+++ b/php/requestKey.php	Thu Jan 19 11:20:04 2017 +0000
@@ -16,6 +16,12 @@
 header("Cache-Control: post-check=0, pre-check=0", false);
 header("Pragma: no-cache");
 
+// Get the current test URL
+$testURL = "";
+if (isset($_GET['url'])) {
+    $testURL = $_GET["url"];
+}
+
 $saves = glob("../saves/*.xml");
 
 $key = "";
@@ -44,18 +50,21 @@
 $filename = "../saves/save-".$key.".xml";
 $fileHandle = fopen($filename, 'w');
 if ($fileHandle == FALSE) {
-    echo "<response><state>ERROR</state><key>".$key."</key><message>Could not open file for writing</message></response>";
-    return;
+    die("<response><state>ERROR</state><key>".$key."</key><message>Could not open file for writing</message></response>");
 }
 fclose($fileHandle);
 // TODO:
 //  Generate the XML Base file and save it
 $doc_struct = new SimpleXMLElement('<waetresult/>');
 $doc_struct->addAttribute("key",$key);
+// Add the root
+if (file_exists($testURL)) {
+    $test_proto = new SimpleXMLElement(file_get_contents($testURL, FILE_TEXT));
+    $doc_struct->addChild($test_proto);
+}
 //  Add start time
 //  Add IP Address information
 //  Save the file
 $doc_struct->asXML($filename);
 echo "<response><state>OK</state><key>".$key."</key></response>";
-return;
 ?>