changeset 2940:8805556c0f42

Potential fix for #235
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 14 Sep 2017 13:10:51 +0100
parents 5d7e33fd00d8
children cccb9c312b5d cacc7f1cf062
files js/core.js php/requestKey.php python/pythonServer.py
diffstat 3 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/js/core.js	Tue Sep 12 19:22:21 2017 +0100
+++ b/js/core.js	Thu Sep 14 13:10:51 2017 +0100
@@ -3591,7 +3591,7 @@
                     returnURL = specification.projectReturn;
                 }
             }
-            this.request.open("GET", returnURL + "php/requestKey.php", true);
+            this.request.open("GET", returnURL + "php/requestKey.php?saveFilenamePrefix=" + this.parent.filenamePrefix, true);
             this.request.addEventListener("load", this);
             this.request.send();
         },
--- a/php/requestKey.php	Tue Sep 12 19:22:21 2017 +0100
+++ b/php/requestKey.php	Thu Sep 14 13:10:51 2017 +0100
@@ -17,6 +17,13 @@
 header("Pragma: no-cache");
 
 // Get the current test URL
+// Load up the parameters
+$saveFilenamePrefix = '';
+if (isset($_GET['saveFilenamePrefix'])) {
+    $saveFilenamePrefix = $_GET['saveFilenamePrefix'].'-';
+} else {
+    $saveFilenamePrefix = "save-";
+}
 $testURL = "";
 if (isset($_GET['url'])) {
     $testURL = "../".$_GET["url"];
@@ -47,7 +54,7 @@
     }
 }
 
-$filename = "../saves/save-".$key.".xml";
+$filename = "../saves/".$saveFilenamePrefix.$key.".xml";
 $fileHandle = fopen($filename, 'w');
 if ($fileHandle == FALSE) {
     die("<response><state>ERROR</state><key>".$key."</key><message>Could not open file for writing</message></response>");
--- a/python/pythonServer.py	Tue Sep 12 19:22:21 2017 +0100
+++ b/python/pythonServer.py	Thu Sep 14 13:10:51 2017 +0100
@@ -120,6 +120,14 @@
         tempKey = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(32));
         if (os.path.isfile("saves/save-"+tempKey+".xml") == False):
             key = tempKey
+    options = s.path.rsplit('?')
+    options = options[1].rsplit('&')
+    for option in options:
+        optionPair = option.rsplit('=')
+        if optionPair[0] == "saveFilenamePrefix":
+            prefix = optionPair[1]
+    if prefix == None:
+        prefix = "save"
     s.send_response(200)
     s.send_header("Content-type", "application/xml");
     s.end_headers()
@@ -128,7 +136,7 @@
         s.wfile.write(reply)
     elif sys.version_info[0] == 3:
         s.wfile.write(bytes(reply, "utf-8"))
-    file = open("../saves/save-"+key+".xml",'w')
+    file = open("../saves/"+prefix+"-"+key+".xml",'w')
     file.write("<waetresult key=\""+key+"\"/>")
     file.close()