v0.9.55 (#32)
* v0.9.55 - CGI Support (eg PHP, Perl, etc) - Slight PC Admin updates - Numerous bug fixes - Security updates --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,7 @@ if(!String.prototype.repeat){String.prototype.repeat=function(c){o='';for(i=0;i<
|
||||
|
||||
d=document
|
||||
rom='file://rom/'
|
||||
rmb=rom+'Borders/'
|
||||
htm=rom+'HTMLs/'
|
||||
cch=rom+'Cache/'
|
||||
|
||||
@@ -32,7 +33,7 @@ function gTC(type,itm){
|
||||
case 1://dark
|
||||
bgclr='191919'
|
||||
tclr='42bd52'
|
||||
bbif = thb+'ButtonBorder2'
|
||||
bbif = rmb+'ButtonBorder2'
|
||||
break
|
||||
case 2://red
|
||||
bgclr='6e0005'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
WTVPCAdmin = require(classPath + "/WTVPCAdmin.js")
|
||||
var wtva = new WTVPCAdmin(minisrv_config, socket, service_name);
|
||||
WTVAdmin = require(classPath + "/WTVAdmin.js")
|
||||
var wtva = new WTVAdmin(minisrv_config, socket, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
var password = null;
|
||||
@@ -28,154 +28,21 @@ Welcome to the zefie minisrv v${minisrv_config.version} Account Administration
|
||||
</p>
|
||||
`;
|
||||
data = htmlhead;
|
||||
if (!request_headers.query.cmd) {
|
||||
data += `Please select an option to get started:
|
||||
data += `Please select an option to get started:
|
||||
<hr>
|
||||
<a href="?cmd=list">List all SSIDs and their Primary User</a><br>
|
||||
<a href="/admin/ssid?cmd=list">List all SSIDs and their Primary User</a><br>
|
||||
</p>
|
||||
</body>
|
||||
</html >`;
|
||||
}
|
||||
else if (request_headers.query.cmd == "list") {
|
||||
data += `<hr>`;
|
||||
if (request_headers.query.msg) {
|
||||
data += decodeURI(request_headers.query.msg) + "<hr>";
|
||||
}
|
||||
data += `<table border=1>`;
|
||||
accounts = wtva.listRegisteredSSIDs();
|
||||
Object.keys(accounts).forEach(function (k) {
|
||||
data += `<tr><td><a href="?cmd=ssid&ssid=${accounts[k][0]}">${accounts[k][0]}</a></td><td>${(accounts[k][1]['username'] === undefined) ? "Unregistered SSID" : accounts[k][1]['username'] }</td></tr>`;
|
||||
});
|
||||
data += `</table>`;
|
||||
|
||||
} else if (request_headers.query.cmd == "ssid") {
|
||||
var ssid = request_headers.query.ssid;
|
||||
if (!ssid) {
|
||||
redirectmsg = `An SSID is required for the ${request_headers.query.cmd} command.`;
|
||||
} else {
|
||||
data += "<hr>";
|
||||
if (request_headers.query.msg) {
|
||||
data += decodeURI(request_headers.query.msg) + "<hr>";
|
||||
}
|
||||
data += `<script>
|
||||
function validateSelection(cmd, ssid, friendlymsg) {
|
||||
conf = confirm("Are you sure you wish to "+friendlymsg+"?\\n\\n"+ssid);
|
||||
if (conf) {
|
||||
location.href = "/admin/?cmd="+cmd+"&ssid="+ssid;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
`
|
||||
data += `<p>Management for SSID: ${ssid}</p>`;
|
||||
data += `<form action="/admin/" method="GET">`
|
||||
data += `<input type="button" value="Delete Account" onclick="validateSelection('delete', '${ssid}', 'delete all accounts associated with this SSID')">`
|
||||
if (wtva.isBanned(ssid)) {
|
||||
data += `<input type="button" value="Ban Account" onclick="validateSelection('ban', '${ssid}', 'ban this SSID')" disabled=disabled>`
|
||||
data += `<input type="button" value="Unban Account" onclick="validateSelection('unban', '${ssid}', 'unban this SSID')">`
|
||||
} else {
|
||||
data += `<input type="button" value="Ban Account" onclick="validateSelection('ban', '${ssid}', 'ban this SSID')">`
|
||||
data += `<input type="button" value="Unban Account" onclick="validateSelection('unban', '${ssid}', 'unban this SSID')" disabled=disabled>`
|
||||
}
|
||||
data += "<p><table border=1>";
|
||||
user_info = wtva.getAccountInfoBySSID(ssid.toLowerCase());
|
||||
if (user_info.account_users) {
|
||||
if (user_info.account_users['subscriber']) {
|
||||
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 style="vertical-align: top">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 += "</table></p>";
|
||||
} else {
|
||||
data += "The user aborted registration, so this account has no users."
|
||||
}
|
||||
} else {
|
||||
data += "The SSID does not exist in the SessionStore."
|
||||
}
|
||||
}
|
||||
} else if (request_headers.query.cmd == "delete") {
|
||||
redirectmsg = "";
|
||||
var ssid = request_headers.query.ssid;
|
||||
if (ssid) {
|
||||
var userAccount = wtva.getAccountBySSID(ssid);
|
||||
userAccount.unregisterBox();
|
||||
redirectmsg = `All data for SSID ${ssid} has been deleted. Please note that this does not include Usenet posts made by this account.`;
|
||||
} else {
|
||||
redirectmsg = `An SSID is required for the ${request_headers.query.cmd} command.`;
|
||||
}
|
||||
headers = "302 OK\nLocation: /admin/?cmd=list&msg=" + encodeURI(redirectmsg);
|
||||
} else if (request_headers.query.cmd == "ban") {
|
||||
redirectmsg = "";
|
||||
var ssid = request_headers.query.ssid;
|
||||
if (ssid) {
|
||||
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) {
|
||||
redirectmsg = "The SSID was already banned.";
|
||||
}
|
||||
});
|
||||
if (!entry_exists) {
|
||||
fake_config.config.ssid_block_list.push(ssid);
|
||||
wtvshared.writeToUserConfig(fake_config);
|
||||
reloadConfig();
|
||||
redirectmsg = "The SSID is now banned.";
|
||||
}
|
||||
} else {
|
||||
redirectmsg = `An SSID is required for the ${request_headers.query.cmd} command.`;
|
||||
}
|
||||
headers = "302 OK\nLocation: /admin/?cmd=ssid&ssid=" + encodeURI(ssid) + "&msg=" + encodeURI(redirectmsg);
|
||||
} else if (request_headers.query.cmd == "unban") {
|
||||
redirectmsg = "The SSID was not banned, so it could not be unbanned.";
|
||||
var ssid = request_headers.query.ssid;
|
||||
if (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.ssid === 'string') {
|
||||
Object.keys(fake_config.config.ssid_block_list).forEach(function (k) {
|
||||
if (fake_config.config.ssid_block_list[k] == request_headers.query.ssid) {
|
||||
fake_config.config.ssid_block_list.splice(k, 1);
|
||||
config_changed = true
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Object.keys(fake_config.config.ssid_block_list).forEach(function (k) {
|
||||
Object.keys(request_headers.query.ssid).forEach(function (j) {
|
||||
if (fake_config.config.ssid_block_list[k] == request_headers.query.ssid[j]) {
|
||||
fake_config.config.ssid_block_list.splice(k, 1);
|
||||
config_changed = true
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
if (config_changed) {
|
||||
wtvshared.writeToUserConfig(fake_config);
|
||||
minisrv_config = reloadConfig();
|
||||
redirectmsg = "The SSID is now unbanned.";
|
||||
}
|
||||
else {
|
||||
redirectmsg = `An SSID is required for the ${request_headers.query.cmd} command.`;
|
||||
}
|
||||
}
|
||||
headers = "302 OK\nLocation: /admin/?cmd=ssid&ssid=" + encodeURI(ssid) + "&msg=" + encodeURI(redirectmsg);
|
||||
}
|
||||
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||
headers = errpage[0];
|
||||
headers += "\nWWW-Authenticate: Basic";
|
||||
data = errpage[1];
|
||||
}
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(403, auth);
|
||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||
headers = errpage[0];
|
||||
headers += "\nWWW-Authenticate: Basic";
|
||||
data = errpage[1];
|
||||
}
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(403, auth);
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
}
|
||||
154
zefie_wtvp_minisrv/includes/ServiceVault/http_pc/admin/ssid.js
Normal file
154
zefie_wtvp_minisrv/includes/ServiceVault/http_pc/admin/ssid.js
Normal file
@@ -0,0 +1,154 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
WTVAdmin = require(classPath + "/WTVAdmin.js")
|
||||
var wtva = new WTVAdmin(minisrv_config, socket, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
var password = null;
|
||||
if (request_headers.authorization) {
|
||||
var authheader = request_headers.authorization.split(' ');
|
||||
console.log(request_headers)
|
||||
|
||||
if (authheader[0] == "Basic") {
|
||||
password = Buffer.from(authheader[1], 'base64').toString();
|
||||
password = password.split(':')[1];
|
||||
}
|
||||
}
|
||||
if (wtva.checkPassword(password)) {
|
||||
headers = `200 OK
|
||||
Content-Type: text/html`
|
||||
|
||||
htmlhead = `<html>
|
||||
<head>
|
||||
<title>zefie minisrv v${minisrv_config.version} account administration</title>
|
||||
</head>
|
||||
<body bgcolor="#000000" text="#449944" link="gold" alink="gold" vlink="gold">
|
||||
<p>
|
||||
Welcome to the zefie minisrv v${minisrv_config.version} Account Administration
|
||||
</p>
|
||||
`;
|
||||
data = htmlhead;
|
||||
if (request_headers.query.cmd == "list") {
|
||||
data += `<hr>`;
|
||||
if (request_headers.query.msg) {
|
||||
data += decodeURI(request_headers.query.msg) + "<hr>";
|
||||
}
|
||||
data += `<table border=1>`;
|
||||
accounts = wtva.listRegisteredSSIDs();
|
||||
Object.keys(accounts).forEach(function (k) {
|
||||
data += `<tr><td><a href="?cmd=ssid&ssid=${accounts[k][0]}">${accounts[k][0]}</a></td><td>${(accounts[k][1]['username'] === undefined) ? "Unregistered SSID" : accounts[k][1]['username'] }</td></tr>`;
|
||||
});
|
||||
data += `</table>`;
|
||||
|
||||
} else if (request_headers.query.cmd == "ssid") {
|
||||
var ssid = request_headers.query.ssid;
|
||||
if (!ssid) {
|
||||
redirectmsg = `An SSID is required for the ${request_headers.query.cmd} command.`;
|
||||
} else {
|
||||
data += "<hr>";
|
||||
if (request_headers.query.msg) {
|
||||
data += decodeURI(request_headers.query.msg) + "<hr>";
|
||||
}
|
||||
data += `<script>
|
||||
function validateSelection(cmd, ssid, friendlymsg) {
|
||||
conf = confirm("Are you sure you wish to "+friendlymsg+"?\\n\\n"+ssid);
|
||||
if (conf) {
|
||||
location.href = "/admin/ssid/?cmd="+cmd+"&ssid="+ssid;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
`
|
||||
data += `<p>Management for SSID: ${ssid}</p>`;
|
||||
data += `<form action="/admin/" method="GET">`
|
||||
data += `<input type="button" value="Delete Account" onclick="validateSelection('delete', '${ssid}', 'delete all accounts associated with this SSID')">`
|
||||
if (wtva.isBanned(ssid)) {
|
||||
data += `<input type="button" value="Ban Account" onclick="validateSelection('ban', '${ssid}', 'ban this SSID')" disabled=disabled>`
|
||||
data += `<input type="button" value="Unban Account" onclick="validateSelection('unban', '${ssid}', 'unban this SSID')">`
|
||||
} else {
|
||||
data += `<input type="button" value="Ban Account" onclick="validateSelection('ban', '${ssid}', 'ban this SSID')">`
|
||||
data += `<input type="button" value="Unban Account" onclick="validateSelection('unban', '${ssid}', 'unban this SSID')" disabled=disabled>`
|
||||
}
|
||||
data += "<p><a href='?cmd=list'>Back to SSID List</a>";
|
||||
data += "<p><table border=1>";
|
||||
user_info = wtva.getAccountInfoBySSID(ssid);
|
||||
if (user_info.account_users) {
|
||||
if (user_info.account_users['subscriber']) {
|
||||
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 style="vertical-align: top">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 += "</table></p>";
|
||||
} else {
|
||||
data += "The user aborted registration, so this account has no users."
|
||||
}
|
||||
} else {
|
||||
data += "The SSID does not exist in the SessionStore."
|
||||
}
|
||||
}
|
||||
} else if (request_headers.query.cmd == "delete") {
|
||||
redirectmsg = "";
|
||||
var ssid = request_headers.query.ssid;
|
||||
if (ssid) {
|
||||
var userAccount = wtva.getAccountBySSID(ssid);
|
||||
userAccount.unregisterBox();
|
||||
redirectmsg = `All data for SSID ${ssid} has been deleted. Please note that this does not include Usenet posts made by this account.`;
|
||||
} else {
|
||||
redirectmsg = `An SSID is required for the ${request_headers.query.cmd} command.`;
|
||||
}
|
||||
headers = "302 OK\nLocation: /admin/?cmd=list&msg=" + encodeURI(redirectmsg);
|
||||
} else if (request_headers.query.cmd == "ban") {
|
||||
redirectmsg = "";
|
||||
var ssid = request_headers.query.ssid;
|
||||
if (ssid) {
|
||||
var result = wtva.banSSID(ssid);
|
||||
if (result === wtva.SUCCESS) {
|
||||
reloadConfig();
|
||||
redirectmsg = "The SSID is now banned.";
|
||||
} else if (result == wtva.REASON_EXISTS) {
|
||||
redirectmsg = "The SSID was already banned.";
|
||||
} else {
|
||||
redirectmsg = "Unknown response " + result.toString();
|
||||
}
|
||||
} else {
|
||||
redirectmsg = `An SSID is required for the ${request_headers.query.cmd} command.`;
|
||||
}
|
||||
headers = "302 OK\nLocation: /admin/?cmd=ssid&ssid=" + encodeURI(ssid) + "&msg=" + encodeURI(redirectmsg);
|
||||
} else if (request_headers.query.cmd == "unban") {
|
||||
redirectmsg = "The SSID was not banned, so it could not be unbanned.";
|
||||
var ssid = request_headers.query.ssid;
|
||||
if (ssid) {
|
||||
var result = wtv.unbanSSID(ssid);
|
||||
if (result === wtva.SUCCESS) {
|
||||
reloadConfig();
|
||||
redirectmsg = "The SSID is now unbanned.";
|
||||
} else if (result == wtva.REASON_EXISTS) {
|
||||
redirectmsg = "The SSID was not banned.";
|
||||
} else {
|
||||
redirectmsg = "Unknown response " + result.toString();
|
||||
}
|
||||
} else {
|
||||
redirectmsg = `An SSID is required for the ${request_headers.query.cmd} command.`;
|
||||
}
|
||||
headers = "302 OK\nLocation: /admin/?cmd=ssid&ssid=" + encodeURI(ssid) + "&msg=" + encodeURI(redirectmsg);
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(401, "Missing command.");
|
||||
headers = errpage[0];
|
||||
headers += "\nWWW-Authenticate: Basic";
|
||||
data = errpage[1];
|
||||
}
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||
headers = errpage[0];
|
||||
headers += "\nWWW-Authenticate: Basic";
|
||||
data = errpage[1];
|
||||
}
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(403, auth);
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
}
|
||||
@@ -15,24 +15,7 @@ if (auth === true) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
var result = wtva.banSSID(ssid, socket.ssid);
|
||||
}
|
||||
headers = `200 OK
|
||||
Content-Type: text/html
|
||||
@@ -61,13 +44,16 @@ wtv-expire-all: wtv-admin:/ban`;
|
||||
<input type="submit" value="Ban SSID">
|
||||
</form><br><br>`
|
||||
if (request_headers.query.ssid) {
|
||||
if (nobanself) {
|
||||
if (result == wtva.REASON_SELF) {
|
||||
data += "<strong>Cannot ban yourself.</strong>"
|
||||
} else {
|
||||
if (entry_exists) {
|
||||
if (result == wtva.REASON_EXISTS) {
|
||||
data += "<strong>SSID " + request_headers.query.ssid + " is already in the ban list.</strong><br><br>";
|
||||
} else {
|
||||
} else if (result === wtva.SUCCESS) {
|
||||
reloadConfig();
|
||||
data += "<strong>SSID " + request_headers.query.ssid + " added to the ban list.</strong><br><br>";
|
||||
} else {
|
||||
data += "<strong>Unexpected response "+result.toString()+".</strong><br><br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ wtv-language-header: en-US,en
|
||||
wtv-noback-all: wtv-
|
||||
wtv-transition-override: off
|
||||
wtv-smartcard-inserted-message: Contacting service
|
||||
wtv-addresses-url: wtv-mail:/addresslist
|
||||
wtv-ssl-timeout: 240
|
||||
wtv-login-timeout: 7200
|
||||
`;
|
||||
|
||||
@@ -1,38 +1,300 @@
|
||||
var minisrv_service_file = true;
|
||||
var minisrv_service_file = true;
|
||||
var camefrom = request_headers.query.camefrom;
|
||||
var action = request_headers.query.action;
|
||||
|
||||
if (request_headers.query.action == "editfromheader") {
|
||||
|
||||
function parseAddress() {
|
||||
var nickname = request_headers.query.nickname + ":"
|
||||
var address = request_headers.query.address;
|
||||
return {
|
||||
nickname: address
|
||||
};
|
||||
}
|
||||
var addresstoadd = parseAddress()
|
||||
|
||||
if (session_data.getSessionData("address_book")) {
|
||||
session_data.setSessionData("address_book", session_data.getSessionData("address_book") + addresstoadd);
|
||||
session_data.saveSessionData();
|
||||
} else {
|
||||
session_data.setSessionData("address_book", addresstoadd);
|
||||
session_data.saveSessionData();
|
||||
}
|
||||
|
||||
|
||||
headers = `200 OK
|
||||
Content-type: text/html
|
||||
wtv-expire: wtv-mail:/addresslist`;
|
||||
} else {
|
||||
var camefrom = request_headers.query.camefrom;
|
||||
|
||||
var CommonBLIMScripts = wtvshared.unpackCompressedB64('eNrFVttuGjEQfQaJfxjtS3ZbKFCpfQhJJIiEmiptI5V8gFkPYOG1kS9QVOXf6/Ui4l1uq0hRH9eeOXPOmVnbNzpVbGWAEzG3ZI630XeyJsVidNdqzqxIDZMC5mi+2YyInyTDGDPC+JBShVonrebfhkJjlYARZ9knF/l8NHDQeAkA9SnANgjc5KsHyPoE8mtGucQPt4dijupB/1qSbRwCxgUk00PO1hgnkAxazTCZ6bFiKOh5sUw/iEemTRyNH6M2lPVWAUdcpkusjTi6jDjkXG7qIw5PIHa7sJKcpdtrYDMwCwSrUQGhVAOBmfehDRsEYo3MiGEp4XwLJK8ORFCwYppr80h5+gqVdgSJ8V/atQYMyzDgPsUCdrJg+slHH4rw7B2JiTxj8ZoowD+YWoPeDbiFyBMLkK8i+FhKdJ/RVTKIyvnPhYocYSeoJoYbzImTJ62JQypt6H/o93q95GjIrlobPu+Dyq2gEoQ0UHDaLFA4mztTS+mWiXmnAxlZOm+t2tvNNOSmexe4cyywm9a1W2Em1zhWMntHz8/49eXALief5BocNS4JjZM87OvesNeJqjSsnr6jv0RQParA3kuFp7WFHT/DzYNcHPfRBWpHjen3D6sfDnM9by4RqPa8vjdvUVEdsP+t4Qy3ev0dXjrfKdNvE/2uQ+1OqFSKNQp3nqR4DdoQZdw14ReV9s0MRPzOt++DvRMa5ApFKazMJRnAPiy/191bRT8RgTz2tBpVVlPlDkmwK38BOaDgNQCrPC+kuJCb/e4OtMTrSMFW86ZbPJPu/gEVxhrd');
|
||||
var address_book = null
|
||||
address_book = session_data.getSessionData("address_book")
|
||||
if (address_book == null) {
|
||||
session_data.setSessionData("address_book", [])
|
||||
address_book = [];
|
||||
}
|
||||
|
||||
if (!camefrom && !action) {
|
||||
headers = `200 OK`
|
||||
|
||||
data = `<html>
|
||||
<head>
|
||||
<SAVEPANEL
|
||||
message="The address book cannot be saved, because it is part of ${ minisrv_config.config.service_name }"
|
||||
>
|
||||
<SENDPANEL action="wtv-mail:/sendmail"
|
||||
message="Write a new message"
|
||||
label="Write"
|
||||
>
|
||||
<title>Addresses</title>
|
||||
</head>
|
||||
<print blackandwhite>
|
||||
<sidebar width=114 height=420 align=left>
|
||||
<table cellspacing=0 cellpadding=0 bgcolor=333b5a>
|
||||
<tr>
|
||||
<td colspan=3 width=104 absheight=4>
|
||||
<td rowspan=100 width=10 height=420 valign=top align=left bgcolor=191919>
|
||||
<img src="wtv-mail:/ROMCache/Shadow.gif" width=6 height=420>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=93 absheight=76>
|
||||
<table href="wtv-home:/home" absheight=76 cellspacing=0 cellpadding=0 width=100%>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1>
|
||||
<td align=center>
|
||||
<img src="wtv-mail:/ROMCache/WebTVLogoJewel.gif" width=87 height=67>
|
||||
</table>
|
||||
<td abswidth=5>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=515b84>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=93 absheight=26>
|
||||
<table href="wtv-mail:/listmail"
|
||||
cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=5>
|
||||
<td abswidth=90 valign=middle align=left>
|
||||
<table bgcolor=333b5a cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td absheight=1>
|
||||
<tr>
|
||||
<td maxlines=1><shadow><font sizerange=medium color="E7CE4A">Mail list</font></shadow>
|
||||
</table>
|
||||
</table>
|
||||
<td abswidth=5>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=515b84>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=93 absheight=26>
|
||||
<table id=new href="/addressbook?camefrom=inbox&action=edit&new_address=true&selected=new"
|
||||
cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=5>
|
||||
<td abswidth=90 valign=middle align=left>
|
||||
<table bgcolor=333b5a cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td absheight=1>
|
||||
<tr>
|
||||
<td maxlines=1><shadow><font sizerange=medium color="E7CE4A">Add</font></shadow>
|
||||
</table>
|
||||
</table>
|
||||
<td abswidth=5>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=515b84>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=93 absheight=26>
|
||||
<table href="client:showalert?message=This%20feature%20is%20not%20currently%20available." transition=light cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=5>
|
||||
<td abswidth=90 valign=middle align=left>
|
||||
<table bgcolor=333b5a cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td absheight=1>
|
||||
<tr>
|
||||
<td maxlines=1><shadow><font sizerange=medium color="E7CE4A">Look up</font></shadow>
|
||||
</table>
|
||||
</table>
|
||||
<td abswidth=5>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=515b84>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=93 absheight=26>
|
||||
<table href="wtv-guide:/quickhelp?title=AddressBook"
|
||||
cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=5>
|
||||
<td abswidth=90 valign=middle align=left>
|
||||
<table bgcolor=333b5a cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td absheight=1>
|
||||
<tr>
|
||||
<td maxlines=1><shadow><font sizerange=medium color="E7CE4A">Help</font></shadow>
|
||||
</table>
|
||||
</table>
|
||||
<td abswidth=5>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=515b84>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 height=174 valign=bottom align=right >
|
||||
<img src="wtv-mail:/ROMCache/BannerMail.gif" width=50 height=96>
|
||||
<tr><td colspan=3 absheight=36>
|
||||
</table>
|
||||
</sidebar>
|
||||
<body instructions="wtv-guide:/helpindex?title=Index_Mail"
|
||||
bgcolor="191919" text="42BD52" link="189CD6" vlink="189CD6"
|
||||
vspace=0
|
||||
hspace=0>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td height=16 valign=top align=left>
|
||||
<tr>
|
||||
<td abswidth=8><img src="wtv-home:/ROMCache/Spacer.gif" width=8 height=1>
|
||||
<td height=39 valign=top>
|
||||
<font size=+1 color="E7CE4A">
|
||||
<blackface>
|
||||
<shadow>
|
||||
E-mail addresses for ${session_data.getSessionData("subscriber_username")}
|
||||
</shadow>
|
||||
</blackface>
|
||||
</font>
|
||||
</table>
|
||||
<table border=0 cellspacing=0 cellpadding=0>
|
||||
<tr absheight=26>
|
||||
<td rowspan=1000 abswidth=8>
|
||||
<td colspan=3>
|
||||
Your address is ${session_data.getSessionData("subscriber_username")}@${minisrv_config.config.service_name}
|
||||
<tr absheight=8>
|
||||
<td colspan=3>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=8>
|
||||
<tr>
|
||||
<td colspan=3 height=2 valign=middle align=center bgcolor="2B2B2B">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 height=1 valign=top align=left>
|
||||
<tr>
|
||||
<td colspan=3 height=2 valign=top align=left bgcolor="0D0D0D">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td abswidth=170 height=26 valign=middle align=left>
|
||||
<font size=-1><b>Name</b></font>
|
||||
<td abswidth=230 valign=middle align=left>
|
||||
<font size=-1><b>E-mail address</b></font>
|
||||
<td abswidth=38 valign=middle align=right>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=26>
|
||||
<tr>
|
||||
<td colspan=3 height=2 valign=middle align=center bgcolor="2B2B2B">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 height=1 valign=top align=left>
|
||||
<tr>
|
||||
<td colspan=3 height=2 valign=top align=left bgcolor="0D0D0D">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=10>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=10>
|
||||
</table>`;
|
||||
for (let i = 0; i < address_book.length; i++) {
|
||||
data += `
|
||||
<table border=0 cellspacing=0 cellpadding=0>
|
||||
<TR>
|
||||
<TD ABSWIDTH=8 valign=top>
|
||||
<TD ABSWIDTH=400>
|
||||
<TABLE cellspacing=0 cellpadding=0 HREF="/addressbook?camefrom=inbox&action=edit&id=${i}">
|
||||
<TR><TD ABSWIDTH=150 valign=top>${address_book[i].name}
|
||||
<TD ABSWIDTH=20 width=20><spacer>
|
||||
<TD ABSWIDTH=230 valign=top>${address_book[i].address}
|
||||
</TABLE>
|
||||
<TD ABSWIDTH=30>
|
||||
<TR>
|
||||
<TD colspan=4 absheight=6><spacer>
|
||||
</table>`
|
||||
}
|
||||
data += `
|
||||
</table>
|
||||
</body></html>`;
|
||||
} else {
|
||||
switch (camefrom) {
|
||||
case "messenger":
|
||||
data = `${CommonBLIMScripts}
|
||||
headers = `200 OK`;
|
||||
data = `<script language="Javascript">
|
||||
function getHumanName(emailAddress)
|
||||
{return Blim.getUmanName(emailAddress);}
|
||||
function setHumanName(emailAddress, newName)
|
||||
{return Blim.setUmanName(emailAddress, newName);}
|
||||
function MessengerIsOkay()
|
||||
{return ( Blim.isAlive() );
|
||||
}
|
||||
function isFriend(emailAddress)
|
||||
{return Blim.isInList("FL", emailAddress);
|
||||
}
|
||||
function isBlocked(emailAddress)
|
||||
{return Blim.isInList("BL", emailAddress);
|
||||
}
|
||||
function isAllowed(emailAddress)
|
||||
{return Blim.isInList("AL", emailAddress);
|
||||
}
|
||||
// policy: if the user adds a friend, we automatically allow and unblock
|
||||
// the person at the same time
|
||||
function befriendThisPerson(emailAddress)
|
||||
{Blim.addToList("FL", emailAddress);
|
||||
var executeAllow = "allowThisPerson('" + emailAddress + "');";
|
||||
var executeUnblock = "unblockThisPerson('" + emailAddress + "');";
|
||||
setTimeout(executeAllow, 1*1000);
|
||||
setTimeout(executeUnblock, 2*1000);
|
||||
}
|
||||
// policy: do not block when un-buddying-- make sure person is on allow list
|
||||
function defriendThisPerson(emailAddress)
|
||||
{Blim.removeFromList("FL", emailAddress);
|
||||
var executeAllow = "allowThisPerson('" + emailAddress + "');";
|
||||
setTimeout(executeAllow, 1*500);
|
||||
setTimeout(location.reload(), 1*600);
|
||||
}
|
||||
function blockThisPerson(emailAddress)
|
||||
{Blim.removeFromList("AL", emailAddress);
|
||||
setTimeout("blockThisPersonCore('" + emailAddress + "');", 1*1000);
|
||||
}
|
||||
function blockThisPersonCore(emailAddress)
|
||||
{Blim.addToList("BL", emailAddress);
|
||||
setTimeout(location.reload(), 1*1100);
|
||||
}
|
||||
function unblockThisPerson(emailAddress)
|
||||
{Blim.removeFromList("BL", emailAddress);
|
||||
setTimeout("allowThisPersonCore('" + emailAddress + "');", 1*1000);
|
||||
setTimeout(location.reload(), 1*1100);
|
||||
}
|
||||
function allowThisPerson(emailAddress)
|
||||
{Blim.removeFromList("BL", emailAddress);
|
||||
setTimeout("allowThisPersonCore('" + emailAddress + "');", 1*1000);
|
||||
}
|
||||
function allowThisPersonCore(emailAddress)
|
||||
{Blim.addToList("AL", emailAddress);
|
||||
}
|
||||
function disallowThisPerson(emailAddress)
|
||||
{Blim.removeFromList("AL", emailAddress);
|
||||
setTimeout("blockThisPersonCore('" + emailAddress + "');", 1*1000);
|
||||
}
|
||||
// convenience: start a conversation
|
||||
function StartConversation(emailAddress)
|
||||
{Blim.openConversation( emailAddress ); Blim.openMessagesPanel();
|
||||
}// convenience: bring up the main Messenger panel
|
||||
function ShowMessengerPanel()
|
||||
{Blim.openMessagesPanel();
|
||||
}
|
||||
</script>
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Addresses</TITLE>
|
||||
@@ -51,11 +313,11 @@ label="View saved messages">
|
||||
<TD ROWSPAN=100 WIDTH=10 HEIGHT=420 VALIGN=TOP ALIGN=LEFT BGCOLOR=191919><IMG SRC="ROMCache/Shadow.gif" WIDTH=6 HEIGHT=420>
|
||||
<TR><TD ABSWIDTH=6>
|
||||
<TD ABSWIDTH=109 ABSHEIGHT=76>
|
||||
<TABLE HREF="wtv-home:/home" ABSHEIGHT=76 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>
|
||||
<TR><TD ABSWIDTH=6>
|
||||
<TABLE HREF="wtv-home:/home" ABSHEIGHT=76 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>
|
||||
<TR><TD ABSWIDTH=6>
|
||||
<IMG SRC="ROMCache/spacer.gif" WIDTH=1>
|
||||
<TD ALIGN=CENTER><IMG SRC="ROMCache/WebTVLogoJewel.gif" WIDTH=87 HEIGHT=67>
|
||||
</TABLE>
|
||||
</TABLE>
|
||||
<TD ABSWIDTH=5>
|
||||
|
||||
<TR><TD COLSPAN=3 ABSHEIGHT=2 VALIGN=MIDDLE ALIGN=CENTER BGCOLOR=202434><IMG SRC="ROMCache/spacer.gif" WIDTH=1 HEIGHT=1>
|
||||
@@ -63,14 +325,14 @@ label="View saved messages">
|
||||
<TR><TD COLSPAN=3 ABSHEIGHT=2 VALIGN=TOP ALIGN=LEFT BGCOLOR=515B84><IMG SRC="ROMCache/spacer.gif" WIDTH=1 HEIGHT=1>
|
||||
<TR><TD ABSWIDTH=6 >
|
||||
<TD ABSWIDTH=109 ABSHEIGHT=26>
|
||||
<TABLE HREF="wtv-mail:/listmail" CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSWIDTH=5>
|
||||
<TD ABSWIDTH=109 VALIGN=MIDDLE ALIGN=LEFT>
|
||||
<TABLE BGCOLOR=333B5A CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSHEIGHT=1>
|
||||
<TR><TD MAXLINES=1><SHADOW><FONT SIZERANGE=MEDIUM COLOR="E7CE4A">Mail List</FONT></SHADOW>
|
||||
</TABLE>
|
||||
</TABLE>
|
||||
<TABLE HREF="wtv-mail:/listmail" CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSWIDTH=5>
|
||||
<TD ABSWIDTH=109 VALIGN=MIDDLE ALIGN=LEFT>
|
||||
<TABLE BGCOLOR=333B5A CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSHEIGHT=1>
|
||||
<TR><TD MAXLINES=1><SHADOW><FONT SIZERANGE=MEDIUM COLOR="E7CE4A">Mail List</FONT></SHADOW>
|
||||
</TABLE>
|
||||
</TABLE>
|
||||
<TD ABSWIDTH=5>
|
||||
|
||||
<TR><TD COLSPAN=3 ABSHEIGHT=2 VALIGN=MIDDLE ALIGN=CENTER BGCOLOR=202434><IMG SRC="ROMCache/spacer.gif" WIDTH=1 HEIGHT=1>
|
||||
@@ -79,14 +341,14 @@ label="View saved messages">
|
||||
<TR><TD ABSWIDTH=6 >
|
||||
<TD ABSWIDTH=109 ABSHEIGHT=26 >
|
||||
|
||||
<TABLE href="/addressbook?action=edit&new_address=true&selected=new" CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSWIDTH=5>
|
||||
<TD ABSWIDTH=130 VALIGN=MIDDLE ALIGN=LEFT>
|
||||
<TABLE BGCOLOR=333B5A CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSHEIGHT=1>
|
||||
<TR><TD MAXLINES=1><SHADOW><FONT SIZERANGE=MEDIUM COLOR="E7CE4A">Add</FONT></SHADOW>
|
||||
</TABLE>
|
||||
</TABLE>
|
||||
<TABLE href="/addressbook?action=edit&new_address=true&selected=new" CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSWIDTH=5>
|
||||
<TD ABSWIDTH=130 VALIGN=MIDDLE ALIGN=LEFT>
|
||||
<TABLE BGCOLOR=333B5A CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSHEIGHT=1>
|
||||
<TR><TD MAXLINES=1><SHADOW><FONT SIZERANGE=MEDIUM COLOR="E7CE4A">Add</FONT></SHADOW>
|
||||
</TABLE>
|
||||
</TABLE>
|
||||
<TD ABSWIDTH=5>
|
||||
|
||||
<TR><TD COLSPAN=3 ABSHEIGHT=2 VALIGN=MIDDLE ALIGN=CENTER BGCOLOR=202434><IMG SRC="ROMCache/spacer.gif" WIDTH=1 HEIGHT=1>
|
||||
@@ -94,14 +356,14 @@ label="View saved messages">
|
||||
<TR><TD COLSPAN=3 ABSHEIGHT=2 VALIGN=TOP ALIGN=LEFT BGCOLOR=515B84><IMG SRC="ROMCache/spacer.gif" WIDTH=1 HEIGHT=1>
|
||||
<TR><TD ABSWIDTH=6 >
|
||||
<TD ABSWIDTH=109 ABSHEIGHT=26 >
|
||||
<TABLE href="JavaScript:alert('No idea what this goes to')" CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSWIDTH=5>
|
||||
<TD ABSWIDTH=130 VALIGN=MIDDLE ALIGN=LEFT>
|
||||
<TABLE BGCOLOR=333B5A CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSHEIGHT=1>
|
||||
<TR><TD MAXLINES=1><SHADOW><FONT SIZERANGE=MEDIUM COLOR="E7CE4A">Help</FONT></SHADOW>
|
||||
</TABLE>
|
||||
</TABLE>
|
||||
<TABLE href="JavaScript:alert('No idea what this goes to')" CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSWIDTH=5>
|
||||
<TD ABSWIDTH=130 VALIGN=MIDDLE ALIGN=LEFT>
|
||||
<TABLE BGCOLOR=333B5A CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD ABSHEIGHT=1>
|
||||
<TR><TD MAXLINES=1><SHADOW><FONT SIZERANGE=MEDIUM COLOR="E7CE4A">Help</FONT></SHADOW>
|
||||
</TABLE>
|
||||
</TABLE>
|
||||
<TD ABSWIDTH=5>
|
||||
|
||||
<TR><TD COLSPAN=3 ABSHEIGHT=2 VALIGN=MIDDLE ALIGN=CENTER BGCOLOR=202434><IMG SRC="ROMCache/spacer.gif" WIDTH=1 HEIGHT=1>
|
||||
@@ -117,12 +379,14 @@ label="View saved messages">
|
||||
|
||||
<TABLE CELLSPACING=0 CELLPADDING=0>
|
||||
<TR><TD COLSPAN=3 HEIGHT=12VALIGN=TOP ALIGN=LEFT>
|
||||
<TR><TD COLSPAN=3 HEIGHT=35 VALIGN=TOP><FONT SIZE=+3 COLOR="E7CE4A"><B><SHADOW><BLACKFACE>Buddies for ${session_data.getSessionData("subscriber_username") || "You"}</BLACKFACE></SHADOW></B></FONT>
|
||||
<TR><TD COLSPAN=3 HEIGHT=35 VALIGN=TOP><FONT SIZE=+3 COLOR="E7CE4A"><B><SHADOW><BLACKFACE>Buddies for ${session_data.getSessionData("subscriber_username") || "You"
|
||||
}</BLACKFACE></SHADOW></B></FONT>
|
||||
<TR><TD COLSPAN=3 HEIGHT=25 VALIGN=TOP>
|
||||
<TABLE CELLSPACING=0 CELLPADDING=0>
|
||||
<TD WIDTH=400>Your address is ${session_data.getSessionData("messenger_email") || "unlinked"}@${session_data.getSessionData("messenger_domain") || "escargot.chat"}
|
||||
<TD ALIGN=RIGHT>
|
||||
</TABLE>
|
||||
<TABLE CELLSPACING=0 CELLPADDING=0>
|
||||
<TD WIDTH=400>Your address is ${session_data.getSessionData("messenger_email") || "unlinked"
|
||||
}@${session_data.getSessionData("messenger_domain") || "escargot.chat"}
|
||||
<TD ALIGN=RIGHT>
|
||||
</TABLE>
|
||||
</TABLE>
|
||||
|
||||
<TABLE CELLSPACING=0 CELLPADDING=0>
|
||||
@@ -145,21 +409,20 @@ var gUserHasNoFriends = (Blim.listLength("FL") < 0);
|
||||
var i;
|
||||
var listLength = Blim.listLength("FL");
|
||||
if (listLength == 0)
|
||||
{ document.write('<table border=0 cellspacing=3 cellpadding=0 ><tr>');
|
||||
document.write("<tr><td><font color=FFEFAD>You don't have any buddies yet. ");
|
||||
{document.write('<table border=0 cellspacing=3 cellpadding=0 ><tr>');
|
||||
document.write("<tr><td>You don't have any buddies yet. ");
|
||||
document.write('<p>To add a buddy or send an instant message, ');
|
||||
document.write('choose <b>Use MSN Messenger now</b>. ');
|
||||
document.write('You can also add buddies in your Address book.');
|
||||
document.write('press <b>OPTIONS</b> and choose <b>messenger</b> ');
|
||||
}
|
||||
else
|
||||
{ document.write("<table border=0 cellspacing=3 cellpadding=0><tr>");
|
||||
{document.write("<table border=0 cellspacing=3 cellpadding=0><tr>");
|
||||
var isFirst = true;
|
||||
for ( i=0 ; i < listLength; i++)
|
||||
{ var ID = Blim.listItem("FL", i);
|
||||
{var ID = Blim.listItem("FL", i);
|
||||
var humanName = Blim.getUmanName(ID);
|
||||
document.write('<tr><td maxlines=1><b><a ');
|
||||
if (isFirst)
|
||||
{ document.write(" id=firstFriend selected ");
|
||||
{document.write(" id=firstFriend selected ");
|
||||
isFirst = false;
|
||||
}
|
||||
document.write("<TD ABSWIDTH=150 HEIGHT=20 MAXLINES=1>");
|
||||
@@ -206,6 +469,336 @@ document.close();
|
||||
|
||||
|
||||
</BODY>
|
||||
</HTML>`
|
||||
</HTML>`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case "edit":
|
||||
case "editfromheader":
|
||||
const newaddress = request_headers.query.new_address
|
||||
headers = `200 OK`;
|
||||
data = `<html>
|
||||
<head>
|
||||
<DISPLAY fontsize=medium poweroffalert>
|
||||
<SAVEPANEL
|
||||
message="Save this address"
|
||||
action="client:submitform?name=addressform&submitname=action&submitvalue=Add"
|
||||
label="Save"
|
||||
>
|
||||
<SENDPANEL action="wtv-mail:/sendmail"
|
||||
message="Write a new message"
|
||||
label="Write"
|
||||
>
|
||||
<title>${(!newaddress) ? "Change" : "Add"} an e-mail address</title>
|
||||
</head>
|
||||
<print blackandwhite>
|
||||
<sidebar width=114 height=420 align=left>
|
||||
<table cellspacing=0 cellpadding=0 bgcolor=333b5a>
|
||||
<tr>
|
||||
<td colspan=3 width=104 absheight=4>
|
||||
<td rowspan=100 width=10 height=420 valign=top align=left bgcolor=191919>
|
||||
<img src="wtv-mail:/ROMCache/Shadow.gif" width=6 height=420>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=93 absheight=76>
|
||||
<table href="wtv-home:/home" absheight=76 cellspacing=0 cellpadding=0 width=100%>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1>
|
||||
<td align=center>
|
||||
<img src="wtv-mail:/ROMCache/WebTVLogoJewel.gif" width=87 height=67>
|
||||
</table>
|
||||
<td abswidth=5>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=515b84>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=93 absheight=26>
|
||||
<table href="wtv-mail:/addressbook?camefrom=inbox"
|
||||
cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=5>
|
||||
<td abswidth=90 valign=middle align=left>
|
||||
<table bgcolor=333b5a cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td absheight=1>
|
||||
<tr>
|
||||
<td maxlines=1><shadow><font sizerange=medium color="E7CE4A">Addresses</font></shadow>
|
||||
</table>
|
||||
</table>
|
||||
`;
|
||||
if (!newaddress) {
|
||||
data += `<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=515b84>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=93 absheight=26>
|
||||
<table href="wtv-mail:/addressbook?camefrom=inbox&action=discard&id=${request_headers.query.id}"
|
||||
cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td abswidth=5>
|
||||
<td abswidth=90 valign=middle align=left>
|
||||
<table bgcolor=333b5a cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td absheight=1>
|
||||
<tr>
|
||||
<td maxlines=1><shadow><font sizerange=medium color="E7CE4A">Discard</font></shadow>
|
||||
</table>
|
||||
</table>`;
|
||||
}
|
||||
data += `
|
||||
<td abswidth=5>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=middle align=center bgcolor=202434>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=1 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 absheight=2 valign=top align=left bgcolor=515b84>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr>
|
||||
<td colspan=3 height=${(!newaddress) ? "236" : "267"} valign=bottom align=right >
|
||||
<img src="wtv-mail:/ROMCache/BannerMail.gif" width=50 height=96>
|
||||
<tr><td colspan=3 absheight=${(!newaddress) ? "67" : "36"}>
|
||||
</table>
|
||||
</sidebar>
|
||||
<body instructions="wtv-guide:/helpindex?title=Index_Mail"
|
||||
bgcolor="191919" text="42BD52" link="189CD6" vlink="189CD6"
|
||||
vspace=0
|
||||
hspace=0
|
||||
fontsize="medium">
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td height=16 valign=top align=left>
|
||||
<tr>
|
||||
<td height=39 valign=top>
|
||||
<font size=+1 color="E7CE4A">
|
||||
<blackface>
|
||||
<shadow>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=10 height=4>${(!newaddress) ? "Change" : "Add"} an e-mail address
|
||||
</shadow>
|
||||
</blackface>
|
||||
</font>
|
||||
</table>
|
||||
<table cellspacing=0 cellpadding=0 width=100%>
|
||||
<tr>
|
||||
<td rowspan=100 abswidth=15
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif">
|
||||
<td colspan=4 width=100%>
|
||||
`;
|
||||
if (!newaddress) {
|
||||
data += `To change the e-mail address, make your changes, then choose <b>Done</b>.<p>
|
||||
To remove the entry from your address book, choose <b>Discard</b>.`;
|
||||
} else {
|
||||
data += "Type a name and electronic mail address to add to your address book, then choose <B>Add</B>.";
|
||||
}
|
||||
data += `
|
||||
<td abswidth=10>
|
||||
<form action="/addressbook" name="addressform" method ="POST"><tr absheight=24>
|
||||
<td colspan=6><img src="wtv-home:/ROMCache/Spacer.gif" width=10 height=24>
|
||||
<tr >
|
||||
<td>
|
||||
<td align=right valign=top>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=4><br>
|
||||
Name
|
||||
<td abswidth=10>
|
||||
<td valign=bottom colspan=3>
|
||||
<INPUT type="text" bgcolor=#202020
|
||||
cursor=#cc9933
|
||||
text="E7CE4A"
|
||||
font=proportional
|
||||
name="nickname"
|
||||
value="`;
|
||||
if (action == 'editfromheader') {
|
||||
data += request_headers.query.nickname
|
||||
} else if (action == 'edit' && request_headers.query.id) {
|
||||
data += address_book[request_headers.query.id].name
|
||||
}
|
||||
data += `"
|
||||
size=25
|
||||
maxlength=30
|
||||
autoactivate
|
||||
nosubmit>
|
||||
</tr>
|
||||
<tr absheight=12>
|
||||
<td colspan=6><img src="wtv-home:/ROMCache/Spacer.gif" width=10 height=12>
|
||||
<tr>
|
||||
<td absheight=${(!newaddress) ? "94" : "144"}>
|
||||
<td align=right valign=top>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=4><br>
|
||||
Address
|
||||
<td abswidth=10>
|
||||
<td valign=top colspan=3>
|
||||
<TEXTAREA bgcolor=#202020
|
||||
cursor=#cc9933
|
||||
text="E7CE4A"
|
||||
font=proportional
|
||||
nosoftbreaks nohardbreaks
|
||||
name="address"
|
||||
value="`;
|
||||
if (action == 'editfromheader') {
|
||||
data += request_headers.query.address
|
||||
} else if (action == 'edit' && request_headers.query.id) {
|
||||
data += address_book[request_headers.query.id].address
|
||||
}
|
||||
data += `"
|
||||
size=25
|
||||
rows=1
|
||||
maxlength=1000
|
||||
autoactivate
|
||||
autoascii
|
||||
nosubmit
|
||||
growable></TEXTAREA>
|
||||
</tr>
|
||||
<tr absheight=25>
|
||||
<td colspan=6>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=4 height=25>
|
||||
<tr><td>
|
||||
<td colspan=4 absheight=2 align=center bgcolor=2B2B2B>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr><td>
|
||||
<td colspan=4 absheight=1 align=center>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr><td>
|
||||
<td colspan=4 absheight=2 align=center bgcolor=0D0D0D>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr absheight=5>
|
||||
<td colspan=6>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=4 height=5>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<td colspan=2 align=right><FONT COLOR="#E7CE4A"><SHADOW>
|
||||
<INPUT TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" NAME=done value="${(!newaddress) ? "Done" : "Add"}"
|
||||
USESTYLE WIDTH=103
|
||||
NOARGS>
|
||||
</SHADOW></FONT>
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=10 height=1>
|
||||
</table>
|
||||
<input type=hidden name="camefrom" value="inbox">
|
||||
<input type="hidden" name="action" value="${(!newaddress) ? "change" : "add"}">
|
||||
${(!newaddress) ? `<input type=hidden name="id" value="${request_headers.query.id}">` : ""}
|
||||
</form>
|
||||
</body></html>`;
|
||||
break;
|
||||
|
||||
case "add":
|
||||
var nameExists = false;
|
||||
var addrExists = false;
|
||||
// dumbass protection for making addresses look proper in the list
|
||||
var address = request_headers.query.address.split("@")[0];
|
||||
address += `@${minisrv_config.config.service_name}`;
|
||||
// sanity checks to make sure the user doesn't have duplicate names/addresses
|
||||
address_book.forEach(user => {
|
||||
if (user.name.includes(request_headers.query.nickname)) {
|
||||
nameExists = true;
|
||||
}
|
||||
});
|
||||
|
||||
address_book.forEach(user => {
|
||||
if (user.address.includes(address)) {
|
||||
addrExists = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (addrExists) {
|
||||
headers = `400 The address <blackface>${address}</blackface> already exists in your address book.`;
|
||||
} else if (nameExists) {
|
||||
headers = `400 The name <blackface>${request_headers.query.nickname}</blackface> already exists in your address book. Please choose a different name and try again.`;
|
||||
} else {
|
||||
const entry = {
|
||||
name: request_headers.query.nickname,
|
||||
address: address
|
||||
}
|
||||
address_book.push(entry)
|
||||
session_data.setSessionData("address_book", address_book.sort(function (a, b) { return a.name < b.name ? -1 : 1; }))
|
||||
headers = `302 Moved temporarily
|
||||
wtv-expire-all: wtv-mail:/addressbook
|
||||
wtv-expire: wtv-mail:/addresslist
|
||||
Location: wtv-mail:/addressbook`;
|
||||
}
|
||||
break;
|
||||
|
||||
case "change":
|
||||
var address = request_headers.query.address
|
||||
var nickname = request_headers.query.nickname
|
||||
if (!address) {
|
||||
address = address_book[request_headers.query.id].address
|
||||
}
|
||||
if (!nickname) {
|
||||
nickname = address_book[request_headers.query.id].nickname
|
||||
}
|
||||
// dumbass protection for making addresses look proper in the list
|
||||
address = address.split("@")[0];
|
||||
address += `@${minisrv_config.config.service_name}`;
|
||||
var nameExists = false;
|
||||
var addrExists = false;
|
||||
if (address_book.length > 1) {
|
||||
var otheraddrs = address_book.slice(0)
|
||||
otheraddrs.splice(request_headers.query.id, 1)
|
||||
// sanity checks to make sure the user doesn't have duplicate names/addresses
|
||||
otheraddrs.forEach(user => {
|
||||
if (user.name.includes(nickname)) {
|
||||
nameExists = true;
|
||||
}
|
||||
});
|
||||
|
||||
otheraddrs.forEach(user => {
|
||||
if (user.address.includes(address)) {
|
||||
addrExists = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (addrExists) {
|
||||
headers = `400 The address <blackface>${address}</blackface> already exists in your address book.`;
|
||||
} else if (nameExists) {
|
||||
headers = `400 The name <blackface>${nickname}</blackface> already exists in your address book. Please choose a different name and try again.`;
|
||||
} else {
|
||||
const entry = {
|
||||
name: nickname,
|
||||
address: address
|
||||
}
|
||||
address_book[request_headers.query.id] = entry
|
||||
session_data.setSessionData("address_book", address_book.sort(function (a, b) { return a.name < b.name ? -1 : 1; }))
|
||||
headers = `302 Moved temporarily
|
||||
wtv-expire-all: wtv-mail:/addressbook
|
||||
wtv-expire: wtv-mail:/addresslist
|
||||
Location: wtv-mail:/addressbook`;
|
||||
}
|
||||
break;
|
||||
|
||||
case "discard":
|
||||
if (address_book.length == 1) {
|
||||
address_book = []
|
||||
} else {
|
||||
address_book.splice(request_headers.query.id, 1)
|
||||
}
|
||||
session_data.setSessionData("address_book", address_book.sort(function (a, b) { return a.name < b.name ? -1 : 1; }))
|
||||
headers = `302 Moved temporarily
|
||||
wtv-expire-all: wtv-mail:/addressbook
|
||||
wtv-expire: wtv-mail:/addresslist
|
||||
Location: wtv-mail:/addressbook`;
|
||||
break;
|
||||
|
||||
default:
|
||||
headers = `302 Moved temporarily
|
||||
Location: wtv-mail:/addressbook`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
headers = `200 OK
|
||||
Content-Type: x-wtv-addresses`;
|
||||
|
||||
const address_book = session_data.getSessionData("address_book")
|
||||
|
||||
if (session_data.getSessionData("address_book") != null) {
|
||||
data = ``
|
||||
for (let i = 0; i < address_book.length; i++) {
|
||||
data += address_book[i].name + '\0' + address_book[i].address + '\0'
|
||||
}
|
||||
} else {
|
||||
session_data.setSessionData("address_book", [])
|
||||
}
|
||||
@@ -143,7 +143,7 @@ label="View saved e-mail messages">
|
||||
<tr>
|
||||
<td width=10 height=26>
|
||||
<td width=89 valign=middle>
|
||||
<table cellspacing=0 cellpadding=0 href="${notImplementedAlert}"
|
||||
<table cellspacing=0 cellpadding=0 href="wtv-mail:/addressbook"
|
||||
>
|
||||
<tr>
|
||||
<td height=1>
|
||||
@@ -282,6 +282,7 @@ ${username}@${minisrv_config.config.service_name}
|
||||
Object.keys(message_list).forEach(function (k) {
|
||||
var message = message_list[k];
|
||||
if (typeof message.subject == "object" && message.subject) message.subject = wtvshared.decodeBufferText(message.subject);
|
||||
message.known_sender = session_data.isAddressInAddressBook(message.from_addr);
|
||||
var message_font_open = "<font color=#7A9FCC>";
|
||||
var message_font_close = "</font>";
|
||||
if (message.unread) {
|
||||
|
||||
@@ -42,10 +42,13 @@ Content-type: text/html`;
|
||||
|
||||
|
||||
var message_colors = null;
|
||||
|
||||
if (message.body.indexOf("<body")) {
|
||||
var default_colors = session_data.mailstore.defaultColors;
|
||||
var message_colors = session_data.mailstore.getSignatureColors(message.body);
|
||||
if (message.body) {
|
||||
if (message.body.indexOf("<body")) {
|
||||
var default_colors = session_data.mailstore.defaultColors;
|
||||
var message_colors = session_data.mailstore.getSignatureColors(message.body);
|
||||
}
|
||||
} else {
|
||||
message_colors = session_data.mailstore.defaultColors;
|
||||
}
|
||||
if (message.signature) message_colors = session_data.mailstore.getSignatureColors(message.signature);
|
||||
|
||||
@@ -282,13 +285,14 @@ ${(message.subject) ? wtvshared.htmlEntitize(message.subject) : '(No subject)'}
|
||||
if (typeof message.body === "object" && message.body) {
|
||||
message.body = wtvshared.decodeBufferText(message.body);
|
||||
}
|
||||
if (message.body) message.body = message.body.replace(/\n/g, "<br><br>");
|
||||
if (message.body.indexOf("<html>") >= 0) {
|
||||
message.allow_html = true;
|
||||
if (message.body) {
|
||||
message.body = message.body.replace(/\n/g, "<br><br>");
|
||||
if (message.body.indexOf("<html>") >= 0) {
|
||||
message.allow_html = true;
|
||||
}
|
||||
data += `${(message.allow_html) ? wtvshared.sanitizeSignature(message.body) : wtvshared.htmlEntitize(message.body, true)}`
|
||||
}
|
||||
data += `${(message.allow_html) ? wtvshared.sanitizeSignature(message.body) : wtvshared.htmlEntitize(message.body, true)}
|
||||
<br>
|
||||
<br>`;
|
||||
data += "<br><br>";
|
||||
if (message.signature) {
|
||||
data += wtvshared.sanitizeSignature(message.signature);
|
||||
}
|
||||
@@ -296,8 +300,7 @@ ${(message.subject) ? wtvshared.htmlEntitize(message.subject) : '(No subject)'}
|
||||
`;
|
||||
if (Array.isArray(message.attachments)) {
|
||||
message.attachments.forEach((v, k) => {
|
||||
if (v) {
|
||||
console.log("*****************", v['Content-Type']);
|
||||
if (v) {
|
||||
switch (v['Content-Type']) {
|
||||
case "image/jpeg":
|
||||
data += `<img border=2 src="wtv-mail:/get-attachment?message_id=${messageid}&attachment_id=${k}&wtv-title=Video%20Snapshot" width="380" height="290"><br><br>`;
|
||||
|
||||
@@ -8,26 +8,23 @@ var wtvr = new WTVRegister(minisrv_config);
|
||||
var namerand = Math.floor(Math.random() * 100000);
|
||||
var nickname = (minisrv_config.config.service_name + '_' + namerand)
|
||||
var human_name = nickname;
|
||||
var hasJS = session_data.hasCap("client-can-do-javascript");
|
||||
if (hasJS) {
|
||||
var form_data = `<script>butt('Quick Reg','speedyreg',130,'button','action="ValidateAgreement?registering=true&subscriber_name=${human_name}&subscriber_username=${nickname}"');`;
|
||||
if (minisrv_config.config.allow_guests) form_data += `butt('Sign in as Guest', 'noreg', 170, 'button', 'action="BeMyGuest"')`;
|
||||
form_data += '</script>';
|
||||
} else {
|
||||
var form_data = `<input type=button action="ValidateAgreement?registering=true&subscriber_name=${human_name}&subscriber_username=${nickname}" text="e7ce4a" Value="Quick Reg" name="speedyreg" borderimage="file://ROM/Borders/ButtonBorder2.bif" width=130>`;
|
||||
if (minisrv_config.config.allow_guests) form_data += `<input type=button text="e7ce4a" action="BeMyGuest" Value="Sign in as Guest" name="noreg" borderimage="file://ROM/Borders/ButtonBorder2.bif" width=170 >`;
|
||||
}
|
||||
var hasJS = session_data.hasCap("client-can-do-javascript") && parseInt(session_data.get('wtv-system-version')) >= 2000;
|
||||
var form_data = "";
|
||||
var main_data = `<form action="ValidateAgreement"
|
||||
ENCTYPE="x-www-form-encoded" METHOD="POST">
|
||||
<input type=hidden name=registering value="true">
|
||||
Welcome to the ${minisrv_config.config.service_name} Mini Service, operated by ${minisrv_config.config.service_owner}.
|
||||
The next screens will lead you through a quick setup process for using this service.<p> Press the "Continue" button below to begin setup.<p>`;
|
||||
|
||||
if (hasJS) {
|
||||
form_data += `<script>butt('Continue','Continue',110)</script>`;
|
||||
form_data = `<script>butt('Quick Reg','speedyreg',130,'button','action="ValidateAgreement?registering=true&subscriber_name=${human_name}&subscriber_username=${nickname}"');`;
|
||||
if (minisrv_config.config.allow_guests) form_data += `butt('Sign in as Guest', 'noreg', 170, 'button', 'action="BeMyGuest"')`;
|
||||
form_data += `butt('Continue','Continue',110)</script>`;
|
||||
} else {
|
||||
form_data = `<input type=button action="ValidateAgreement?registering=true&subscriber_name=${human_name}&subscriber_username=${nickname}" text="e7ce4a" Value="Quick Reg" name="speedyreg" borderimage="file://ROM/Borders/ButtonBorder2.bif" width=130>`;
|
||||
if (minisrv_config.config.allow_guests) form_data += `<input type=button text="e7ce4a" action="BeMyGuest" Value="Sign in as Guest" name="noreg" borderimage="file://ROM/Borders/ButtonBorder2.bif" width=170 >`;
|
||||
form_data += `<input type=submit Value=Continue name="Continue" text="#e7ce4a" borderimage="file://ROM/Borders/ButtonBorder2.bif" width=110 selected>`;
|
||||
}
|
||||
|
||||
form_data += `</form>`;
|
||||
|
||||
data = wtvr.getHTMLTemplate("Welcome to " + minisrv_config.config.service_name, main_data, form_data, hasJS);
|
||||
@@ -24,10 +24,11 @@ if (isNaN(start_time)) {
|
||||
var image_size = fs.statSync(image_filename).size
|
||||
var image_size_kb = parseFloat(image_size / 1024).toFixed(3);
|
||||
var throughput = parseFloat((image_size / download_time) * 1024).toFixed(0);
|
||||
var throughput_bps = parseInt(throughput * 8)
|
||||
data += `
|
||||
<table>
|
||||
<tr>
|
||||
<td height=20>
|
||||
<td height=5>
|
||||
<tr>
|
||||
<td valign=top align=right width=200><shadow>POP Number:</shadow>
|
||||
<td width=10>
|
||||
@@ -61,18 +62,21 @@ if (isNaN(start_time)) {
|
||||
<tr>
|
||||
<td valign=top align=right><shadow>Throughput:</shadow>
|
||||
<td width=10>
|
||||
<td valign=top>${throughput} bytes/sec
|
||||
<td valign=top>${throughput} bytes/sec (${throughput_bps} bps)
|
||||
|
||||
|
||||
</table>
|
||||
`;
|
||||
}
|
||||
data += `
|
||||
</table>
|
||||
<p>
|
||||
<p>
|
||||
<a selected href="wtv-tricks:/benchmark">Re-Test</a>
|
||||
<table>
|
||||
<tr>
|
||||
<td width=120>
|
||||
<td><a selected href="wtv-tricks:/benchmark">Re-Test</a>
|
||||
<td width=30>
|
||||
<a href="wtv-tricks:/tricks">Back to Tricks</a>
|
||||
|
||||
<td><a href="wtv-tricks:/tricks">Back to Tricks</a>
|
||||
</table>
|
||||
</CENTER>
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
@@ -21,14 +21,7 @@ tricks = [
|
||||
["client:ResetNVAndPowerOff", "Blast NVRAM"],
|
||||
["wtv-tricks:/charmap", "Character Map"],
|
||||
["wtv-tricks:/cSetup", "Connect Setup"],
|
||||
["wtv-tricks:/benchmark", "Speed Test"],
|
||||
["", ""],
|
||||
["", ""],
|
||||
["", ""],
|
||||
["", ""],
|
||||
["", ""],
|
||||
["", ""],
|
||||
["", ""],
|
||||
["wtv-tricks:/benchmark", "Speed Test"]
|
||||
]
|
||||
// add these at the bottom
|
||||
tricks.push((session_data.getSessionData("registered")) ? ["wtv-tricks:/unregister", "Unregister This Box"] : ["wtv-tricks:/register", "Register This Box"]); // reg/unreg
|
||||
@@ -39,24 +32,23 @@ data = `<html>
|
||||
<script src=/ROMCache/h.js></script><script src=/ROMCache/n.js></script><script>
|
||||
head('${minisrv_config.config.service_name} Tricks')</script>
|
||||
<table cellspacing=0 cellpadding=0><tr><td abswidth=10> <td colspan=3>
|
||||
<br>
|
||||
<table>`;
|
||||
<table><tc><td width=50> </td></tc><tc><td><table>`;
|
||||
|
||||
for (i = 0; i < tricks.length; i += 2) {
|
||||
data += `<tr>
|
||||
<td colspan=3 height=6>
|
||||
<tr>
|
||||
<td>${(tricks[i][0] != "") ? `<a href="${tricks[i][0]}">${tricks[i][1]}</a>` : `<!-- TODO --> `}
|
||||
<td>${(tricks[i][0] != "") ? `€ <a href="${tricks[i][0]}">${tricks[i][1]}</a>` : `<!-- TODO --> `}
|
||||
<td width=25>
|
||||
<td>`
|
||||
if (i + 1 < tricks.length) {
|
||||
data += (tricks[i + 1][0] != "") ? `<a href="${tricks[i + 1][0]}">${tricks[i + 1][1]}</a>` : `<!-- TODO --> `
|
||||
data += (tricks[i + 1][0] != "") ? `€ <a href="${tricks[i + 1][0]}">${tricks[i + 1][1]}</a>` : `<!-- TODO --> `
|
||||
} else {
|
||||
// require even number of tricks
|
||||
data += "<!-- TODO --> "
|
||||
}
|
||||
}
|
||||
data += `</table>
|
||||
data += `</table></td></tc></table>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
|
||||
32
zefie_wtvp_minisrv/includes/classes/Prototypes.js
Normal file
32
zefie_wtvp_minisrv/includes/classes/Prototypes.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const prototypes = {
|
||||
String: {
|
||||
reverse: function () {
|
||||
return this.split("").reverse().join("");
|
||||
},
|
||||
toHexString: function () {
|
||||
var result = '';
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
result += this.charCodeAt(i).toString(16);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
},
|
||||
Array: {
|
||||
replace: function(sub, newSub) {
|
||||
splits = this.split(sub, 2);
|
||||
return Array.concat(splits[0], newSub, splits[1])
|
||||
},
|
||||
moveKey: function (from, to) {
|
||||
this.splice(to, 0, this.splice(from, 1)[0]);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (const [type, methods] of Object.entries(prototypes)) {
|
||||
for (const [name, method] of Object.entries(methods)) {
|
||||
if (!global[type].prototype[name]) {
|
||||
global[type].prototype[name] = method;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,18 @@ class WTVAdmin {
|
||||
wtvr = null;
|
||||
wtvshared = null;
|
||||
wtvclient = null;
|
||||
pcservices = false;
|
||||
WTVClientSessionData = require("./WTVClientSessionData.js");
|
||||
service_name = "wtv-admin";
|
||||
|
||||
SUCCESS = 0
|
||||
FAIL = 1
|
||||
INVALID_OP = 2
|
||||
|
||||
REASON_NOSELF = 3
|
||||
REASON_EXISTS = 4
|
||||
REASON_NONEXIST = 5
|
||||
|
||||
constructor(minisrv_config, wtvclient, service_name) {
|
||||
this.minisrv_config = minisrv_config;
|
||||
var { WTVShared } = require("./WTVShared.js");
|
||||
@@ -16,10 +25,69 @@ class WTVAdmin {
|
||||
this.wtvclient = wtvclient;
|
||||
this.wtvshared = new WTVShared(minisrv_config);
|
||||
this.wtvr = new WTVRegister(minisrv_config);
|
||||
this.clientAddress = wtvclient.getClientAddress();
|
||||
if (this.wtvclient.remoteAddress) {
|
||||
// is a socket
|
||||
this.clientAddress = this.wtvclient.remoteAddress;
|
||||
this.pcservices = true;
|
||||
} else {
|
||||
// is wtvclient class
|
||||
this.clientAddress = this.wtvclient.getClientAddress();
|
||||
}
|
||||
this.service_name = service_name;
|
||||
}
|
||||
|
||||
banSSID(ssid, admin_ssid = null) {
|
||||
if (ssid == admin_ssid) {
|
||||
return this.REASON_NOSELF;
|
||||
} else {
|
||||
var fake_config = this.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;
|
||||
var self = this;
|
||||
Object.keys(fake_config.config.ssid_block_list).forEach(function (k) {
|
||||
if (fake_config.config.ssid_block_list[k] == ssid) {
|
||||
return self.REASON_EXISTS;
|
||||
}
|
||||
});
|
||||
if (!entry_exists) {
|
||||
fake_config.config.ssid_block_list.push(ssid);
|
||||
this.wtvshared.writeToUserConfig(fake_config);
|
||||
return this.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unbanSSID(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.ssid === 'string') {
|
||||
Object.keys(fake_config.config.ssid_block_list).forEach(function (k) {
|
||||
if (fake_config.config.ssid_block_list[k].toLowerCase() == request_headers.query.ssid.toLowerCase()) {
|
||||
fake_config.config.ssid_block_list.splice(k, 1);
|
||||
config_changed = true
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Object.keys(fake_config.config.ssid_block_list).forEach(function (k) {
|
||||
Object.keys(request_headers.query.ssid).forEach(function (j) {
|
||||
if (fake_config.config.ssid_block_list[k].toLowerCase() == request_headers.query.ssid[j].toLowerCase()) {
|
||||
fake_config.config.ssid_block_list.splice(k, 1);
|
||||
config_changed = true
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
if (config_changed) {
|
||||
wtvshared.writeToUserConfig(fake_config);
|
||||
minisrv_config = reloadConfig();
|
||||
return this.SUCCESS
|
||||
} else {
|
||||
return this.REASON_NONEXIST;
|
||||
}
|
||||
}
|
||||
|
||||
ip2long(ip) {
|
||||
var components;
|
||||
@@ -53,47 +121,87 @@ class WTVAdmin {
|
||||
|
||||
rejectConnection(reason_is_ssid) {
|
||||
var rejectReason;
|
||||
if (reason_is_ssid) {
|
||||
rejectReason = this.wtvclient.ssid + " is not in the whitelist.";
|
||||
console.log(" * Request from SSID", this.wtvshared.filterSSID(this.wtvclient.ssid), "(" + this.clientAddress + ") for wtv-admin, but that SSID is not in the admin whitelist.");
|
||||
if (this.pcservices) {
|
||||
rejectReason = this.clientAddress + " is not in the whitelist for PC Services Admin.";
|
||||
console.log(" * Request from IP (" + this.clientAddress + ") for PC Services Admin, but that IP is not authorized.");
|
||||
} else {
|
||||
rejectReason = this.clientAddress + " is not in the whitelist for SSID " + this.wtvclient.ssid + ".";
|
||||
console.log(" * Request from SSID", this.wtvshared.filterSSID(this.wtvclient.ssid), "(" + this.clientAddress + ") for wtv-admin, but that IP is not authorized for that SSID.");
|
||||
if (reason_is_ssid) {
|
||||
rejectReason = this.wtvclient.ssid + " is not in the whitelist.";
|
||||
console.log(" * Request from SSID", this.wtvshared.filterSSID(this.wtvclient.ssid), "(" + this.clientAddress + ") for wtv-admin, but that SSID is not in the admin whitelist.");
|
||||
} else {
|
||||
rejectReason = this.clientAddress + " is not in the whitelist for SSID " + this.wtvclient.ssid + ".";
|
||||
console.log(" * Request from SSID", this.wtvshared.filterSSID(this.wtvclient.ssid), "(" + this.clientAddress + ") for wtv-admin, but that IP is not authorized for that SSID.");
|
||||
}
|
||||
}
|
||||
return rejectReason;
|
||||
}
|
||||
|
||||
checkPassword(password) {
|
||||
if (this.minisrv_config.services[this.service_name].password) {
|
||||
return (password == this.minisrv_config.services[this.service_name].password);
|
||||
if (this.pcservices) {
|
||||
if (this.minisrv_config.config.pc_admin.password) {
|
||||
return (password == this.minisrv_config.config.pc_admin.password);
|
||||
} else {
|
||||
// no password set
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// no password set
|
||||
return true;
|
||||
if (this.minisrv_config.services[this.service_name].password) {
|
||||
return (password == this.minisrv_config.services[this.service_name].password);
|
||||
} else {
|
||||
// no password set
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
listRegisteredSSIDs() {
|
||||
var search_dir = this.wtvshared.getAbsolutePath(this.minisrv_config.config.SessionStore + this.path.sep + "accounts");
|
||||
var self = this;
|
||||
var out = [];
|
||||
this.fs.readdirSync(search_dir).forEach(file => {
|
||||
if (self.fs.lstatSync(search_dir + self.path.sep + file).isDirectory()) {
|
||||
var user = self.getAccountInfoBySSID(file);
|
||||
out.push([file, user]);
|
||||
}
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
isAuthorized(justchecking = false) {
|
||||
var allowed_ssid = false;
|
||||
var allowed_ip = false;
|
||||
if (this.minisrv_config.services[this.service_name].authorized_ssids) {
|
||||
var self = this;
|
||||
Object.keys(self.minisrv_config.services[this.service_name].authorized_ssids).forEach(function (k) {
|
||||
if (typeof self.minisrv_config.services[self.service_name].authorized_ssids[k] == "string") {
|
||||
var ssid = self.minisrv_config.services[self.service_name].authorized_ssids[k]
|
||||
if (ssid == self.wtvclient.ssid) allowed_ssid = true;
|
||||
allowed_ip = true; // no ip block defined
|
||||
} else {
|
||||
var ssid = k;
|
||||
if (ssid == self.wtvclient.ssid) {
|
||||
allowed_ssid = true;
|
||||
Object.keys(self.minisrv_config.services[self.service_name].authorized_ssids[k]).forEach(function (j) {
|
||||
if (self.isInSubnet(self.clientAddress, self.minisrv_config.services[self.service_name].authorized_ssids[k][j])) {
|
||||
allowed_ip = true;
|
||||
}
|
||||
});
|
||||
var use_ssid = (this.wtvclient.ssid && !this.pcservices) ? true : false
|
||||
if (use_ssid) {
|
||||
if (this.minisrv_config.services[this.service_name].authorized_ssids) {
|
||||
var self = this;
|
||||
Object.keys(self.minisrv_config.services[this.service_name].authorized_ssids).forEach(function (k) {
|
||||
if (typeof self.minisrv_config.services[self.service_name].authorized_ssids[k] == "string") {
|
||||
var ssid = self.minisrv_config.services[self.service_name].authorized_ssids[k]
|
||||
if (ssid == self.wtvclient.ssid) allowed_ssid = true;
|
||||
allowed_ip = true; // no ip block defined
|
||||
} else {
|
||||
var ssid = k;
|
||||
if (ssid == self.wtvclient.ssid) {
|
||||
allowed_ssid = true;
|
||||
Object.keys(self.minisrv_config.services[self.service_name].authorized_ssids[k]).forEach(function (j) {
|
||||
if (self.isInSubnet(self.clientAddress, self.minisrv_config.services[self.service_name].authorized_ssids[k][j])) {
|
||||
allowed_ip = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (this.pcservices) {
|
||||
if (this.minisrv_config.config.pc_admin.ip_whitelist) {
|
||||
var self = this;
|
||||
Object.keys(this.minisrv_config.config.pc_admin.ip_whitelist).forEach(function (k) {
|
||||
allowed_ip = self.isInSubnet(self.clientAddress, self.minisrv_config.config.pc_admin.ip_whitelist[k]);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
allowed_ssid = true;
|
||||
}
|
||||
if (justchecking) {
|
||||
return (allowed_ssid && allowed_ip) ? true : false;
|
||||
@@ -103,7 +211,7 @@ class WTVAdmin {
|
||||
}
|
||||
|
||||
getAccountInfo(username, directory = null) {
|
||||
var search_dir = this.minisrv_config.config.SessionStore + this.path.sep + "accounts";
|
||||
var search_dir = this.wtvshared.getAbsolutePath(this.minisrv_config.config.SessionStore + this.path.sep + "accounts");
|
||||
var account_data = null;
|
||||
var self = this;
|
||||
if (directory) search_dir = directory;
|
||||
@@ -118,7 +226,7 @@ class WTVAdmin {
|
||||
var temp_session_data = JSON.parse(temp_session_data_file);
|
||||
|
||||
if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) {
|
||||
account_data = [temp_session_data, (search_dir + self.path.sep + file).replace(this.minisrv_config.config.SessionStore + this.path.sep + "accounts", "").split(this.path.sep)[1]];
|
||||
account_data = [temp_session_data, (search_dir + self.path.sep + file).replace(this.wtvshared.getAbsolutePath(this.minisrv_config.config.SessionStore + this.path.sep + "accounts"), "").split(this.path.sep)[1]];
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(" # Error parsing Session Data JSON", search_dir + self.path.sep + file, e);
|
||||
@@ -145,7 +253,16 @@ class WTVAdmin {
|
||||
if (userSession.isRegistered(false)) {
|
||||
account_info.ssid = ssid;
|
||||
account_info.account_users = userSession.listPrimaryAccountUsers();
|
||||
account_info.username = account_info.account_users['subscriber'].subscriber_username;
|
||||
if (account_info.account_users) {
|
||||
if (account_info.account_users['subscriber']) {
|
||||
account_info.username = account_info.account_users['subscriber'].subscriber_username;
|
||||
} else {
|
||||
account_info.username = account_info.account_users[0];
|
||||
}
|
||||
} else {
|
||||
account_info.username = account_info.account_users[0];
|
||||
}
|
||||
|
||||
account_info.user_id = 0;
|
||||
return account_info;
|
||||
}
|
||||
|
||||
@@ -127,6 +127,19 @@ class WTVClientSessionData {
|
||||
return true;
|
||||
}
|
||||
|
||||
isAddressInAddressBook(addr) {
|
||||
const addresses = this.getSessionData("address_book");
|
||||
if (addresses) {
|
||||
for (let i = 0; i < addresses.length; i++) {
|
||||
console.log(addr.toLowerCase(), addresses[i].address.toLowerCase())
|
||||
if (addr.toLowerCase() == addresses[i].address.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
findFreeUserSlot() {
|
||||
if (this.user_id != 0) return false; // subscriber only command
|
||||
var master_directory = this.getUserStoreDirectory(true);
|
||||
@@ -158,10 +171,11 @@ class WTVClientSessionData {
|
||||
var master_directory = this.getUserStoreDirectory(true);
|
||||
var account_data = [];
|
||||
var self = this;
|
||||
this.debug(this.ssid)
|
||||
this.fs.readdirSync(master_directory).forEach(f => {
|
||||
if (self.fs.lstatSync(master_directory + self.path.sep + f).isDirectory()) {
|
||||
if (f.substr(0, 4) == "user") {
|
||||
var user_file = master_directory + self.path.sep + f + self.path.sep + f + ".json";
|
||||
var user_file = this.path.resolve(master_directory + self.path.sep + f + self.path.sep + f + ".json");
|
||||
if (self.fs.existsSync(user_file)) {
|
||||
if (f == "user0") {
|
||||
account_data['subscriber'] = JSON.parse(this.fs.readFileSync(user_file));
|
||||
@@ -193,7 +207,7 @@ class WTVClientSessionData {
|
||||
}
|
||||
|
||||
getAccountStoreDirectory() {
|
||||
return this.path.resolve(this.wtvshared.getAbsolutePath() + this.path.sep + this.minisrv_config.config.SessionStore + this.path.sep + "accounts");
|
||||
return this.wtvshared.getAbsolutePath(this.minisrv_config.config.SessionStore + this.path.sep + "accounts");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +219,7 @@ class WTVClientSessionData {
|
||||
if (user_id == null) user_id = this.user_id;
|
||||
var userstore = this.getAccountStoreDirectory() + this.path.sep + this.ssid + this.path.sep;
|
||||
if (!subscriber) userstore += "user" + user_id + this.path.sep;
|
||||
return userstore;
|
||||
return this.wtvshared.getAbsolutePath(userstore);
|
||||
}
|
||||
|
||||
removeUser(user_id) {
|
||||
@@ -264,7 +278,7 @@ class WTVClientSessionData {
|
||||
if (!store_dir) return false; // unregistered
|
||||
// FileStore
|
||||
store_dir += "FileStore" + this.path.sep;
|
||||
var store_dir_path = this.wtvshared.makeSafePath(store_dir, path.replace('/', this.path.sep));
|
||||
var store_dir_path = this.wtvshared.getAbsolutePath(this.wtvshared.makeSafePath(store_dir, path.replace('/', this.path.sep)));
|
||||
if (this.fs.existsSync(store_dir_path)) return this.fs.readFileSync(store_dir_path);
|
||||
else return false;
|
||||
}
|
||||
@@ -611,8 +625,8 @@ class WTVClientSessionData {
|
||||
}
|
||||
|
||||
getSessionData(key = null) {
|
||||
if (typeof (this.data_store) === 'session_store') return null;
|
||||
else if (key === null) return this.data_store;
|
||||
if (typeof (this.session_store) === 'session_store') return null;
|
||||
else if (key === null) return this.session_store;
|
||||
else if (this.session_store[key]) return this.session_store[key];
|
||||
else return null;
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ class WTVMail {
|
||||
|
||||
checkUserExists(username, directory = null) {
|
||||
// returns the user's ssid, and user_id and userid in an array if true, false if not
|
||||
var search_dir = this.minisrv_config.config.SessionStore;
|
||||
var search_dir = this.path.resolve(this.wtvshared.getAbsolutePath() + this.path.sep + this.minisrv_config.config.SessionStore);
|
||||
var return_val = false;
|
||||
var self = this;
|
||||
if (directory) search_dir = directory;
|
||||
@@ -388,9 +388,11 @@ class WTVMail {
|
||||
try {
|
||||
var temp_session_data_file = self.fs.readFileSync(search_dir + self.path.sep + file, 'Utf8');
|
||||
var temp_session_data = JSON.parse(temp_session_data_file);
|
||||
if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) {
|
||||
return_val = search_dir.replace(this.minisrv_config.config.SessionStore + self.path.sep + "accounts" + self.path.sep, '').replace("user", '').split(self.path.sep);
|
||||
return_val.push(temp_session_data.subscriber_name);
|
||||
if (temp_session_data.subscriber_username) {
|
||||
if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) {
|
||||
return_val = search_dir.replace(this.minisrv_config.config.SessionStore + self.path.sep + "accounts" + self.path.sep, '').replace("user", '').split(self.path.sep);
|
||||
return_val.push(temp_session_data.subscriber_name);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(" # Error parsing Session Data JSON", file, e);
|
||||
|
||||
@@ -228,13 +228,13 @@ class WTVNewsServer {
|
||||
post_data.headers['Injection-Date'] = this.strftime("%a, %-d %b %Y %H:%M:%S %z", Date.parse(Date.now()))
|
||||
|
||||
// Reorder headers per examples in RFC3977 sect 6.2.1.3, not sure if needed
|
||||
post_data.headers = this.wtvshared.moveObjectElement('Path', null, post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectElement('From', 'Path', post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectElement('Newsgroups', 'From', post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectElement('Subject', 'Newsgroups', post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectElement('Date', 'Subject', post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectElement('Organization', 'Date', post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectElement('Message-ID', 'Organization', post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectKey('Path', null, post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectKey('From', 'Path', post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectKey('Newsgroups', 'From', post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectKey('Subject', 'Newsgroups', post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectKey('Date', 'Subject', post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectKey('Organization', 'Date', post_data.headers, true);
|
||||
post_data.headers = this.wtvshared.moveObjectKey('Message-ID', 'Organization', post_data.headers, true);
|
||||
// end reordering of headers
|
||||
|
||||
if (this.articleExists(group, post_data.articleNumber)) return false // should not occur, but just in case
|
||||
|
||||
@@ -95,9 +95,9 @@ class WTVRegister {
|
||||
}
|
||||
data += `<display nooptions>
|
||||
|
||||
<table width=520 align=center cellspacing=0 cellpadding=0>
|
||||
<table width=480 align=center cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td height=272>
|
||||
<td height=242>
|
||||
<font size=+1>
|
||||
${main_content}
|
||||
<p>
|
||||
|
||||
@@ -349,7 +349,7 @@ class WTVShared {
|
||||
|
||||
utf8Decode(utf8String) {
|
||||
if (typeof utf8String !== 'string') {
|
||||
throw new TypeError('parameter <20>utf8String<6E> is not a string');
|
||||
throw new TypeError('parameter <20>utf8String<6E> is not a string');
|
||||
}
|
||||
const textDecoder = new TextDecoder('utf-8');
|
||||
const bytes = new Uint8Array(utf8String.split('').map(c => c.charCodeAt(0)));
|
||||
@@ -480,57 +480,6 @@ class WTVShared {
|
||||
else return this.parseSSID(ssid).manufacturer || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves an object to the desired location in the object (reorder)
|
||||
* @param {string} currentKey Name of the object Key to move
|
||||
* @param {string} afterKey Name of the object key to place currentKey after
|
||||
* @param {object} obj The object to work on
|
||||
* @param {boolean} caseInsensitive
|
||||
* @returns {object} The modified object
|
||||
*/
|
||||
moveObjectElement(currentKey, afterKey, obj, caseInsensitive = false) {
|
||||
let keys = Object.keys(obj);
|
||||
let values = Object.values(obj);
|
||||
|
||||
if (caseInsensitive) {
|
||||
const lowerCurrentKey = currentKey.toLowerCase();
|
||||
const foundKey = keys.find(k => k.toLowerCase() === lowerCurrentKey);
|
||||
currentKey = foundKey || currentKey;
|
||||
}
|
||||
|
||||
const afterKeyIndex = typeof afterKey === 'string' ?
|
||||
keys.findIndex(k => caseInsensitive ? k.toLowerCase() === afterKey.toLowerCase() : k === afterKey)
|
||||
: -1;
|
||||
|
||||
if (afterKeyIndex === -1) {
|
||||
// If afterKey is not found or not defined, don't move the element
|
||||
return obj;
|
||||
}
|
||||
|
||||
const currentIndex = keys.indexOf(currentKey);
|
||||
if (currentIndex === -1) {
|
||||
// If currentKey is not found, don't move the element
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Remove the current element from keys and values
|
||||
const [currentKeyValue] = values.splice(currentIndex, 1);
|
||||
keys.splice(currentIndex, 1);
|
||||
|
||||
// Insert the current element after the afterKey position
|
||||
keys.splice(afterKeyIndex + 1, 0, currentKey);
|
||||
values.splice(afterKeyIndex + 1, 0, currentKeyValue);
|
||||
|
||||
// Reconstruct the object with the new order
|
||||
const result = {};
|
||||
keys.forEach((key, index) => {
|
||||
result[key] = values[index];
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
readMiniSrvConfig(user_config = true, notices = true, reload_notice = false) {
|
||||
const log = (msg) => {
|
||||
if (notices || reload_notice) console.log(msg);
|
||||
@@ -608,7 +557,7 @@ class WTVShared {
|
||||
var new_user_config = {};
|
||||
Object.assign(new_user_config, minisrv_user_config, config);
|
||||
if (this.minisrv_config.config.debug_flags.debug) console.log(" * Writing new user configuration...");
|
||||
this.fs.writeFileSync(this.getAbsolutePath("user_config.json", this.parentDirectory), JSON.stringify(new_user_config, null, "\t"));
|
||||
this.fs.writeFileSync(this.getAbsolutePath("user_config.json", this.appdir), JSON.stringify(new_user_config, null, "\t"));
|
||||
return true;
|
||||
}
|
||||
catch (e) {
|
||||
@@ -827,6 +776,7 @@ class WTVShared {
|
||||
}
|
||||
});
|
||||
}
|
||||
delete newobj.raw_headers;
|
||||
|
||||
return newobj;
|
||||
}
|
||||
@@ -1160,6 +1110,67 @@ class WTVShared {
|
||||
getTemplate(service_name, path, path_only = false) {
|
||||
return this.getServiceDep(service_name + this.path.sep + path, path_only, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds a key in an object
|
||||
* @param {string} key The key to find
|
||||
* @param {object} obj The object to search
|
||||
* @param {boolean} case_insensitive Search case insensitive
|
||||
* @returns
|
||||
*/
|
||||
findObjectKeyIndex(key, obj, case_insensitive = false) {
|
||||
const keys = Object.keys(obj);
|
||||
if (case_insensitive) {
|
||||
key = key.toLowerCase();
|
||||
return keys.findIndex(k => k.toLowerCase() === key);
|
||||
}
|
||||
return keys.indexOf(key);
|
||||
}
|
||||
/**
|
||||
* Moves an object to the desired location in the object (reorder)
|
||||
* @param {string|int} currentKey Name of the object Key to move or the index to move
|
||||
* @param {string|int} destKey Name of the object key to place currentKey after or the index to place it at
|
||||
* @param {object} obj The object to work on
|
||||
* @param {boolean} case_insensitive Search case insensitive
|
||||
* @returns {object} The modified object
|
||||
*/
|
||||
moveObjectKey(currentKey, destKey, obj, case_insensitive = false) {
|
||||
let keys = Object.keys(obj);
|
||||
let values = Object.values(obj);
|
||||
|
||||
const currentIndex = typeof currentKey === 'string' ? this.findObjectKeyIndex(currentKey, obj, case_insensitive) : parseInt(currentKey);
|
||||
if (currentIndex === -1) return obj;
|
||||
|
||||
var destIndex = typeof destKey === 'string' ? this.findObjectKeyIndex(destKey, obj, case_insensitive) : parseInt(destKey);
|
||||
|
||||
// Bump by one if the destKey is a string (put after the key)
|
||||
if (typeof destKey === 'string' && destIndex !== -1) destIndex++;
|
||||
|
||||
// If destKey is not found or not defined, don't move the element
|
||||
if (isNaN(destIndex)) return obj;
|
||||
|
||||
// Remove the current element from keys and values
|
||||
const [currentKeyValue] = values.splice(currentIndex, 1);
|
||||
const [currentKeyName] = keys.splice(currentIndex, 1);
|
||||
|
||||
// Insert the current element after the destKey position
|
||||
keys.splice(destIndex, 0, currentKeyName);
|
||||
values.splice(destIndex, 0, currentKeyValue);
|
||||
|
||||
// Reconstruct the object with the new order
|
||||
const result = {};
|
||||
keys.forEach((key, index) => {
|
||||
result[key] = values[index];
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
getCaseInsensitiveKey(key, obj) {
|
||||
const foundKey = Object.keys(obj).find(k => k.toLowerCase() === key.toLowerCase());
|
||||
return foundKey || null;
|
||||
}
|
||||
}
|
||||
|
||||
class clientShowAlert {
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
"UserServiceDeps",
|
||||
"includes/ServiceDeps"
|
||||
],
|
||||
"cgi_enabled": false, // Disable CGI by default
|
||||
"php_enabled": false, // Disable PHP by default
|
||||
"SessionStore": "SessionStore", // Where we store account (session) data. Best left unchanged.
|
||||
"SharedROMCache": "SharedROMCache", // Shared ROMCache (wtv-service:/ROMCache/, where wtv-service is any configured service). Found under service vault. Best left unchanged.
|
||||
"enable_shared_romcache": true, // Disabling this will cause a lot of problems without manual intervention. Best left unchanged.
|
||||
|
||||
Reference in New Issue
Block a user