From 26dfd0de4b4c0b0fadfa5e13867eb79ec089c83c Mon Sep 17 00:00:00 2001
From: zefie
Date: Wed, 13 Aug 2025 13:23:45 -0400
Subject: [PATCH] bring back an old goodie
---
zefie_wtvp_minisrv/client_sim.js | 2 +-
.../wtv-disk/content/DownloadScreen.tmpl.js | 42 ++++++++-----
.../wtv-disk/content/Downloads.tmpl.js | 11 +++-
.../ServiceVault/wtv-disk/delete-group.js | 62 +++++++++++++++++++
.../ServiceVault/wtv-disk/get-group-data.js | 20 ++++++
5 files changed, 118 insertions(+), 19 deletions(-)
create mode 100644 zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/delete-group.js
create mode 100644 zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/get-group-data.js
diff --git a/zefie_wtvp_minisrv/client_sim.js b/zefie_wtvp_minisrv/client_sim.js
index b899da79..7932b5bd 100644
--- a/zefie_wtvp_minisrv/client_sim.js
+++ b/zefie_wtvp_minisrv/client_sim.js
@@ -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
diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/DownloadScreen.tmpl.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/DownloadScreen.tmpl.js
index 85b9ba92..76c721c6 100644
--- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/DownloadScreen.tmpl.js
+++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/DownloadScreen.tmpl.js
@@ -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 = `
Retrieving Files
diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/Downloads.tmpl.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/Downloads.tmpl.js
index 5d444a56..ba7c7a94 100644
--- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/Downloads.tmpl.js
+++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/Downloads.tmpl.js
@@ -40,7 +40,14 @@ V.90 Modem Firmware (Use common 56k technology)
All Music (can take a very long time)
-Karaoke
-
+Karaoke
+
+
+
Tools
+WARNING: Use the following with caution
+
+
`;
\ No newline at end of file
diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/delete-group.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/delete-group.js
new file mode 100644
index 00000000..3de1477a
--- /dev/null
+++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/delete-group.js
@@ -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 = `
+
+
+Delete a DiskMap Group
+
+
+
+
+
+| Group | Path | State | Last Checkup |
+`;
+ if (!client_group_data) {
+ data += "No groups found.";
+ } 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 += `| ${group} | ${path} | ${state} | ${date} |
\n`;
+ })
+ }
+ data += `
+
+
+
+Refresh Box Group Data - Go to Downloads
+
+
+`
+ }
+}
\ No newline at end of file
diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/get-group-data.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/get-group-data.js
new file mode 100644
index 00000000..39e9a33f
--- /dev/null
+++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/get-group-data.js
@@ -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) : "");
+}
\ No newline at end of file