Mercurial > hg > webaudioevaluationtool
comparison php/requestKey.php @ 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 | fb8f43204ae0 |
children | 0bce959c42ed |
comparison
equal
deleted
inserted
replaced
2625:e3cf3c24149e | 2626:f41389149eab |
---|---|
13 | 13 |
14 // Request a new session key from the server | 14 // Request a new session key from the server |
15 header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); | 15 header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
16 header("Cache-Control: post-check=0, pre-check=0", false); | 16 header("Cache-Control: post-check=0, pre-check=0", false); |
17 header("Pragma: no-cache"); | 17 header("Pragma: no-cache"); |
18 | |
19 // Get the current test URL | |
20 $testURL = ""; | |
21 if (isset($_GET['url'])) { | |
22 $testURL = $_GET["url"]; | |
23 } | |
18 | 24 |
19 $saves = glob("../saves/*.xml"); | 25 $saves = glob("../saves/*.xml"); |
20 | 26 |
21 $key = ""; | 27 $key = ""; |
22 | 28 |
42 } | 48 } |
43 | 49 |
44 $filename = "../saves/save-".$key.".xml"; | 50 $filename = "../saves/save-".$key.".xml"; |
45 $fileHandle = fopen($filename, 'w'); | 51 $fileHandle = fopen($filename, 'w'); |
46 if ($fileHandle == FALSE) { | 52 if ($fileHandle == FALSE) { |
47 echo "<response><state>ERROR</state><key>".$key."</key><message>Could not open file for writing</message></response>"; | 53 die("<response><state>ERROR</state><key>".$key."</key><message>Could not open file for writing</message></response>"); |
48 return; | |
49 } | 54 } |
50 fclose($fileHandle); | 55 fclose($fileHandle); |
51 // TODO: | 56 // TODO: |
52 // Generate the XML Base file and save it | 57 // Generate the XML Base file and save it |
53 $doc_struct = new SimpleXMLElement('<waetresult/>'); | 58 $doc_struct = new SimpleXMLElement('<waetresult/>'); |
54 $doc_struct->addAttribute("key",$key); | 59 $doc_struct->addAttribute("key",$key); |
60 // Add the root | |
61 if (file_exists($testURL)) { | |
62 $test_proto = new SimpleXMLElement(file_get_contents($testURL, FILE_TEXT)); | |
63 $doc_struct->addChild($test_proto); | |
64 } | |
55 // Add start time | 65 // Add start time |
56 // Add IP Address information | 66 // Add IP Address information |
57 // Save the file | 67 // Save the file |
58 $doc_struct->asXML($filename); | 68 $doc_struct->asXML($filename); |
59 echo "<response><state>OK</state><key>".$key."</key></response>"; | 69 echo "<response><state>OK</state><key>".$key."</key></response>"; |
60 return; | |
61 ?> | 70 ?> |