Mercurial > hg > webaudioevaluationtool
changeset 2515:913d7c132ab6
Removed references to old keygen system.
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Mon, 24 Oct 2016 11:07:45 +0100 |
parents | fb8f43204ae0 |
children | 22673a6cfcfb |
files | js/core.js php/keygen.php python/pythonServer.py |
diffstat | 3 files changed, 6 insertions(+), 92 deletions(-) [+] |
line wrap: on
line diff
--- a/js/core.js Mon Oct 24 11:01:55 2016 +0100 +++ b/js/core.js Mon Oct 24 11:07:45 2016 +0100 @@ -3130,9 +3130,8 @@ handleEvent: function () { var parse = new DOMParser(); var xml = parse.parseFromString(this.request.response, "text/xml"); - var shouldGenerateKey = true; if (this.request.response.length == 0) { - console.log("Error: Server did not respond"); + console.error("An unspecified error occured, no server key could be generated"); return; } if (xml.getElementsByTagName("state").length > 0) { @@ -3140,27 +3139,15 @@ this.key = xml.getAllElementsByTagName("key")[0].textContent; this.parent.root.setAttribute("key", this.key); this.parent.root.setAttribute("state", "empty"); - shouldGenerateKey = false; + return; } else if (xml.getElementsByTagName("state")[0].textContent == "ERROR") { + this.key = null; console.error("Could not generate server key. Server responded with error message: \"" + xml.getElementsByTagName("message")[0].textContent + "\""); - shouldGenerateKey = false; + return; } } - if (shouldGenerateKey === true) { - this.generateKey(); - } - }, - generateKey: function () { - var temp_key = randomString(32); - var returnURL = ""; - if (typeof specification.projectReturn == "string") { - if (specification.projectReturn.substr(0, 4) == "http") { - returnURL = specification.projectReturn; - } - } - this.request.open("GET", returnURL + "php/keygen.php?key=" + temp_key, true); - this.request.addEventListener("load", this); - this.request.send(); + this.key = null; + console.error("An unspecified error occured, no server key could be generated"); }, requestKey: function () { // For new servers, request a new key from the server
--- a/php/keygen.php Mon Oct 24 11:01:55 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -<?php -header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -// 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_error = "<response><state>ERROR</state><key>".$key_requested."</key><message>Could not open file for writing</message></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; - } - } - } - } - $filename = "../saves/save-".$key_requested.".xml"; - $fileHandle = fopen($filename, 'c'); - if ($fileHandle == FALSE) { - echo $xml_error; - return; - } - fclose($fileHandle); - // TODO: - // Generate the XML Base file and save it - $doc_struct = new SimpleXMLElement('<waetresult/>'); - $doc_struct->addAttribute("key",$key_requested); - // Add start time - // Add IP Address information - // Save the file - $doc_struct->asXML($filename); - echo $xml_good; - return; -} else { - echo $xml_error; - return; -} -?>
--- a/python/pythonServer.py Mon Oct 24 11:01:55 2016 +0100 +++ b/python/pythonServer.py Mon Oct 24 11:07:45 2016 +0100 @@ -111,27 +111,6 @@ s.send_header("Content-Length", len(fileBytes)) s.end_headers() s.wfile.write(fileBytes) - -def keygen(s): - reply = "" - options = s.path.rsplit('?') - options = options[1].rsplit('=') - key = options[1] - print("Registered key "+key) - if os.path.isfile("saves/save-"+key+".xml"): - reply = "<response><state>NO</state><key>"+key+"</key></response>" - else: - reply = "<response><state>OK</state><key>"+key+"</key></response>" - s.send_response(200) - s.send_header("Content-type", "application/xml") - s.end_headers() - if sys.version_info[0] == 2: - 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.write("<waetresult key="+key+"/>") - file.close(); def requestKey(s): reply = "" @@ -248,8 +227,6 @@ if(request.client_address[0] == "127.0.0.1"): if (request.path == "/favicon.ico"): send404(request) - elif (request.path.split('?',1)[0] == "/php/keygen.php"): - keygen(request); elif (request.path.split('?',1)[0] == "/php/requestKey.php"): requestKey(request); elif (request.path.split('?',1)[0] == "/php/pool.php"):