Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion html-Common/SQL/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ <h1 align="center">SQL database</h1>
</body>
</html>

<script src="./sql.js?v=11" async></script>
<script type="module" src="./sql.js?v=11" async></script>
38 changes: 5 additions & 33 deletions html-Common/SQL/sql.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { GetPSQLTable } from "/includes/functions.js";

var output = document.getElementById("output");
var tableselect = document.getElementById("tableselect");
var select = document.querySelector('select');
Expand All @@ -9,39 +11,9 @@ var limit= document.getElementById("limit");
//update dropdown at startup
updatedropdown();


function gettable(command){ //generic get sql table command

return new Promise(function(resolve, reject){
var xhr = new XMLHttpRequest();

var url = "/cgi-bin/sqlquery.cgi";

var user ="root";
var db="daq";

// Set the request method to POST
xhr.open("POST", url);

// Set the request header to indicate that the request body contains form data
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");


var dataString = "user=" + user + "&db=" + db + "&command=" + command;


// Send the request
xhr.send(dataString);

xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {

resolve(xhr.responseText);
}
// else reject(new Error('error loading'));
}
});


function gettable(command) {
return GetPSQLTable(command, 'root', 'daq', true);
}


Expand Down
4 changes: 3 additions & 1 deletion html-Common/includes/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ export function SendSCCommand(ip, port, command_output, ...incommands){

export function GetPSQLTable(command, user, database, async=false){

var data_string = "user=" + user + "&db=" + database + "&command=" + command;
var data_string = "user=" + user
+ "&db=" + database
+ "&command=" + encodeURIComponent(command);

return HTTPRequest("POST", "/cgi-bin/sqlquery.cgi", async, data_string);

Expand Down
6 changes: 3 additions & 3 deletions html-StandAlone/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ function gettable(command){ //generic get sql table command
// Set the request header to indicate that the request body contains form data
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");


var dataString = "user=" + user + "&db=" + db + "&command=" + command;

var dataString = "user=" + user
+ "&db=" + db
+ "&command=" + encodeURIComponent(command);

// Send the request
xhr.send(dataString);
Expand Down