clean up file structure

This commit is contained in:
zefie
2022-11-30 08:44:33 -05:00
parent 89407e7d51
commit 08de059758
2254 changed files with 2399 additions and 1317 deletions

View File

@@ -0,0 +1,94 @@
var minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, 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)) {
headers = "200 OK\r\nContent-Type: text/html";
data = `<html>
<body>
<display nosave nosend>
<title>${minisrv_config.config.service_name} Admin Tricks</title>
<sidebar width=20%>
<img src="wtv-tricks:/images/Favorites_bg.jpg">
</sidebar>
<body bgcolor="#101010" text="#FF3455" link="#ff55ff" vlink="#ff55ff" vspace=0>
<font size="-1">
<br>
<br>
<h1>${minisrv_config.config.service_name} Admin Tricks</h1>
<br>
<table>
<tr>
<td colspan=3 height=6>
<tr>
<td width=170><a href="wtv-tricks:/tricks">Standard Tricks</a>
<td width=10>
<td><a href="wtv-admin:/findaccount">Account Lookup</a>
<tr>
<td colspan=3 height=6>
<tr>
<td><a href="wtv-admin:/ban">Ban an SSID</a>
<td width = 10>
<td><a href="wtv-admin:/deleteaccount">Delete an Account</a>
<tr>
<td colspan=3 height=6>
<tr>
<td><a href="wtv-admin:/unban">Unban an SSID</a>
<td width = 10>
<td><a href="wtv-admin:/deleteuser">Delete User from Account</a>
<tr>
<td colspan=3 height=6>
<tr>
<td><strike><a href="wtv-admin:/whitelist">Whitelist an SSID</a></strike>
<td width = 10>
<td><a href="wtv-admin:/removeuserpasswd">Remove Pass from User </a>
<tr>
<td colspan=3 height=6>
<tr>
<td><strike><a href="wtv-admin:/addadmin">Grant Admin to SSID</a></strike>
<td width = 10>
<td><a href="wtv-admin:/polyzoot">Polyzoot a User</a>
<tr>
<td colspan=3 height=6>
<tr>
<td><strike><a href="wtv-admin:/modadmin">Modify Admin for SSID</a></strike>
<td width = 10>
<td><a href="wtv-admin:/operatortweaks">Edit Config</a>
<tr>
<td colspan=3 height=6>
<tr>
<td><a href="wtv-admin:/regenfavs">Restore Favs for User</a>
<td width = 10>
<td><a href="wtv-admin:/reloadconfig">Reload Config</a>
<tr>
<td colspan=3 height=6>
<tr>
<td><!-- TODO -->
<td width = 10>
<td>
<!-- TODO -->
<td width = 10>
</table>
</body>
</html>
`;
} 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];
}

View File

@@ -0,0 +1,94 @@
var minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, 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.ssid) {
var ssid = request_headers.query.ssid.toLowerCase();
if (ssid == socket.ssid) {
var nobanself = true;
} else {
var fake_config = wtvshared.getUserConfig();
if (!fake_config.config) fake_config.config = {};
if (!fake_config.config.ssid_block_list) fake_config.config.ssid_block_list = [];
var entry_exists = false;
Object.keys(fake_config.config.ssid_block_list).forEach(function (k) {
if (fake_config.config.ssid_block_list[k] == ssid) {
entry_exists = true;
}
});
if (!entry_exists) {
fake_config.config.ssid_block_list.push(ssid);
wtvshared.writeToUserConfig(fake_config);
reloadConfig();
}
}
}
headers = `200 OK
Content-Type: text/html
wtv-expire-all: wtv-admin:/ban`;
if (ssid) {
headers += "\nwtv-noback-all: wtv-admin:/ban";
}
data = `<html>
<body>
<display nosave nosend>
<title>${minisrv_config.config.service_name} Admin Tricks</title>
<sidebar width=20%>
<img src="wtv-admin:/images/nuke.gif">
</sidebar>
<body bgcolor="#101010" text="#FF3455" link="#ff55ff" vlink="#ff55ff" vspace=0>
<br>
<br>
<h1>${minisrv_config.config.service_name} Admin Tricks</h1>
<br>
<table>
<tr>
<td colspan=3 height=6>
<h3>Ban an SSID</h3>
<form action="wtv-admin:/ban" method="POST">
<input type="text" name="ssid" value="${(ssid) ? ssid : ""}">
<input type="submit" value="Ban SSID">
</form><br><br>`
if (request_headers.query.ssid) {
if (nobanself) {
data += "<strong>Cannot ban yourself.</strong>"
} else {
if (entry_exists) {
data += "<strong>SSID " + request_headers.query.ssid + " is already in the ban list.</strong><br><br>";
} else {
data += "<strong>SSID " + request_headers.query.ssid + " added to the ban list.</strong><br><br>";
}
}
}
data += `
<br>
<br>
<tr>
</table>
<p align="right">
<a href="client:goback">Go Back</a>
</p>
</body>
</html>
`;
} 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];
}

View File

@@ -0,0 +1,112 @@
var minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, 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.ssid) {
var ssid_match = false;
var ssid = request_headers.query.ssid.toLowerCase();
var 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);
userAccount.unregisterBox();
}
}
}
headers = `200 OK
Content-Type: text/html
wtv-expire-all: wtv-admin:/deleteaccount
wtv-noback-all: wtv-admin:/deleteaccount`;
data = `<html>
<body>
<display nosave nosend>
<title>${minisrv_config.config.service_name} Admin Tricks</title>
<sidebar width=20%>
<img src="wtv-admin:/images/nuke.gif">
</sidebar>
<body bgcolor="#101010" text="#FF3455" link="#ff55ff" vlink="#ff55ff" vspace=0>
<br>
<br>
<h1>${minisrv_config.config.service_name} Admin Tricks</h1>
<br>
<table>
<tr>
<td colspan=3 height=6>
<h3>Delete an Account</h3>
<form action="wtv-admin:/deleteaccount" method="POST">
<input type="text" name="ssid" value="${(ssid) ? ssid : ""}"> &nbsp; <input type="submit" value="Look Up SSID">
</form><br><br>`
if (ssid) {
if (user_info) {
data += `
<strong>User Information:</strong>
<table border=1 cellpadding=3 width=400>
<tr><td>Username:</td><td>${user_info.username} (User ID: ${user_info.user_id})</td></tr>
<tr><td>SSID:</td><td>${user_info.ssid}</td></tr>`;
if (user_info.account_users) {
data += `<tr><td>Primary User:</td><td>${user_info.account_users['subscriber'].subscriber_username}</td></tr>`;
if (Object.keys(user_info.account_users).length > 1) {
data += `<tr><td>Additional Users:</td><td>`;
Object.keys(user_info.account_users).forEach(function (k) {
if (k == "subscriber") return;
data += user_info.account_users[k].subscriber_username + "<br>";
})
data += `</td></tr>`
}
}
data += `
<tr>
<td border=0 colspan=2 align=right>
<form action="wtv-admin:/deleteaccount" method="POST">
<input type="hidden" name="ssid" value="${user_info.ssid}">
<input type="hidden" name="confirm_delete" value="true">
<input type="submit" value="Confirm Delete">
</form>
</td>
</tr>
`
data += `</table>`;
} else if (request_headers.query.confirm_delete && ssid_match) {
data += `<strong>Cannot delete yourself in this manner.<br>Try ${minisrv_config.config.service_name} Tricks Unregister.</strong><br><br>`;
} else if (request_headers.query.confirm_delete) {
data += "<strong>Account for SSID \"" + ssid + "\" has been deleted.</strong><br><br>";
} else {
data += "<strong>Could not find an account for SSID \"" + ssid + "\"</strong><br><br>";
}
}
data += `
<br>
<br>
<tr>
</table>
<p align="right">
<a href="client:goback">Go Back</a>
</p>
</body>
</html>
`;
} 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];
}

View File

@@ -0,0 +1,118 @@
var minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, 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_cannot_remove_primary = false;
var show_box_was_unregistered = 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;
}
if (request_headers.query.confirm_delete) {
if (!show_cannot_modify_self) {
// delete
var userAccount = wtva.getAccountBySSID(user_info.ssid);
userAccount.switchUserID(0, false, false);
var 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);
}
}
}
}
}
headers = `200 OK
Content-Type: text/html
wtv-expire-all: wtv-admin:/deleteuser
wtv-noback-all: wtv-admin:/deleteuser`;
data = `<html>
<body>
<display nosave nosend>
<title>${minisrv_config.config.service_name} Admin Tricks</title>
<sidebar width=20%>
<img src="wtv-admin:/images/nuke.gif">
</sidebar>
<body bgcolor="#101010" text="#FF3455" link="#ff55ff" vlink="#ff55ff" vspace=0>
<br>
<br>
<h1>${minisrv_config.config.service_name} Admin Tricks</h1>
<br>
<table>
<tr>
<td colspan=3 height=6>
<h3>Delete a user from an account</h3>
<form action="wtv-admin:/deleteuser" method="POST">
<input type="text" name="username" value="${(request_headers.query.username) ? request_headers.query.username : ""}"> &nbsp; <input type="submit" value="Look Up User">
</form><br><br>`
if (request_headers.query.username) {
if (user_info && !request_headers.query.confirm_delete) {
data += `
<strong>User Information:</strong>
<table border=1 cellpadding=3 width=400>
<tr><td>Username:</td><td>${user_info.username} (User ID: ${user_info.user_id})</td></tr>
<tr><td>SSID:</td><td>${user_info.ssid}</td></tr>`;
if (user_info.account_users) {
data += `<tr><td>Primary User:</td><td>${user_info.account_users['subscriber'].subscriber_username}</td></tr>`;
}
data += `
<tr>
<td border=0 colspan=2 align=right>
<form action="wtv-admin:/deleteuser" method="POST">
<input type="hidden" name="username" value="${user_info.username}">
<input type="hidden" name="confirm_delete" value="true">
<input type="submit" value="Confirm Delete">
</form>
</td>
</tr>
`
data += `</table>`;
} else if (request_headers.query.confirm_delete && show_cannot_modify_self) {
data += `<strong>Cannot modify your account in this manner.<br>Try <a href="wtv-setup:/remove-users">wtv-setup</a>.</strong><br><br>`;
} else if (request_headers.query.confirm_delete && show_cannot_remove_primary) {
data += `<strong>Cannot delete a primary user in this manner.<br>Try <a href="wtv-admin:/deleteaccount?ssid=${user_info.ssid}">deleting the account</a>.<br><br>`;
} else if (request_headers.query.confirm_delete && show_box_was_unregistered) {
data += `<strong>Account for "${user_info.username}" was deleted, and SSID ${user_info.ssid} unregistered, as it was the only user.<br><br>`;
} else if (request_headers.query.confirm_delete) {
if (result) data += `<strong>User "${user_info.username}" has been deleted from account belonging to SSID ${user_info.ssid}.</strong><br><br>`;
else data += `<strong>Could not delete "${user_info.username}" from SSID ${user_info.ssid}.</strong><br><br>`;
} else {
data += "<strong>Could not find an account for user \"" + request_headers.query.username + "\"</strong><br><br>";
}
}
data += `
<br>
<br>
<tr>
</table>
<p align="right">
<a href="client:goback">Go Back</a>
</p>
</body>
</html>
`;
} 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];
}

View File

@@ -0,0 +1,100 @@
var minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, 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) user_info = wtva.getAccountInfoBySSID(request_headers.query.username.toLowerCase()); // ssid search
}
headers = `200 OK
Content-Type: text/html
wtv-expire-all: wtv-admin:/findaccount
wtv-noback-all: wtv-admin:/findaccount`;
data = `<html>
<body>
<display nosave nosend>
<title>${minisrv_config.config.service_name} Admin Tricks</title>
<sidebar width=20%>
<img src="wtv-tricks:/images/Favorites_bg.jpg">
</sidebar>
<body bgcolor="#101010" text="#FF3455" link="#ff55ff" vlink="#ff55ff" vspace=0>
<br>
<br>
<h1>${minisrv_config.config.service_name} Admin Tricks</h1>
<br>
<table>
<tr>
<td colspan=3 height=6>
<h3>Account Lookup</h3>
<form action="wtv-admin:/findaccount" method="POST">
<input type="text" name="username" value="${(request_headers.query.username) ? request_headers.query.username : ""}"> &nbsp; <input type="submit" value="Look Up User / SSID">
</form><br><br>`
if (request_headers.query.username) {
if (user_info) {
data += `
<strong>User Information:</strong>
<table border=1 cellpadding=3>
<tr><td>Username:</td><td>${user_info.username} (User ID: ${user_info.user_id})</td></tr>
<tr><td>SSID:</td><td>${user_info.ssid}</td></tr>`;
if (user_info.account_users) {
data += `<tr><td>Primary User:</td><td>${user_info.account_users['subscriber'].subscriber_username}</td></tr>`;
if (Object.keys(user_info.account_users).length > 1) {
data += `<tr><td>Additional Users:</td><td>`;
Object.keys(user_info.account_users).forEach(function (k) {
if (k == "subscriber") return;
data += user_info.account_users[k].subscriber_username + "<br>";
})
data += `</td></tr>`
}
}
data += `
<tr>
<td border=0 colspan=2>`;
if (wtva.isBanned(user_info.ssid)) {
data += `<a href="wtv-admin:/unban?ssid=${user_info.ssid}">Unban SSID</a>`;
data += "&nbsp;".repeat(28);
} else {
data += `<a href="wtv-admin:/ban?ssid=${user_info.ssid}">Ban SSID</a>`;
data += "&nbsp;".repeat(32);
}
data += `<a href="wtv-admin:/deleteaccount?ssid=${user_info.ssid}">Delete Account</span>
</td>
</tr>
`
data += `</table>`;
} else {
data += "<strong>Could not find user \"" + request_headers.query.username + "\"</strong><br><br>";
}
}
data += `
<br>
<br>
<tr>
</table>
<p align="right">
<a href="client:goback">Go Back</a>
</p>
</body>
</html>
`;
} 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];
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@@ -0,0 +1,272 @@
var minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
function generateFormField(type, confvar, options = null) {
if (confvar.indexOf('.') > 0) {
var 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]];
confvar = confvar.replace(".", "-");
} else
var 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`
if (options) {
Object.keys(options).forEach((k) => {
out += `<option value="${options[k].value}"${(confvar_value == options[k].value) ? ' selected' : ''}>${options[k].name}</option>\n`
});
}
return out + "</select>";
}
}
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)) {
var user_config = wtvshared.getUserConfig();
headers = "200 OK\r\nContent-Type: text/html";
data = `<html>
<body>
<display nosave nosend>
<title>${minisrv_config.config.service_name} Operator Tweaks</title>
<script type="text/javascript">
function forceNumeric(e) {
switch (e.keyCode) {
case 8:
case 9:
case 13:
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
return true;
break;
default:
return false;
}
}
function passwordFieldToggle(check) {
document.forms[0]['passwords-min_length'].disabled = !check.checked;
document.forms[0]['passwords-min_length'].readonly = !check.checked;
document.forms[0]['passwords-max_length'].disabled = !check.checked;
document.forms[0]['passwords-max_length'].readonly = !check.checked;
document.forms[0]['passwords-form_size'].disabled = !check.checked;
document.forms[0]['passwords-form_size'].readonly = !check.checked;
}
function validateNumber(field, min, max, def) {
var num = parseInt(field.value);
if (num === NaN) num = def;
if (num < min) num = min;
if (num > max) num = max;
if (field.value != num) field.value = num;
}
</script>
<sidebar width=20%>
<img src="wtv-tricks:/images/Favorites_bg.jpg">
</sidebar>
<body bgcolor="#101010" text="#EE44bb" link="#ff55ff" vlink="#ff55ff" vspace=0>
<font size="-1">
<br>
<br>
<h1><font color=#FF3455>${minisrv_config.config.service_name} Operator Tweaks</font></h1>
<font size=-1><i>These settings can be updated without restarting minisrv</i></font>
<hr>
<table>
<tr>
<TD>
<TR>
<td>
<tr>
<td WIDTH=198 VALIGN=top ALIGN=left>
<table cellspacing=0 cellpadding=5>
<tr><td absheight=60 valign=top>
<font size=-1><b>service_owner</b><br>The name of the server
operator
<tr><td absheight=60 valign=top>
<font size=-1><b>service_owner_account</b><br>The minisrv account name of the server
operator
<tr><td absheight=90 valign=top>
<font size=-1><b>service_owner_contact</b><br>The email address or username of the
server operator where users can contact them
<tr><td absheight=100 valign=top>
<font size=-1><b>service_owner_<br>contact_method</b><br>The method by which the user can
contact the server operator (eg. email, Discord, Twitter, etc...)
<tr><td absheight=60 valign=top>
<font size=-1><b>service_name</b><br>The name of the service (eg. WebTV)
<tr><td absheight=90 valign=top>
<font size=-1><b>service_logo</b><br>The logo for the service. Absolute URL, or file name in the Shared ROMCache.
<tr><td absheight=90 valign=top>
<font size=-1><b>service_splash_logo</b><br>The splash page logo for the service. Absolute URL, or file name in the Shared ROMCache.
<tr><td absheight=60 valign=top>
<font size=-1><b>show_detailed_splash</b><br>Show service information and client connection speed on the splash page.
<tr><td absheight=60 valign=top>
<font size=-1><b>hide_ssid_in_logs</b><br>Filter SSIDs in console logs and log files.
<tr><td absheight=90 valign=top>
<font size=-1><b>filter_<br>passwords_in_logs</b><br>Filter passwords (if the form field contains 'pass') in console logs and log files.
<tr><td absheight=45 valign=top>
<font size=-1><b>verbosity</b><br>Console log debug level.
<tr><td absheight=60 valign=top>
<font size=-1><b>show_diskmap</b><br>Useful for debugging wtv-disk downloads.
<tr><td absheight=140 valign=top>
<font size=-1><b>allow_guests</b><br>Allows users to use the service without having to register.
Guest session data is destroyed upon logout, and some features are not available to guests.
<tr><td absheight=90 valign=top>
<font size=-1><b>enable_<br>lzpf_compression</b><br>Toggles whether LZPF compression will be considered or not
<tr><td absheight=90 valign=top>
<font size=-1><b>enable_<br>gzip_compression</b><br>Toggles whether GZIP compression will be considered or not
<tr><td absheight=45 valign=top>
<font size=-1><b>Max Users Per Account</b>
<tr><td absheight=45 valign=top>
<font size=-1><b>Min Username Length</b>
<tr><td absheight=45 valign=top>
<font size=-1><b>Max Username Length</b>
<tr><td absheight=120 valign=top>
<font size=-1><b>Enable Passwords</b><br>
When disabled, accounts will not be able to use passwords, if they had a password set prior, the account will be accessible without it.
<tr><td absheight=45 valign=top>
<font size=-1><b>Min Password Length</b>
<tr><td absheight=45 valign=top>
<font size=-1><b>Max Password Length</b>
<tr><td absheight=60 valign=top>
<font size=-1><b>Password Field Size</b>
The size of the field on the login password page
</table>
<TD WIDTH=15>
<TD WIDTH=198 absheight=1640 VALIGN=top ALIGN=left colspan=2>
<form action="wtv-admin:/validate-operator-tweaks">
<input type=hidden name=autosubmit value=true autosubmit=onleave>
<table cellspacing=0 cellpadding=5>
<tr><td valign=top>
<table>
<tr>
<td absheight=60 valign=top>
${generateFormField('input', 'service_owner')}
<tr>
<td absheight=60 valign=top>
${generateFormField('input', 'service_owner_account')}
<tr>
<td absheight=90 valign=top>
${generateFormField('input', 'service_owner_contact')}
<tr>
<td absheight=90 valign=top>
${generateFormField('input', 'service_owner_contact_method')}
<tr>
<td absheight=55 valign=top>
${generateFormField('input', 'service_name')}
<tr>
<td absheight=85 valign=top>
${generateFormField('input', 'service_logo')}
<tr>
<td absheight=90 valign=top>
${generateFormField('input', 'service_splash_logo')}
<tr>
<td absheight=60 valign=top>
${generateFormField('checkbox', 'show_detailed_splash')}
<tr>
<td absheight=60 valign=top>
${generateFormField('checkbox', 'hide_ssid_in_logs')}
<tr>
<td absheight=80 valign=top>
${generateFormField('checkbox', 'filter_passwords_in_logs')}
<tr>
<td absheight=50 valign=top>
${generateFormField('select', 'verbosity', [
{ "name": "Quiet (0)", value: 0 },
{ "name": "Show Headers (1)", value: 1 },
{ "name": "Verbose, without Headers (2)", value: 2 },
{ "name": "Verbose, with headers (3)", value: 3 },
{ "name": "Debug (4)", value: 4 },
])}
<tr>
<td absheight=60 valign=top>
${generateFormField('checkbox', 'show_diskmap')}
<tr>
<td absheight=140 valign=top>
${generateFormField('checkbox', 'allow_guests')}
<tr>
<td absheight=85 valign=top>
${generateFormField('checkbox', 'enable_lzpf_compression')}
<tr>
<td absheight=80 valign=top>
${generateFormField('checkbox', 'enable_gzip_compression')}
<tr>
<td absheight=42 valign=top>
${generateFormField('input', 'user_accounts.max_users_per_account', "size=2 onkeypress='return forceNumeric(event)' onchange='validateNumber(this,1,50,6)' maxlength=2")}
<tr>
<td absheight=42 valign=top>
${generateFormField('input', 'user_accounts.min_username_length', "size=2 onkeypress='return forceNumeric(event)' onchange='validateNumber(this,3,50,5)' maxlength=2")}
<tr>
<td absheight=50 valign=top>
${generateFormField('input', 'user_accounts.max_username_length', "size=2 onkeypress='return forceNumeric(event)' onchange='validateNumber(this,3,50,18)' maxlength=2")}
<tr>
<td absheight=113 valign=top>
${generateFormField('checkbox', 'passwords.enabled', "onchange='passwordFieldToggle(this)'")}
<tr>
<td absheight=40 valign=top>
${generateFormField('input', 'passwords.min_length', "size=2 onkeypress='return forceNumeric(event)' onchange='validateNumber(this,3,32,5)' maxlength=2")}
<tr>
<td absheight=46 valign=top>
${generateFormField('input', 'passwords.max_length', "size=2 onkeypress='return forceNumeric(event)' onchange='validateNumber(this,3,256,32)' maxlength=2")}
<tr>
<td absheight=60 valign=top>
${generateFormField('input', 'passwords.form_size', "size=2 onkeypress='return forceNumeric(event)' onchange='validateNumber(this,5,99,16)' maxlength=2")}
</table>
</table>
</form>
<tr>
<td colspan=4><hr>
<TR>
<TD>
<TD COLSPAN=2 VALIGN=top ALIGN=left>
<TD VALIGN=top ALIGN=right>
<FORM action="client:goback">
<FONT COLOR="#E7CE4A" SIZE=-1><SHADOW>
<INPUT TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" Value=Done NAME="Done" USESTYLE WIDTH=103>
</SHADOW></FONT></FORM>
<TD><TD>
<tr><td>
</TABLE>
</body>
</html>
`;
} 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];
}

View File

@@ -0,0 +1,133 @@
var minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, 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(classPath + "/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(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 = {};
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 = `<html>
<body>
<display nosave nosend>
<title>${minisrv_config.config.service_name} Admin Tricks</title>
<sidebar width=20%>
<img src="wtv-admin:/images/polyzoot.jpg">
</sidebar>
<body bgcolor="#101010" text="#FF3455" link="#ff55ff" vlink="#ff55ff" vspace=0>
<br>
<br>
<h1>${minisrv_config.config.service_name} Admin Tricks</h1>
<br>
<table>
<tr>
<td colspan=3 height=6>
<h3>Polyzoot a User</h3>`;
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.<br><br>`
}
data += `
<form action="wtv-admin:/polyzoot" method="POST">
<input type="text" name="username" value="${(request_headers.query.username) ? request_headers.query.username : ""}"> &nbsp; <input type="submit" value="Look Up User">
</form><br><br>`
if (request_headers.query.username) {
if (user_info && !request_headers.query.confirm && !request_headers.query.reset) {
if (user_info.username == session_data.getSessionData("subscriber_username")) {
data += `Are you sure you want to Polyzoot <b>yourself</b>?<br>Are you a masochist?`;
} else {
data += `Are you sure you want to Polyzoot <b>${user_info.username}</b>?<br>Are you a sadist?`;
}
data += `
<br><br>
<tr>
<td>
<form action="wtv-admin:/polyzoot" method="POST">
<input type="hidden" name="username" value="${user_info.username}">
<input type="hidden" name="reset" value="true">
<input type="submit" value="Release This Soul (Reset)">
</td>
<td>
<form action="wtv-admin:/polyzoot" method="POST">
<input type="hidden" name="username" value="${user_info.username}">
<input type="hidden" name="confirm" value="true">
<input type="submit" value="Torture This Soul">
</form>
</td>
</tr>
`
data += `</table>`;
} else if (request_headers.query.confirm) {
data += `You have condemned <strong>${user_info.username}</strong><br> to endless loops of Polyzoot.<br><br>It will take effect upon their next login.<br><br>`;
} else if (request_headers.query.reset) {
data += `You have freed <strong>${user_info.username}'s</strong> soul<br> from the bounds of Polyzoot.<br><br>It will take effect upon their next login.<br><br>`;
}
}
data += `
<br>
<br>
<tr>
</table>
<p align="right">
<a href="client:goback">Go Back</a>
</p>
</body>
</html>
`;
} 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];
}

View File

@@ -0,0 +1,98 @@
var minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, 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.folder) {
if (userAccount.favstore.favstoreExists()) {
if (userAccount.favstore.folderExists(request_headers.query.folder)) {
userAccount.favstore.deleteFolder(request_headers.query.folder);
}
userAccount.favstore.createTemplateFolder(request_headers.query.folder);
}
}
}
}
headers = `200 OK
Content-Type: text/html
wtv-expire-all: wtv-admin:/regenfavs
wtv-noback-all: wtv-admin:/regenfavs`;
data = `<html>
<body>
<display nosave nosend>
<title>${minisrv_config.config.service_name} Admin Tricks</title>
<sidebar width=20%>
<img src="wtv-tricks:/images/Favorites_bg.jpg">
</sidebar>
<body bgcolor="#101010" text="#FF3455" link="#ff55ff" vlink="#ff55ff" vspace=0>
<br>
<br>
<h1>${minisrv_config.config.service_name} Admin Tricks</h1>
<br>
<table>
<tr>
<td colspan=3 height=6>
<h3>Restore a default favorites folder for a User</h3>
<form action="wtv-admin:/regenfavs" method="POST">
<input type="text" name="username" value="${(request_headers.query.username) ? request_headers.query.username : ""}"> &nbsp; <input type="submit" value="Look Up User">
</form><br><br>`
if (request_headers.query.username) {
if (user_info && !request_headers.query.folder) {
if (userAccount.favstore.favstoreExists()) {
data += `<form action="wtv-admin:/regenfavs" method="POST">
<input type="hidden" name="username" value="${user_info.username}">
<select name="folder">`;
Object.keys(minisrv_config.favorites.folder_templates).forEach(function (k) {
data += `<option value="${k}">${k}</option`;
});
data += `</select>
<input type="submit" value="Restore Folder">
</form>
</td>
</tr>
`
data += `</table>`;
} else {
data += `<strong>${user_info.username} has not initialized their favorites.</strong><br><br>`;
}
} else {
data += `<strong>Successfully regenerated folder ${request_headers.query.folder} for user "${user_info.username}"</strong><br><br>`;
}
}
data += `
<br>
<br>
<tr>
</table>
<p align="right">
<a href="client:goback">Go Back</a>
</p>
</body>
</html>
`;
} 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];
}

View File

@@ -0,0 +1,56 @@
var minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, 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)) {
reloadConfig();
headers = `200 OK
Content-Type: text/html
wtv-expire-all: wtv-admin:/reloadconfig
wtv-noback-all: wtv-admin:/reloadconfig`;
data = `<html>
<body>
<display nosave nosend>
<title>${minisrv_config.config.service_name} Admin Tricks</title>
<sidebar width=20%>
<img src="wtv-tricks:/images/Favorites_bg.jpg">
</sidebar>
<body bgcolor="#101010" text="#FF3455" link="#ff55ff" vlink="#ff55ff" vspace=0>
<br>
<br>
<h1>${minisrv_config.config.service_name} Admin Tricks</h1>
<br>
<table>
<tr>
<td colspan=3 height=6>
<h3>Reload Config</h3>
The config.json and user_config.json files has been reloaded.<br>
If you added a new service, it will not bind without a restart.
<tr>
</table>
<p align="right">
<a href="client:goback">Go Back</a>
</p>
</body>
</html>
`;
} 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];
}

View File

@@ -0,0 +1,109 @@
var minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, 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 = `<html>
<body>
<display nosave nosend>
<title>${minisrv_config.config.service_name} Admin Tricks</title>
<sidebar width=20%>
<img src="wtv-admin:/images/nuke.gif">
</sidebar>
<body bgcolor="#101010" text="#FF3455" link="#ff55ff" vlink="#ff55ff" vspace=0>
<br>
<br>
<h1>${minisrv_config.config.service_name} Admin Tricks</h1>
<br>
<table>
<tr>
<td colspan=3 height=6>
<h3>Remove Password from a User Account</h3>
<form action="wtv-admin:/removeuserpasswd" method="POST">
<input type="text" name="username" value="${(request_headers.query.username) ? request_headers.query.username : ""}"> &nbsp; <input type="submit" value="Look Up User">
</form><br><br>`
if (request_headers.query.username) {
if (user_info && !request_headers.query.confirm_remove && !show_user_has_no_password && !show_cannot_modify_self) {
data += `
<strong>User Information:</strong>
<table border=1 cellpadding=3 width=400>
<tr><td>Username:</td><td>${user_info.username} (User ID: ${user_info.user_id})</td></tr>
<tr><td>SSID:</td><td>${user_info.ssid}</td></tr>`;
if (user_info.account_users) {
data += `<tr><td>Primary User:</td><td>${user_info.account_users['subscriber'].subscriber_username}</td></tr>`;
}
data += `
<tr>
<td border=0 colspan=2 align=right>
<form action="wtv-admin:/removeuserpasswd" method="POST">
<input type="hidden" name="username" value="${user_info.username}">
<input type="hidden" name="confirm_remove" value="true">
<input type="submit" value="Confirm Password Removal">
</form>
</td>
</tr>
`
data += `</table>`;
} else if (show_cannot_modify_self) {
data += `<strong>Cannot modify your account in this manner.<br>Try <a href="wtv-setup:/accounts">wtv-setup</a>.</strong><br><br>`;
} else if (show_user_has_no_password) {
data += `<strong>${user_info.username} has no password,<br>so there nothing to do.<br><br>`;
} else {
data += `<strong>Password removed from account "${user_info.username}"</strong><br><br>`;
}
}
data += `
<br>
<br>
<tr>
</table>
<p align="right">
<a href="client:goback">Go Back</a>
</p>
</body>
</html>
`;
} 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];
}

View File

@@ -0,0 +1,108 @@
var minisrv_service_file = true;
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;
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.unban_ssid) {
var config_changed = false;
var 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') {
Object.keys(fake_config.config.ssid_block_list).forEach(function (k) {
if (fake_config.config.ssid_block_list[k] == request_headers.query.unban_ssid) {
fake_config.config.ssid_block_list.splice(k, 1);
ssids_removed.push(request_headers.query.unban_ssid)
config_changed = true;
}
});
} else {
Object.keys(fake_config.config.ssid_block_list).forEach(function (k) {
Object.keys(request_headers.query.unban_ssid).forEach(function (j) {
if (fake_config.config.ssid_block_list[k] == request_headers.query.unban_ssid[j]) {
fake_config.config.ssid_block_list.splice(k,1);
ssids_removed.push(request_headers.query.unban_ssid[j])
config_changed = true;
}
});
});
}
if (config_changed) {
wtvshared.writeToUserConfig(fake_config);
minisrv_config = reloadConfig();
}
}
headers = `200 OK
Content-Type: text/html
wtv-expire-all: wtv-admin:/unban`;
if (request_headers.query.unban_ssid) {
headers += "\nwtv-noback-all: wtv-admin:/unban";
}
data = `<html>
<body>
<display nosave nosend>
<title>${minisrv_config.config.service_name} Admin Tricks</title>
<sidebar width=20%>
<img src="wtv-admin:/images/nuke_inverted.gif">
</sidebar>
<body bgcolor="#101010" text="#FF3455" link="#ff55ff" vlink="#ff55ff" vspace=0>
<br>
<br>
<h1>${minisrv_config.config.service_name} Admin Tricks</h1>
<br>
<table>
<tr>
<td colspan=3 height=6>
<h3>Unban an SSID</h3>`;
if (minisrv_config.config.ssid_block_list) {
if (minisrv_config.config.ssid_block_list.length > 0) {
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];
data += "<option value=\"" + ssid + "\">" + ssid + "</option>\n";
});
data += '</select><br><input type="submit" value="Unban SSID(s)"></form>';
} else {
data += "No SSIDs are in the ban list.<br><br>";
}
} else {
data += "No SSIDs are in the ban list.<br><br>";
}
if (ssids_removed.length > 0) {
if (config_changed) {
data += "<strong>SSID(s) " + ssids_removed + " removed from the ban list.</strong><br><br>";
}
}
data += `
<br>
<br>
<tr>
</table>
<p align="right">
<a href="client:goback">Go Back</a>
</p>
</body>
</html>
`;
} 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];
}

View File

@@ -0,0 +1,57 @@
var minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, 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)) {
var user_config = wtvshared.getUserConfig();
Object.keys(request_headers.query).forEach((k) => {
if (k === "autosubmit") return;
var v = request_headers.query[k];
// enable_multi_query may send ["false", "on"] for checkboxes due to webtvism
if (isArray(v)) v = v[(v.length - 1)];
// convert numbers back to int before writing to config
if (!isNaN(parseInt(v))) v = parseInt(v);
// convert string back to boolean before writing to config
if (v === "on" || v === "true" || v === "false") v = wtvshared.parseBool(v);
if (k.indexOf("-") > 0) {
// handle sub-config items
var 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);
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");
headers = err[0];
data = err[1];
}
}
}
if (!headers) {
err = wtvshared.doErrorPage();
headers = err[0];
data = err[1];
}