bring back an old goodie
This commit is contained in:
@@ -63,7 +63,7 @@ class WebTVClientSimulator {
|
||||
this.previousUrl = null; // Store previous URL for Referer header
|
||||
this.debug = debug;
|
||||
this.defaultBox = "plus";
|
||||
this.connectSessionId = crypto.randomBytes(4).toString('hex');;
|
||||
this.connectSessionId = crypto.randomBytes(4).toString('hex');
|
||||
this.username = username;
|
||||
|
||||
// Load minisrv config to get the initial shared key
|
||||
|
||||
@@ -3,21 +3,25 @@ const minisrv_service_file = true;
|
||||
|
||||
headers = `200 OK
|
||||
Content-Type: text/html
|
||||
wtv-expire: wtv-disk:/content/DownloadScreen.tmpl`
|
||||
wtv-expire-all: wtv-disk:`
|
||||
const content_dir = "content/"
|
||||
const diskmap_dir = content_dir + "diskmaps/";
|
||||
const diskmap = request_headers.query[wtvshared.getCaseInsensitiveKey("DiskMap", request_headers.query)];
|
||||
let diskmap_json_file = null;
|
||||
Object.keys(service_vaults).forEach(function (g) {
|
||||
if (diskmap_json_file != null) return;
|
||||
diskmap_json_file = service_vaults[g] + "/" + service_name + "/" + diskmap_dir + diskmap + ".json";
|
||||
if (!fs.existsSync(diskmap_json_file)) diskmap_json_file = null;
|
||||
});
|
||||
let diskmap_data = JSON.parse(fs.readFileSync(diskmap_json_file).toString());
|
||||
if (!diskmap_data[request_headers.query.group]) {
|
||||
throw ("Invalid diskmap data (group does not match)");
|
||||
let diskmap_data = {};
|
||||
|
||||
if (!request_headers.query.url) {
|
||||
Object.keys(service_vaults).forEach(function (g) {
|
||||
if (diskmap_json_file != null) return;
|
||||
diskmap_json_file = service_vaults[g] + "/" + service_name + "/" + diskmap_dir + diskmap + ".json";
|
||||
if (!fs.existsSync(diskmap_json_file)) diskmap_json_file = null;
|
||||
});
|
||||
diskmap_data = JSON.parse(fs.readFileSync(diskmap_json_file).toString());
|
||||
if (!diskmap_data[request_headers.query.group]) {
|
||||
throw ("Invalid diskmap data (group does not match)");
|
||||
}
|
||||
diskmap_data = diskmap_data[request_headers.query.group];
|
||||
}
|
||||
diskmap_data = diskmap_data[request_headers.query.group];
|
||||
const message = request_headers.query.message || diskmap_data.message || "Retrieving files...";
|
||||
const main_message = request_headers.query.main_message || diskmap_data.main_message || "Your receiver is downloading files.";
|
||||
let success_url = request_headers.query.success_url || diskmap_data.success_url || null;
|
||||
@@ -38,18 +42,24 @@ if (fail_url === null) fail_url = new clientShowAlert({
|
||||
'buttonaction1': "client:goback",
|
||||
'noback': true,
|
||||
}).getURL();
|
||||
let url;
|
||||
|
||||
if (request_headers.query.url) {
|
||||
url = encodeURIComponent(request_headers.query.url);
|
||||
} else {
|
||||
url = `wtv-disk:/sync`;
|
||||
if (request_headers.query.diskmap) url += `%3fdiskmap%3d${request_headers.query.diskmap}`;
|
||||
if (request_headers.query.force) url += `%26force%3dtrue`
|
||||
if (!request_headers.query.group) url += `&root=file://Disk/Browser/`;
|
||||
else url += `%26group%3d${request_headers.query.group}`;
|
||||
}
|
||||
|
||||
data = `<html>
|
||||
<head>
|
||||
|
||||
<meta
|
||||
http-equiv=refresh
|
||||
content="0;url=client:Fetch?source=wtv-disk:/sync`;
|
||||
if (request_headers.query.diskmap) data += `%3fdiskmap%3d${request_headers.query.diskmap}`;
|
||||
if (request_headers.query.force) data += `%26force%3dtrue`
|
||||
if (!request_headers.query.group) data += `&root=file://Disk/Browser/`;
|
||||
else data += `&group=${request_headers.query.group}`;;
|
||||
data += `&message=Retrieving Files..."
|
||||
content="0;url=client:Fetch?source=${url}&message=Retrieving Files..."
|
||||
>
|
||||
<display downloadsuccess="${success_url}" downloadfail="${fail_url}">
|
||||
<title>Retrieving Files</title>
|
||||
|
||||
@@ -40,7 +40,14 @@ V.90 Modem Firmware (Use common 56k technology)
|
||||
<i>All Music</i> (can take a very long time)</a>
|
||||
|
||||
</li><li><a href="wtv-disk:/content/DownloadScreen.tmpl?diskmap=Karaoke&group=Karaoke">
|
||||
<i>Karaoke</i></a>
|
||||
|
||||
<i>Karaoke</i></a></li>
|
||||
</ul>
|
||||
<p>
|
||||
<h2>Tools</h2>
|
||||
<i><b>WARNING: Use the following with caution</b></i>
|
||||
</p>
|
||||
<ul><li>
|
||||
<a href="wtv-disk:/get-group-data">Delete Groups</a>
|
||||
</li></ul>
|
||||
|
||||
</body></html>`;
|
||||
@@ -0,0 +1,62 @@
|
||||
const minisrv_service_file = true;
|
||||
|
||||
if (request_headers.query.group) {
|
||||
if (request_headers['wtv-request-type'] === "download") {
|
||||
const wtvdl = new WTVDisk(minisrv_config, service_name);
|
||||
headers = "200 OK\nContent-Type: " + wtvdl.content_type;
|
||||
wtvdl.deleteGroup(request_headers.query.group);
|
||||
wtvdl.deleteGroupUpdate(request_headers.query.group, request_headers.query.path || null);
|
||||
data = wtvdl.getDownloadList();
|
||||
const client_group_data = wtvdl.getGroupDataFromClientPost(request_headers.post_data.toString(CryptoJS.enc.Latin1));
|
||||
session_data.setTicketData("client_disk_group_data", client_group_data);
|
||||
if (minisrv_config.config.show_diskmap) console.log("Client POST Data:", client_group_data)
|
||||
if (minisrv_config.config.show_diskmap) console.log("DiskMap Data:", data);
|
||||
} else {
|
||||
const query = request_headers.query;
|
||||
query['url'] = 'wtv-disk:/delete-group';
|
||||
const queryString = Object.keys(query)
|
||||
.map(key => encodeURIComponent(key) + '=' + encodeURIComponent(query[key]))
|
||||
.join('&');
|
||||
headers = "302 Found\nLocation: wtv-disk:/content/DownloadScreen.tmpl" + (queryString ? ("?" + queryString) : "");
|
||||
}
|
||||
} else {
|
||||
const client_group_data = session_data.getTicketData("client_disk_group_data");
|
||||
if (!client_group_data) {
|
||||
headers = "302 Found\nLocation: wtv-disk:/get-group-data";
|
||||
} else {
|
||||
session_data.deleteTicketData("client_disk_group_data");
|
||||
headers = "200 OK\nContent-Type: text/html\nwtv-expire-all: wtv-disk:/delete-group";
|
||||
data = `
|
||||
<html>
|
||||
<head>
|
||||
<title>Delete a DiskMap Group</title>
|
||||
</head>
|
||||
<body bgcolor="#191919" text="#44bb55" link="#44bb55" vlink="#44bb55" alink="#44bb55">
|
||||
<form action="delete-group">
|
||||
<input type="text" usestyle name="group">
|
||||
<input type="submit" usestyle value="Delete">
|
||||
</form>
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td>Group</td><td>Path</td><td>State</td><td>Last Checkup</td></tr>
|
||||
`;
|
||||
if (!client_group_data) {
|
||||
data += "<li>No groups found.</li>";
|
||||
} else {
|
||||
Object.entries(client_group_data).forEach(([group, _]) => {
|
||||
const path = client_group_data[group].path;
|
||||
const state = client_group_data[group].state;
|
||||
const date = client_group_data[group]['last-checkup-time'];
|
||||
data += `<tr><td><a href="wtv-disk:/content/DownloadScreen.tmpl?url=${encodeURIComponent('wtv-disk:/delete-group?path='+path+'&group='+group)}">${group}</a></td><td>${path}</td><td>${state}</td><td>${date}</td></tr>\n`;
|
||||
})
|
||||
}
|
||||
data += `
|
||||
</table>
|
||||
</p>
|
||||
<br>
|
||||
<a href="/get-group-data">Refresh Box Group Data</a> - <a href="/content/Downloads.tmpl">Go to Downloads</a>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
const minisrv_service_file = true;
|
||||
|
||||
if (request_headers['wtv-request-type'] === "download") {
|
||||
const wtvdl = new WTVDisk(minisrv_config, service_name);
|
||||
headers = "200 OK\nContent-Type: " + wtvdl.content_type;
|
||||
wtvdl.execute('client:donothing');
|
||||
data = wtvdl.getDownloadList();
|
||||
const client_group_data = wtvdl.getGroupDataFromClientPost(request_headers.post_data.toString(CryptoJS.enc.Latin1));
|
||||
session_data.setTicketData("client_disk_group_data", client_group_data);
|
||||
if (minisrv_config.config.show_diskmap) console.log("Client POST Data:", client_group_data);
|
||||
if (minisrv_config.config.show_diskmap) console.log("DiskMap Data:", data);
|
||||
} else {
|
||||
const query = request_headers.query;
|
||||
query['url'] = 'wtv-disk:/get-group-data';
|
||||
query['success_url'] = 'wtv-disk:/delete-group';
|
||||
const queryString = Object.keys(query)
|
||||
.map(key => encodeURIComponent(key) + '=' + encodeURIComponent(query[key]))
|
||||
.join('&');
|
||||
headers = "302 Found\nLocation: wtv-disk:/content/DownloadScreen.tmpl" + (queryString ? ("?" + queryString) : "");
|
||||
}
|
||||
Reference in New Issue
Block a user