diff --git a/zefie_wtvp_minisrv/app.js b/zefie_wtvp_minisrv/app.js index 02190afc..d53c4c7d 100644 --- a/zefie_wtvp_minisrv/app.js +++ b/zefie_wtvp_minisrv/app.js @@ -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, diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/admin.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/admin.js index 8dcdabb0..9af9e026 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/admin.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/admin.js @@ -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) { `; } 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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/ban.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/ban.js index 4f98dd8c..0b07005a 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/ban.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/ban.js @@ -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`; `; } 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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/deleteaccount.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/deleteaccount.js index 94177dfd..9bc64a6c 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/deleteaccount.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/deleteaccount.js @@ -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`; `; } 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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/deleteuser.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/deleteuser.js index d10326ba..16ac6692 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/deleteuser.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/deleteuser.js @@ -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`; `; } 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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/findaccount.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/findaccount.js index 6aed0b8b..482a1003 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/findaccount.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/findaccount.js @@ -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 += `Delete Accoun `; } 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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/operatortweaks.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/operatortweaks.js index 224e6bd0..7d83e7ae 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/operatortweaks.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/operatortweaks.js @@ -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 `` if (type == "checkbox") return `\n` if (type == "select") { - var out = `\n` if (options) { Object.keys(options).forEach((k) => { out += `\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 = ` @@ -255,12 +258,12 @@ ${generateFormField('input', 'passwords.form_size', "size=2 onkeypress='return f `; } 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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/polyzoot.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/polyzoot.js index 2c0c4d15..56786389 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/polyzoot.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/polyzoot.js @@ -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 += ` `; } 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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/regenfavs.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/regenfavs.js index ee7d4f47..68c16409 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/regenfavs.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/regenfavs.js @@ -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`; `; } 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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/reloadconfig.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/reloadconfig.js index 163ac9ed..481bb24a 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/reloadconfig.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/reloadconfig.js @@ -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. `; } 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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/removeuserpasswd.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/removeuserpasswd.js index 1dadeb37..b9b9d87c 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/removeuserpasswd.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/removeuserpasswd.js @@ -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`; `; } 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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/unban.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/unban.js index 2950864e..79e461fe 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/unban.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/unban.js @@ -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 += '
'; data += '
'; @@ -97,12 +98,12 @@ wtv-expire-all: wtv-admin:/unban`; `; } 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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/validate-operator-tweaks.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/validate-operator-tweaks.js index 2181cc5a..2ab8ff37 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/validate-operator-tweaks.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-admin/validate-operator-tweaks.js @@ -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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/test.js b/zefie_wtvp_minisrv/test.js index dc00d4a3..c907e726 100644 --- a/zefie_wtvp_minisrv/test.js +++ b/zefie_wtvp_minisrv/test.js @@ -56,6 +56,7 @@ function checkScopeErrors(file) { "http": "readonly", "https": "readonly", "sharp": "readonly", + "util": "readonly", "nunjucks": "readonly", "URL": "readonly", "URLSearchParams": "readonly",