fix/optimize wtv-admin
This commit is contained in:
@@ -242,6 +242,7 @@ const runScriptInVM = function (script_data, user_contextObj = {}, privileged =
|
|||||||
"wtvmime": wtvmime,
|
"wtvmime": wtvmime,
|
||||||
"http": http,
|
"http": http,
|
||||||
"https": https,
|
"https": https,
|
||||||
|
"util": util,
|
||||||
"sharp": sharp,
|
"sharp": sharp,
|
||||||
"nunjucks": nunjucks,
|
"nunjucks": nunjucks,
|
||||||
"URL": URL,
|
"URL": URL,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
var auth = wtva.isAuthorized();
|
const auth = wtva.isAuthorized();
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let password = null;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
@@ -83,12 +83,12 @@ if (auth === true) {
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(403, auth);
|
const errpage = wtvshared.doErrorPage(403, auth);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
var auth = wtva.isAuthorized();
|
const auth = wtva.isAuthorized();
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let result, ssid, password;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
@@ -14,8 +14,8 @@ if (auth === true) {
|
|||||||
}
|
}
|
||||||
if (wtva.checkPassword(password)) {
|
if (wtva.checkPassword(password)) {
|
||||||
if (request_headers.query.ssid) {
|
if (request_headers.query.ssid) {
|
||||||
var ssid = request_headers.query.ssid.toLowerCase();
|
ssid = request_headers.query.ssid.toLowerCase();
|
||||||
var result = wtva.banSSID(ssid, socket.ssid);
|
result = wtva.banSSID(ssid, socket.ssid);
|
||||||
}
|
}
|
||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
Content-Type: text/html
|
Content-Type: text/html
|
||||||
@@ -69,12 +69,12 @@ wtv-expire-all: wtv-admin:/ban`;
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(403, auth);
|
const errpage = wtvshared.doErrorPage(403, auth);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
var auth = wtva.isAuthorized();
|
const auth = wtva.isAuthorized();
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let user_info, ssid, password;
|
||||||
|
let ssid_match = false;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
@@ -14,16 +15,15 @@ if (auth === true) {
|
|||||||
}
|
}
|
||||||
if (wtva.checkPassword(password)) {
|
if (wtva.checkPassword(password)) {
|
||||||
if (request_headers.query.ssid) {
|
if (request_headers.query.ssid) {
|
||||||
var ssid_match = false;
|
ssid = request_headers.query.ssid.toLowerCase();
|
||||||
var ssid = request_headers.query.ssid.toLowerCase();
|
user_info = wtva.getAccountInfoBySSID(ssid);
|
||||||
var user_info = wtva.getAccountInfoBySSID(ssid);
|
|
||||||
if (request_headers.query.confirm_delete) {
|
if (request_headers.query.confirm_delete) {
|
||||||
user_info = null;
|
user_info = null;
|
||||||
if (ssid == socket.ssid) {
|
if (ssid == socket.ssid) {
|
||||||
ssid_match = true;
|
ssid_match = true;
|
||||||
} else {
|
} else {
|
||||||
// delete
|
// delete
|
||||||
var userAccount = wtva.getAccountBySSID(ssid);
|
const userAccount = wtva.getAccountBySSID(ssid);
|
||||||
userAccount.unregisterBox();
|
userAccount.unregisterBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,12 +101,12 @@ wtv-noback-all: wtv-admin:/deleteaccount`;
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(403, auth);
|
const errpage = wtvshared.doErrorPage(403, auth);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,17 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
var auth = wtva.isAuthorized();
|
const auth = wtva.isAuthorized();
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let user_info;
|
||||||
|
let password = null;
|
||||||
|
let show_cannot_modify_self = false;
|
||||||
|
let show_cannot_remove_primary = false;
|
||||||
|
let result = false;
|
||||||
|
const show_box_was_unregistered = false;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
@@ -14,10 +19,8 @@ if (auth === true) {
|
|||||||
}
|
}
|
||||||
if (wtva.checkPassword(password)) {
|
if (wtva.checkPassword(password)) {
|
||||||
if (request_headers.query.username) {
|
if (request_headers.query.username) {
|
||||||
var show_cannot_modify_self = false;
|
|
||||||
var show_cannot_remove_primary = false;
|
user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
||||||
var show_box_was_unregistered = false;
|
|
||||||
var user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
|
||||||
if (user_info) {
|
if (user_info) {
|
||||||
if (user_info.ssid == socket.ssid) {
|
if (user_info.ssid == socket.ssid) {
|
||||||
show_cannot_modify_self = true;
|
show_cannot_modify_self = true;
|
||||||
@@ -25,13 +28,13 @@ if (auth === true) {
|
|||||||
if (request_headers.query.confirm_delete) {
|
if (request_headers.query.confirm_delete) {
|
||||||
if (!show_cannot_modify_self) {
|
if (!show_cannot_modify_self) {
|
||||||
// delete
|
// delete
|
||||||
var userAccount = wtva.getAccountBySSID(user_info.ssid);
|
const userAccount = wtva.getAccountBySSID(user_info.ssid);
|
||||||
userAccount.switchUserID(0, false, false);
|
userAccount.switchUserID(0, false, false);
|
||||||
var userCount = Object.keys(user_info.account_users).length;
|
const userCount = Object.keys(user_info.account_users).length;
|
||||||
if (user_info.user_id === 0) {
|
if (user_info.user_id === 0) {
|
||||||
show_cannot_remove_primary = true;
|
show_cannot_remove_primary = true;
|
||||||
} else {
|
} else {
|
||||||
var result = userAccount.removeUser(user_info.user_id);
|
result = userAccount.removeUser(user_info.user_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,12 +110,12 @@ wtv-noback-all: wtv-admin:/deleteuser`;
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(403, auth);
|
const errpage = wtvshared.doErrorPage(403, auth);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
var auth = wtva.isAuthorized();
|
const auth = wtva.isAuthorized();
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let user_info;
|
||||||
|
let password = null;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
@@ -14,7 +15,7 @@ if (auth === true) {
|
|||||||
}
|
}
|
||||||
if (wtva.checkPassword(password)) {
|
if (wtva.checkPassword(password)) {
|
||||||
if (request_headers.query.username) {
|
if (request_headers.query.username) {
|
||||||
var user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
||||||
if (!user_info) user_info = wtva.getAccountInfoBySSID(request_headers.query.username.toLowerCase()); // ssid search
|
if (!user_info) user_info = wtva.getAccountInfoBySSID(request_headers.query.username.toLowerCase()); // ssid search
|
||||||
}
|
}
|
||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
@@ -89,12 +90,12 @@ data += `<a href="wtv-admin:/deleteaccount?ssid=${user_info.ssid}">Delete Accoun
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(403, auth);
|
const errpage = wtvshared.doErrorPage(403, auth);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,28 +1,31 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
var auth = wtva.isAuthorized();
|
const auth = wtva.isAuthorized();
|
||||||
|
|
||||||
function generateFormField(type, confvar, options = null) {
|
function generateFormField(type, confvar, options = null) {
|
||||||
|
let confvar_value;
|
||||||
|
const user_config = wtvshared.getUserConfig();
|
||||||
if (confvar.indexOf('.') > 0) {
|
if (confvar.indexOf('.') > 0) {
|
||||||
var confvar_split = confvar.split('.');
|
const confvar_split = confvar.split('.');
|
||||||
// not operater error resistant, be mindful if you modify this page
|
// not operater error resistant, be mindful if you modify this page
|
||||||
if (user_config.config[confvar_split[0]])
|
if (user_config.config[confvar_split[0]]) {
|
||||||
var confvar_value = user_config.config[confvar_split[0]][confvar_split[1]] || minisrv_config.config[confvar_split[0]][confvar_split[1]]
|
confvar_value = user_config.config[confvar_split[0]][confvar_split[1]] || minisrv_config.config[confvar_split[0]][confvar_split[1]];
|
||||||
else
|
} else {
|
||||||
var confvar_value = minisrv_config.config[confvar_split[0]][confvar_split[1]];
|
confvar_value = minisrv_config.config[confvar_split[0]][confvar_split[1]];
|
||||||
|
}
|
||||||
confvar = confvar.replace(".", "-");
|
confvar = confvar.replace(".", "-");
|
||||||
} else
|
} else {
|
||||||
var confvar_value = user_config.config[confvar] || minisrv_config.config[confvar];
|
confvar_value = user_config.config[confvar] || minisrv_config.config[confvar];
|
||||||
|
}
|
||||||
|
|
||||||
if (type == "input")
|
if (type == "input")
|
||||||
return `<input bgcolor="101010" text="ee44bb" type="text" name="${confvar}" value="${confvar_value}"${(options) ? ' '+options : ''}>`
|
return `<input bgcolor="101010" text="ee44bb" type="text" name="${confvar}" value="${confvar_value}"${(options) ? ' '+options : ''}>`
|
||||||
if (type == "checkbox")
|
if (type == "checkbox")
|
||||||
return `<input type="hidden" name="${confvar}" value="false">\n<input type=checkbox name="${confvar}" ${wtvshared.parseBool(confvar_value) ? "checked=checked" : ''}${(options) ? ' ' + options : ''}>`
|
return `<input type="hidden" name="${confvar}" value="false">\n<input type=checkbox name="${confvar}" ${wtvshared.parseBool(confvar_value) ? "checked=checked" : ''}${(options) ? ' ' + options : ''}>`
|
||||||
if (type == "select") {
|
if (type == "select") {
|
||||||
var out = `<select name="${confvar}">\n`
|
let out = `<select name="${confvar}">\n`
|
||||||
if (options) {
|
if (options) {
|
||||||
Object.keys(options).forEach((k) => {
|
Object.keys(options).forEach((k) => {
|
||||||
out += `<option value="${options[k].value}"${(confvar_value == options[k].value) ? ' selected' : ''}>${options[k].name}</option>\n`
|
out += `<option value="${options[k].value}"${(confvar_value == options[k].value) ? ' selected' : ''}>${options[k].name}</option>\n`
|
||||||
@@ -33,16 +36,16 @@ function generateFormField(type, confvar, options = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let password = null;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wtva.checkPassword(password)) {
|
if (wtva.checkPassword(password)) {
|
||||||
var user_config = wtvshared.getUserConfig();
|
const user_config = wtvshared.getUserConfig();
|
||||||
headers = "200 OK\r\nContent-Type: text/html";
|
headers = "200 OK\r\nContent-Type: text/html";
|
||||||
data = `<html>
|
data = `<html>
|
||||||
<body>
|
<body>
|
||||||
@@ -255,12 +258,12 @@ ${generateFormField('input', 'passwords.form_size', "size=2 onkeypress='return f
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(403, auth);
|
const errpage = wtvshared.doErrorPage(403, auth);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
var auth = wtva.isAuthorized();
|
const auth = wtva.isAuthorized();
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let user_info;
|
||||||
|
let password = null;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
@@ -14,33 +15,31 @@ if (auth === true) {
|
|||||||
}
|
}
|
||||||
if (wtva.checkPassword(password)) {
|
if (wtva.checkPassword(password)) {
|
||||||
if (request_headers.query.username) {
|
if (request_headers.query.username) {
|
||||||
var user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
||||||
if (user_info) {
|
if (user_info) {
|
||||||
var userAccount = wtva.getAccountBySSID(user_info.ssid);
|
const userAccount = wtva.getAccountBySSID(user_info.ssid);
|
||||||
userAccount.switchUserID(user_info.user_id, false, false);
|
userAccount.switchUserID(user_info.user_id, false, false);
|
||||||
if (request_headers.query.confirm) {
|
if (request_headers.query.confirm) {
|
||||||
var polyzooot = 1407;
|
const polyzooot = 1407;
|
||||||
var WTVBGMusic = require(classPath + "/WTVBGMusic.js");
|
const WTVBGMusic = require(classPath + "/WTVBGMusic.js");
|
||||||
var wtvbgm = new WTVBGMusic(minisrv_config, userAccount);
|
const wtvbgm = new WTVBGMusic(minisrv_config, userAccount);
|
||||||
var bgmcat = wtvbgm.getSongCategory(polyzooot);
|
const bgmcat = wtvbgm.getSongCategory(polyzooot);
|
||||||
var music_obj = wtvbgm.getMusicObj();
|
let music_obj = wtvbgm.getMusicObj();
|
||||||
music_obj.enableCategories = [bgmcat];
|
music_obj.enableCategories = [bgmcat];
|
||||||
music_obj.enableSongs = [polyzooot];
|
music_obj.enableSongs = [polyzooot];
|
||||||
music_obj = Object.assign({}, music_obj)
|
music_obj = Object.assign({}, music_obj)
|
||||||
userAccount.setSessionData("wtv-bgmusic", music_obj);
|
userAccount.setSessionData("wtv-bgmusic", music_obj);
|
||||||
var settings_obj = userAccount.getSessionData("wtv-setup");
|
const settings_obj = userAccount.getSessionData("wtv-setup") || {};
|
||||||
if (settings_obj === null) settings_obj = {};
|
|
||||||
settings_obj['setup-play-bgm'] = 1;
|
settings_obj['setup-play-bgm'] = 1;
|
||||||
userAccount.setSessionData("wtv-setup", Object.assign({}, settings_obj));
|
userAccount.setSessionData("wtv-setup", Object.assign({}, settings_obj));
|
||||||
userAccount.saveSessionData();
|
userAccount.saveSessionData();
|
||||||
}
|
}
|
||||||
if (request_headers.query.reset) {
|
if (request_headers.query.reset) {
|
||||||
var WTVBGMusic = require(classPath + "/WTVBGMusic.js");
|
const WTVBGMusic = require(classPath + "/WTVBGMusic.js");
|
||||||
userAccount.deleteSessionData("wtv-bgmusic")
|
userAccount.deleteSessionData("wtv-bgmusic")
|
||||||
var wtvbgm = new WTVBGMusic(minisrv_config, userAccount);
|
const wtvbgm = new WTVBGMusic(minisrv_config, userAccount);
|
||||||
var music_obj = wtvbgm.getMusicObj(true);
|
const music_obj = wtvbgm.getMusicObj(true);
|
||||||
var settings_obj = userAccount.getSessionData("wtv-setup");
|
const settings_obj = userAccount.getSessionData("wtv-setup") || {};
|
||||||
if (settings_obj === null) settings_obj = {};
|
|
||||||
settings_obj['setup-play-bgm'] = 0;
|
settings_obj['setup-play-bgm'] = 0;
|
||||||
userAccount.setSessionData("wtv-setup", Object.assign({}, settings_obj));
|
userAccount.setSessionData("wtv-setup", Object.assign({}, settings_obj));
|
||||||
userAccount.saveSessionData();
|
userAccount.saveSessionData();
|
||||||
@@ -122,12 +121,12 @@ data += `
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(403, auth);
|
const errpage = wtvshared.doErrorPage(403, auth);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
var auth = wtva.isAuthorized();
|
const auth = wtva.isAuthorized();
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let user_info, userAccount;
|
||||||
|
let password = null;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
@@ -14,9 +15,9 @@ if (auth === true) {
|
|||||||
}
|
}
|
||||||
if (wtva.checkPassword(password)) {
|
if (wtva.checkPassword(password)) {
|
||||||
if (request_headers.query.username) {
|
if (request_headers.query.username) {
|
||||||
var user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
||||||
if (user_info) {
|
if (user_info) {
|
||||||
var userAccount = wtva.getAccountBySSID(user_info.ssid);
|
userAccount = wtva.getAccountBySSID(user_info.ssid);
|
||||||
userAccount.switchUserID(user_info.user_id, false, false);
|
userAccount.switchUserID(user_info.user_id, false, false);
|
||||||
if (request_headers.query.folder) {
|
if (request_headers.query.folder) {
|
||||||
if (userAccount.favstore.favstoreExists()) {
|
if (userAccount.favstore.favstoreExists()) {
|
||||||
@@ -87,12 +88,12 @@ wtv-noback-all: wtv-admin:/regenfavs`;
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(403, auth);
|
const errpage = wtvshared.doErrorPage(403, auth);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
var auth = wtva.isAuthorized();
|
const auth = wtva.isAuthorized();
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let password = null;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
@@ -45,12 +45,12 @@ If you added a new service, it will not bind without a restart.
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(403, auth);
|
const errpage = wtvshared.doErrorPage(403, auth);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
var auth = wtva.isAuthorized();
|
const auth = wtva.isAuthorized();
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let user_info;
|
||||||
|
let show_cannot_modify_self = false;
|
||||||
|
let show_user_has_no_password = false;
|
||||||
|
let password = null;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
@@ -14,14 +17,12 @@ if (auth === true) {
|
|||||||
}
|
}
|
||||||
if (wtva.checkPassword(password)) {
|
if (wtva.checkPassword(password)) {
|
||||||
if (request_headers.query.username) {
|
if (request_headers.query.username) {
|
||||||
var show_cannot_modify_self = false;
|
user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
||||||
var show_user_has_no_password = false;
|
|
||||||
var user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
|
||||||
if (user_info) {
|
if (user_info) {
|
||||||
if (user_info.ssid == socket.ssid) {
|
if (user_info.ssid == socket.ssid) {
|
||||||
show_cannot_modify_self = true;
|
show_cannot_modify_self = true;
|
||||||
}
|
}
|
||||||
var userAccount = wtva.getAccountBySSID(user_info.ssid);
|
const userAccount = wtva.getAccountBySSID(user_info.ssid);
|
||||||
userAccount.switchUserID(user_info.user_id, false, false);
|
userAccount.switchUserID(user_info.user_id, false, false);
|
||||||
if (!userAccount.getUserPasswordEnabled()) {
|
if (!userAccount.getUserPasswordEnabled()) {
|
||||||
show_user_has_no_password = true;
|
show_user_has_no_password = true;
|
||||||
@@ -98,12 +99,12 @@ wtv-noback-all: wtv-admin:/removeuserpasswd`;
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(403, auth);
|
const errpage = wtvshared.doErrorPage(403, auth);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
|
const auth = wtva.isAuthorized();
|
||||||
|
const ssids_removed = [];
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
|
||||||
var auth = wtva.isAuthorized();
|
|
||||||
var ssids_removed = [];
|
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let config_changed = false;
|
||||||
|
let password = null;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
@@ -15,8 +17,7 @@ if (auth === true) {
|
|||||||
}
|
}
|
||||||
if (wtva.checkPassword(password)) {
|
if (wtva.checkPassword(password)) {
|
||||||
if (request_headers.query.unban_ssid) {
|
if (request_headers.query.unban_ssid) {
|
||||||
var config_changed = false;
|
const fake_config = wtvshared.getUserConfig();
|
||||||
var fake_config = wtvshared.getUserConfig();
|
|
||||||
if (!fake_config.config) fake_config.config = {};
|
if (!fake_config.config) fake_config.config = {};
|
||||||
if (!fake_config.config.ssid_block_list) fake_config.config.ssid_block_list = [];
|
if (!fake_config.config.ssid_block_list) fake_config.config.ssid_block_list = [];
|
||||||
if (typeof request_headers.query.unban_ssid === 'string') {
|
if (typeof request_headers.query.unban_ssid === 'string') {
|
||||||
@@ -70,7 +71,7 @@ wtv-expire-all: wtv-admin:/unban`;
|
|||||||
data += '<form action="wtv-admin:/unban" method="POST">';
|
data += '<form action="wtv-admin:/unban" method="POST">';
|
||||||
data += '<select name="unban_ssid" multiple size="8">';
|
data += '<select name="unban_ssid" multiple size="8">';
|
||||||
Object.keys(minisrv_config.config.ssid_block_list).forEach(function (k) {
|
Object.keys(minisrv_config.config.ssid_block_list).forEach(function (k) {
|
||||||
var ssid = minisrv_config.config.ssid_block_list[k];
|
const ssid = minisrv_config.config.ssid_block_list[k];
|
||||||
data += "<option value=\"" + ssid + "\">" + ssid + "</option>\n";
|
data += "<option value=\"" + ssid + "\">" + ssid + "</option>\n";
|
||||||
});
|
});
|
||||||
data += '</select><br><input type="submit" value="Unban SSID(s)"></form>';
|
data += '</select><br><input type="submit" value="Unban SSID(s)"></form>';
|
||||||
@@ -97,12 +98,12 @@ wtv-expire-all: wtv-admin:/unban`;
|
|||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(403, auth);
|
const errpage = wtvshared.doErrorPage(403, auth);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
const WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||||
var auth = wtva.isAuthorized();
|
const auth = wtva.isAuthorized();
|
||||||
|
|
||||||
if (auth === true) {
|
if (auth === true) {
|
||||||
var password = null;
|
let password = null;
|
||||||
if (request_headers.Authorization) {
|
if (request_headers.Authorization) {
|
||||||
var authheader = request_headers.Authorization.split(' ');
|
const authheader = request_headers.Authorization.split(' ');
|
||||||
if (authheader[0] == "Basic") {
|
if (authheader[0] == "Basic") {
|
||||||
password = Buffer.from(authheader[1], 'base64').toString();
|
password = Buffer.from(authheader[1], 'base64').toString();
|
||||||
if (password) password = password.split(':')[1];
|
if (password) password = password.split(':')[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wtva.checkPassword(password)) {
|
if (wtva.checkPassword(password)) {
|
||||||
var user_config = wtvshared.getUserConfig();
|
const user_config = wtvshared.getUserConfig();
|
||||||
Object.keys(request_headers.query).forEach((k) => {
|
Object.keys(request_headers.query).forEach((k) => {
|
||||||
if (k === "autosubmit") return;
|
if (k === "autosubmit") return;
|
||||||
var v = request_headers.query[k];
|
let v = request_headers.query[k];
|
||||||
|
|
||||||
// enable_multi_query may send ["false", "on"] for checkboxes due to webtvism
|
// enable_multi_query may send ["false", "on"] for checkboxes due to webtvism
|
||||||
if (util.isArray(v)) v = v[(v.length - 1)];
|
if (util.isArray(v)) v = v[(v.length - 1)];
|
||||||
@@ -30,20 +30,20 @@ if (auth === true) {
|
|||||||
|
|
||||||
if (k.indexOf("-") > 0) {
|
if (k.indexOf("-") > 0) {
|
||||||
// handle sub-config items
|
// handle sub-config items
|
||||||
var s = k.split("-");
|
const s = k.split("-");
|
||||||
if (!user_config.config[s[0]]) user_config.config[s[0]] = {}
|
if (!user_config.config[s[0]]) user_config.config[s[0]] = {}
|
||||||
user_config.config[s[0]][s[1]] = v;
|
user_config.config[s[0]][s[1]] = v;
|
||||||
} else {
|
} else {
|
||||||
user_config.config[k] = v;
|
user_config.config[k] = v;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var res = wtvshared.writeToUserConfig(user_config);
|
const res = wtvshared.writeToUserConfig(user_config);
|
||||||
if (res) {
|
if (res) {
|
||||||
console.log(" * Configuration updated from wtv-admin, reloading")
|
console.log(" * Configuration updated from wtv-admin, reloading")
|
||||||
reloadConfig();
|
reloadConfig();
|
||||||
headers = "200 OK\nwtv-expire-all: wtv-admin:/operatortweaks\nContent-Type: text/html";
|
headers = "200 OK\nwtv-expire-all: wtv-admin:/operatortweaks\nContent-Type: text/html";
|
||||||
} else {
|
} else {
|
||||||
err = wtvshared.doErrorPage(400, "Error writing userconfig");
|
const err = wtvshared.doErrorPage(400, "Error writing userconfig");
|
||||||
headers = err[0];
|
headers = err[0];
|
||||||
data = err[1];
|
data = err[1];
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ if (auth === true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!headers) {
|
if (!headers) {
|
||||||
err = wtvshared.doErrorPage();
|
const err = wtvshared.doErrorPage();
|
||||||
headers = err[0];
|
headers = err[0];
|
||||||
data = err[1];
|
data = err[1];
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,7 @@ function checkScopeErrors(file) {
|
|||||||
"http": "readonly",
|
"http": "readonly",
|
||||||
"https": "readonly",
|
"https": "readonly",
|
||||||
"sharp": "readonly",
|
"sharp": "readonly",
|
||||||
|
"util": "readonly",
|
||||||
"nunjucks": "readonly",
|
"nunjucks": "readonly",
|
||||||
"URL": "readonly",
|
"URL": "readonly",
|
||||||
"URLSearchParams": "readonly",
|
"URLSearchParams": "readonly",
|
||||||
|
|||||||
Reference in New Issue
Block a user