fix/optimize wtv-admin

This commit is contained in:
zefie
2025-08-12 18:28:56 -04:00
parent b9d64de79e
commit d5c04688e9
14 changed files with 159 additions and 148 deletions

View File

@@ -242,6 +242,7 @@ const runScriptInVM = function (script_data, user_contextObj = {}, privileged =
"wtvmime": wtvmime,
"http": http,
"https": https,
"util": util,
"sharp": sharp,
"nunjucks": nunjucks,
"URL": URL,

View File

@@ -1,12 +1,12 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
if (auth === true) {
var password = null;
let password = null;
if (request_headers.Authorization) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
@@ -83,12 +83,12 @@ if (auth === true) {
</html>
`;
} 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];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,12 +1,12 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
if (auth === true) {
var password = null;
let result, ssid, password;
if (request_headers.Authorization) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
@@ -14,8 +14,8 @@ if (auth === true) {
}
if (wtva.checkPassword(password)) {
if (request_headers.query.ssid) {
var ssid = request_headers.query.ssid.toLowerCase();
var result = wtva.banSSID(ssid, socket.ssid);
ssid = request_headers.query.ssid.toLowerCase();
result = wtva.banSSID(ssid, socket.ssid);
}
headers = `200 OK
Content-Type: text/html
@@ -69,12 +69,12 @@ wtv-expire-all: wtv-admin:/ban`;
</html>
`;
} 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];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,12 +1,13 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
if (auth === true) {
var password = null;
let user_info, ssid, password;
let ssid_match = false;
if (request_headers.Authorization) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
@@ -14,16 +15,15 @@ if (auth === true) {
}
if (wtva.checkPassword(password)) {
if (request_headers.query.ssid) {
var ssid_match = false;
var ssid = request_headers.query.ssid.toLowerCase();
var user_info = wtva.getAccountInfoBySSID(ssid);
ssid = request_headers.query.ssid.toLowerCase();
user_info = wtva.getAccountInfoBySSID(ssid);
if (request_headers.query.confirm_delete) {
user_info = null;
if (ssid == socket.ssid) {
ssid_match = true;
} else {
// delete
var userAccount = wtva.getAccountBySSID(ssid);
const userAccount = wtva.getAccountBySSID(ssid);
userAccount.unregisterBox();
}
}
@@ -101,12 +101,12 @@ wtv-noback-all: wtv-admin:/deleteaccount`;
</html>
`;
} 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];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,12 +1,17 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
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) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
@@ -14,10 +19,8 @@ if (auth === true) {
}
if (wtva.checkPassword(password)) {
if (request_headers.query.username) {
var show_cannot_modify_self = false;
var show_cannot_remove_primary = false;
var show_box_was_unregistered = false;
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.ssid == socket.ssid) {
show_cannot_modify_self = true;
@@ -25,13 +28,13 @@ if (auth === true) {
if (request_headers.query.confirm_delete) {
if (!show_cannot_modify_self) {
// delete
var userAccount = wtva.getAccountBySSID(user_info.ssid);
const userAccount = wtva.getAccountBySSID(user_info.ssid);
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) {
show_cannot_remove_primary = true;
} 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>
`;
} 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];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,12 +1,13 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
if (auth === true) {
var password = null;
let user_info;
let password = null;
if (request_headers.Authorization) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
@@ -14,7 +15,7 @@ if (auth === true) {
}
if (wtva.checkPassword(password)) {
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
}
headers = `200 OK
@@ -89,12 +90,12 @@ data += `<a href="wtv-admin:/deleteaccount?ssid=${user_info.ssid}">Delete Accoun
</html>
`;
} 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];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,28 +1,31 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
function generateFormField(type, confvar, options = null) {
let confvar_value;
const user_config = wtvshared.getUserConfig();
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
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]]
else
var confvar_value = minisrv_config.config[confvar_split[0]][confvar_split[1]];
if (user_config.config[confvar_split[0]]) {
confvar_value = user_config.config[confvar_split[0]][confvar_split[1]] || minisrv_config.config[confvar_split[0]][confvar_split[1]];
} else {
confvar_value = minisrv_config.config[confvar_split[0]][confvar_split[1]];
}
confvar = confvar.replace(".", "-");
} else
var confvar_value = user_config.config[confvar] || minisrv_config.config[confvar];
} else {
confvar_value = user_config.config[confvar] || minisrv_config.config[confvar];
}
if (type == "input")
return `<input bgcolor="101010" text="ee44bb" type="text" name="${confvar}" value="${confvar_value}"${(options) ? ' '+options : ''}>`
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 : ''}>`
if (type == "select") {
var out = `<select name="${confvar}">\n`
let out = `<select name="${confvar}">\n`
if (options) {
Object.keys(options).forEach((k) => {
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) {
var password = null;
let password = null;
if (request_headers.Authorization) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
}
}
if (wtva.checkPassword(password)) {
var user_config = wtvshared.getUserConfig();
const user_config = wtvshared.getUserConfig();
headers = "200 OK\r\nContent-Type: text/html";
data = `<html>
<body>
@@ -255,12 +258,12 @@ ${generateFormField('input', 'passwords.form_size', "size=2 onkeypress='return f
</html>
`;
} 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];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,12 +1,13 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
if (auth === true) {
var password = null;
let user_info;
let password = null;
if (request_headers.Authorization) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
@@ -14,33 +15,31 @@ if (auth === true) {
}
if (wtva.checkPassword(password)) {
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) {
var userAccount = wtva.getAccountBySSID(user_info.ssid);
const userAccount = wtva.getAccountBySSID(user_info.ssid);
userAccount.switchUserID(user_info.user_id, false, false);
if (request_headers.query.confirm) {
var polyzooot = 1407;
var WTVBGMusic = require(classPath + "/WTVBGMusic.js");
var wtvbgm = new WTVBGMusic(minisrv_config, userAccount);
var bgmcat = wtvbgm.getSongCategory(polyzooot);
var music_obj = wtvbgm.getMusicObj();
const polyzooot = 1407;
const WTVBGMusic = require(classPath + "/WTVBGMusic.js");
const wtvbgm = new WTVBGMusic(minisrv_config, userAccount);
const bgmcat = wtvbgm.getSongCategory(polyzooot);
let music_obj = wtvbgm.getMusicObj();
music_obj.enableCategories = [bgmcat];
music_obj.enableSongs = [polyzooot];
music_obj = Object.assign({}, music_obj)
userAccount.setSessionData("wtv-bgmusic", music_obj);
var settings_obj = userAccount.getSessionData("wtv-setup");
if (settings_obj === null) settings_obj = {};
const settings_obj = userAccount.getSessionData("wtv-setup") || {};
settings_obj['setup-play-bgm'] = 1;
userAccount.setSessionData("wtv-setup", Object.assign({}, settings_obj));
userAccount.saveSessionData();
}
if (request_headers.query.reset) {
var WTVBGMusic = require(classPath + "/WTVBGMusic.js");
const WTVBGMusic = require(classPath + "/WTVBGMusic.js");
userAccount.deleteSessionData("wtv-bgmusic")
var wtvbgm = new WTVBGMusic(minisrv_config, userAccount);
var music_obj = wtvbgm.getMusicObj(true);
var settings_obj = userAccount.getSessionData("wtv-setup");
if (settings_obj === null) settings_obj = {};
const wtvbgm = new WTVBGMusic(minisrv_config, userAccount);
const music_obj = wtvbgm.getMusicObj(true);
const settings_obj = userAccount.getSessionData("wtv-setup") || {};
settings_obj['setup-play-bgm'] = 0;
userAccount.setSessionData("wtv-setup", Object.assign({}, settings_obj));
userAccount.saveSessionData();
@@ -122,12 +121,12 @@ data += `
</html>
`;
} 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];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,12 +1,13 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
if (auth === true) {
var password = null;
let user_info, userAccount;
let password = null;
if (request_headers.Authorization) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
@@ -14,9 +15,9 @@ if (auth === true) {
}
if (wtva.checkPassword(password)) {
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) {
var userAccount = wtva.getAccountBySSID(user_info.ssid);
userAccount = wtva.getAccountBySSID(user_info.ssid);
userAccount.switchUserID(user_info.user_id, false, false);
if (request_headers.query.folder) {
if (userAccount.favstore.favstoreExists()) {
@@ -87,12 +88,12 @@ wtv-noback-all: wtv-admin:/regenfavs`;
</html>
`;
} 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];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,12 +1,12 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
if (auth === true) {
var password = null;
let password = null;
if (request_headers.Authorization) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
@@ -45,12 +45,12 @@ If you added a new service, it will not bind without a restart.
</html>
`;
} 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];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,12 +1,15 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
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) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
@@ -14,14 +17,12 @@ if (auth === true) {
}
if (wtva.checkPassword(password)) {
if (request_headers.query.username) {
var show_cannot_modify_self = false;
var show_user_has_no_password = false;
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.ssid == socket.ssid) {
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);
if (!userAccount.getUserPasswordEnabled()) {
show_user_has_no_password = true;
@@ -98,12 +99,12 @@ wtv-noback-all: wtv-admin:/removeuserpasswd`;
</html>
`;
} 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];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -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) {
var password = null;
let config_changed = false;
let password = null;
if (request_headers.Authorization) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
@@ -15,8 +17,7 @@ if (auth === true) {
}
if (wtva.checkPassword(password)) {
if (request_headers.query.unban_ssid) {
var config_changed = false;
var fake_config = wtvshared.getUserConfig();
const fake_config = wtvshared.getUserConfig();
if (!fake_config.config) fake_config.config = {};
if (!fake_config.config.ssid_block_list) fake_config.config.ssid_block_list = [];
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 += '<select name="unban_ssid" multiple size="8">';
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 += '</select><br><input type="submit" value="Unban SSID(s)"></form>';
@@ -97,12 +98,12 @@ wtv-expire-all: wtv-admin:/unban`;
</html>
`;
} 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];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,23 +1,23 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
if (auth === true) {
var password = null;
let password = null;
if (request_headers.Authorization) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
}
}
if (wtva.checkPassword(password)) {
var user_config = wtvshared.getUserConfig();
const user_config = wtvshared.getUserConfig();
Object.keys(request_headers.query).forEach((k) => {
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
if (util.isArray(v)) v = v[(v.length - 1)];
@@ -30,20 +30,20 @@ if (auth === true) {
if (k.indexOf("-") > 0) {
// handle sub-config items
var s = k.split("-");
const s = k.split("-");
if (!user_config.config[s[0]]) user_config.config[s[0]] = {}
user_config.config[s[0]][s[1]] = v;
} else {
user_config.config[k] = v;
}
});
var res = wtvshared.writeToUserConfig(user_config);
const res = wtvshared.writeToUserConfig(user_config);
if (res) {
console.log(" * Configuration updated from wtv-admin, reloading")
reloadConfig();
headers = "200 OK\nwtv-expire-all: wtv-admin:/operatortweaks\nContent-Type: text/html";
} else {
err = wtvshared.doErrorPage(400, "Error writing userconfig");
const err = wtvshared.doErrorPage(400, "Error writing userconfig");
headers = err[0];
data = err[1];
}
@@ -51,7 +51,7 @@ if (auth === true) {
}
if (!headers) {
err = wtvshared.doErrorPage();
const err = wtvshared.doErrorPage();
headers = err[0];
data = err[1];
}

View File

@@ -56,6 +56,7 @@ function checkScopeErrors(file) {
"http": "readonly",
"https": "readonly",
"sharp": "readonly",
"util": "readonly",
"nunjucks": "readonly",
"URL": "readonly",
"URLSearchParams": "readonly",