diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-admin/admin.js b/zefie_wtvp_minisrv/ServiceVault/wtv-admin/admin.js index fad5cf02..a9a9ac56 100644 --- a/zefie_wtvp_minisrv/ServiceVault/wtv-admin/admin.js +++ b/zefie_wtvp_minisrv/ServiceVault/wtv-admin/admin.js @@ -51,17 +51,17 @@ if (auth === true) { Whitelist an SSID -Remove Pass from User +Remove Pass from User Grant Admin to SSID -Revoke Admin from SSID +Modify Admin for SSID - +Polyzoot a User diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-admin/findaccount.js b/zefie_wtvp_minisrv/ServiceVault/wtv-admin/findaccount.js index d2518f59..23048614 100644 --- a/zefie_wtvp_minisrv/ServiceVault/wtv-admin/findaccount.js +++ b/zefie_wtvp_minisrv/ServiceVault/wtv-admin/findaccount.js @@ -60,12 +60,15 @@ wtv-noback-all: wtv-admin:/findaccount`; } data += ` - -Ban SSID -           -Unban SSID -           -Delete Account +`; + if (wtva.isBanned(user_info.ssid)) { + data += `Unban SSID`; + data += " ".repeat(28); + } else { + data += `Ban SSID`; + data += " ".repeat(32); + } +data += `Delete Account ` diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-admin/images/polyzoot.jpg b/zefie_wtvp_minisrv/ServiceVault/wtv-admin/images/polyzoot.jpg new file mode 100644 index 00000000..881753d7 Binary files /dev/null and b/zefie_wtvp_minisrv/ServiceVault/wtv-admin/images/polyzoot.jpg differ diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-admin/polyzoot.js b/zefie_wtvp_minisrv/ServiceVault/wtv-admin/polyzoot.js new file mode 100644 index 00000000..fb855ba5 --- /dev/null +++ b/zefie_wtvp_minisrv/ServiceVault/wtv-admin/polyzoot.js @@ -0,0 +1,133 @@ +var minisrv_service_file = true; + +var WTVAdmin = require("./WTVAdmin.js"); +var wtva = new WTVAdmin(minisrv_config, ssid_sessions[socket.ssid], service_name); +var auth = wtva.isAuthorized(); +if (auth === true) { + var password = null; + if (request_headers.Authorization) { + var 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)) { + if (request_headers.query.username) { + var user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search + if (user_info) { + var 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("./WTVBGMusic.js"); + var wtvbgm = new WTVBGMusic(minisrv_config, userAccount); + var bgmcat = wtvbgm.getSongCategory(polyzooot); + var 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 = {}; + settings_obj['setup-play-bgm'] = 1; + userAccount.setSessionData("wtv-setup", Object.assign({}, settings_obj)); + userAccount.saveSessionData(); + } + if (request_headers.query.reset) { + var WTVBGMusic = require("./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 = {}; + settings_obj['setup-play-bgm'] = 0; + userAccount.setSessionData("wtv-setup", Object.assign({}, settings_obj)); + userAccount.saveSessionData(); + } + } + } + headers = `200 OK +Content-Type: text/html +wtv-expire-all: wtv-admin:/polyzoot +wtv-noback-all: wtv-admin:/polyzoot`; + data = ` + + +${minisrv_config.config.service_name} Admin Tricks + + + + +
+
+

${minisrv_config.config.service_name} Admin Tricks

+
+ + + + + + +` + data += `
+

Polyzoot a User

`; + + if (!request_headers.query.username) { + data += `"Polyzooting" a user will replace their Background Music with only Polyzoot, +and turn on BGM if they have it disabled. This will not work on Old Classic clients. +Also, the only way to undo a "Polyzooting" is to reset the user's music selection to default.

` + } + +data += ` +
+   +


` + if (request_headers.query.username) { + if (user_info && !request_headers.query.confirm && !request_headers.query.reset) { + if (user_info.username == ssid_sessions[socket.ssid].getSessionData("subscriber_username")) { + data += `Are you sure you want to Polyzoot yourself?
Are you a masochist?`; + } else { + data += `Are you sure you want to Polyzoot ${user_info.username}?
Are you a sadist?`; + } + data += ` +

+
+
+ + + +
+ + + + + +
`; + } else if (request_headers.query.confirm) { + data += `You have condemned ${user_info.username}
to endless loops of Polyzoot.

It will take effect upon their next login.

`; + } else if (request_headers.query.reset) { + data += `You have freed ${user_info.username}'s soul
from the bounds of Polyzoot.

It will take effect upon their next login.

`; + } + } + data += ` +
+
+ + +

+Go Back +

+ + +`; + } else { + var 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); + headers = errpage[0]; + data = errpage[1]; +} \ No newline at end of file diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-admin/removeuserpasswd.js b/zefie_wtvp_minisrv/ServiceVault/wtv-admin/removeuserpasswd.js new file mode 100644 index 00000000..e66a6d52 --- /dev/null +++ b/zefie_wtvp_minisrv/ServiceVault/wtv-admin/removeuserpasswd.js @@ -0,0 +1,109 @@ +var minisrv_service_file = true; + +var WTVAdmin = require("./WTVAdmin.js"); +var wtva = new WTVAdmin(minisrv_config, ssid_sessions[socket.ssid], service_name); +var auth = wtva.isAuthorized(); +if (auth === true) { + var password = null; + if (request_headers.Authorization) { + var 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)) { + 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 + if (user_info) { + if (user_info.ssid == socket.ssid) { + show_cannot_modify_self = true; + } + var userAccount = wtva.getAccountBySSID(user_info.ssid); + userAccount.switchUserID(user_info.user_id, false, false); + if (!userAccount.getUserPasswordEnabled()) { + show_user_has_no_password = true; + } + if (request_headers.query.confirm_remove) { + if (!show_cannot_modify_self && !show_user_has_no_password) { + userAccount.disableUserPassword(); + } + } + } + } + headers = `200 OK +Content-Type: text/html +wtv-expire-all: wtv-admin:/removeuserpasswd +wtv-noback-all: wtv-admin:/removeuserpasswd`; + data = ` + + +${minisrv_config.config.service_name} Admin Tricks + + + + +
+
+

${minisrv_config.config.service_name} Admin Tricks

+
+ + + +
+

Remove Password from a User Account

+
+   +


` + if (request_headers.query.username) { + if (user_info && !request_headers.query.confirm_remove && !show_user_has_no_password && !show_cannot_modify_self) { + data += ` +User Information: + + +`; + if (user_info.account_users) { + data += ``; + } + data += ` + + + +` + data += `
Username:${user_info.username} (User ID: ${user_info.user_id})
SSID:${user_info.ssid}
Primary User:${user_info.account_users['subscriber'].subscriber_username}
+
+ + + +
+
`; + } else if (show_cannot_modify_self) { + data += `Cannot modify your account in this manner.
Try wtv-setup.


`; + } else if (show_user_has_no_password) { + data += `${user_info.username} has no password,
so there nothing to do.

`; + } else { + data += `Password removed from account "${user_info.username}"

`; + } + } + data += ` +
+
+
+

+Go Back +

+ + +`; + } else { + var 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); + headers = errpage[0]; + data = errpage[1]; +} \ No newline at end of file diff --git a/zefie_wtvp_minisrv/WTVAdmin.js b/zefie_wtvp_minisrv/WTVAdmin.js index 78aff4ca..0c428d9e 100644 --- a/zefie_wtvp_minisrv/WTVAdmin.js +++ b/zefie_wtvp_minisrv/WTVAdmin.js @@ -148,6 +148,17 @@ class WTVAdmin { userSession.user_id = 0; return userSession; } + + isBanned(ssid) { + var self = this; + var isBanned = false; + Object.keys(this.minisrv_config.config.ssid_block_list).forEach(function (k) { + if (self.minisrv_config.config.ssid_block_list[k] == ssid) { + isBanned = true; + } + }); + return isBanned; + } } module.exports = WTVAdmin; diff --git a/zefie_wtvp_minisrv/WTVBGMusic.js b/zefie_wtvp_minisrv/WTVBGMusic.js index 2cfa8bdd..0fe4c2a6 100644 --- a/zefie_wtvp_minisrv/WTVBGMusic.js +++ b/zefie_wtvp_minisrv/WTVBGMusic.js @@ -1252,12 +1252,12 @@ class WTVBGMusic { this.wtvshared = new WTVShared(minisrv_config); } - getMusicObj() { + getMusicObj(force_default = false) { var music_obj = this.session_data.getSessionData("wtv-bgmusic"); if (music_obj === null) music_obj = {}; // check if we need to set defaults - var setDefaults = false; + var setDefaults = force_default; if (!music_obj.enableCategories) setDefaults = true; else if (music_obj.enableCategories.length == 0) setDefaults = true; if (!music_obj.enableSongs) setDefaults = true; diff --git a/zefie_wtvp_minisrv/WTVClientSessionData.js b/zefie_wtvp_minisrv/WTVClientSessionData.js index 68ab198b..0a1be9b1 100644 --- a/zefie_wtvp_minisrv/WTVClientSessionData.js +++ b/zefie_wtvp_minisrv/WTVClientSessionData.js @@ -451,7 +451,7 @@ class WTVClientSessionData { getUserPasswordEnabled() { if (!this.minisrv_config.config.passwords.enabled) return false; // master config override var enabled = this.getSessionData("subscriber_password"); - return (enabled); // true if set, false if null/disabled + return (enabled != null && typeof enabled != undefined); // true if set, false if null/disabled } validateUserPassword(passwd) { diff --git a/zefie_wtvp_minisrv/config.json b/zefie_wtvp_minisrv/config.json index 40308694..07f8dd7f 100644 --- a/zefie_wtvp_minisrv/config.json +++ b/zefie_wtvp_minisrv/config.json @@ -113,6 +113,7 @@ }, "wtv-admin": { "port": 1698, + "enable_multi_query": true, "password": "viRak-7" }, "http": {