const minisrv_service_file = true; let BoxId = request_headers.query.BoxId; if (Array.isArray(BoxId)) BoxId = BoxId[0]; let clientIp = socket.remoteAddress; let banned = false; let sessionId = null; // Use the shared MSNTV2 helper injected by WTV-MSNTV2 VM context. if (BoxId) { if (!BoxId || BoxId.length != 20 || !/^\d+$/.test(BoxId)) { console.warn("Invalid BoxId format "+BoxId+" from "+clientIp); banned = true; } else { sessionId = encodeSessionID(BoxId); } } else if (request_headers.cookie && request_headers.cookie.SessionID) { BoxID = decodeSessionID(request_headers.cookie.SessionID); sessionId = request_headers.cookie.SessionID; } else { console.warn("No BoxId provided by client "+clientIp); banned = true; } if (!sessionId && !banned) { banned = true; } if (!session_data && BoxId) { console.log("Missing session_data for BoxId %s", BoxId); } let registered = false; let username = ''; if (session_data) { registered = session_data.isRegistered(); if (registered) { username = session_data.getSessionData("subscriber_username") || ''; } } // Current UTC time const now = new Date(); // Time data object const timeData = { hh: now.getUTCHours(), mm: now.getUTCMinutes(), ss: now.getUTCSeconds(), mo: now.getUTCMonth() + 1, // JS months are 0-based dd: now.getUTCDate(), yyyy: now.getUTCFullYear() }; // Timezone mapping (C# tuple → JS array or object) const timezoneMap = { "UTC": { standardName: "UTC", standardOffset: 0, daylightName: "UTC", daylightOffset: 0 } }; // Destructure like the C# tuple deconstruction const { standardName, standardOffset, daylightName, daylightOffset } = timezoneMap["UTC"]; // Set session cookie on the client if (sessionId) { setCookie('SessionID', sessionId, { path: '/' }); } headers = `200 OK Content-type: text/html` data = `