implement internal shared ROMCache
- make most ROMCache URLS relative - create wtvshared.htmlEntitize function - update wtv-mail:/readmail to use wtvshared.htmlEntitize
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 875 B |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 875 B |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 84 B |
@@ -41,15 +41,14 @@ Choose your name
|
||||
<td absheight=8>
|
||||
</table>
|
||||
</sidebar>
|
||||
<body background="wtv-content:/ROMCache/NameStrip.gif"
|
||||
<body background="ROMCache/NameStrip.gif"
|
||||
novtilebg
|
||||
nohtilebg
|
||||
bgcolor=191919
|
||||
text="AA9B4A" link=189cd6 vlink=189cd6 hspace=0 fontsize="large">
|
||||
<LINK href="wtv-content:/ROMCache/TopBackground_Classic.jpg" rel=next>
|
||||
<LINK href="wtv-content:/ROMCache/Community.gif" rel=next>
|
||||
<LINK href="wtv-content:/ROMCache/UtilityBullet.gif" rel=next>
|
||||
<LINK href="wtv-content:/ROMCache/BackgroundWebTVToday_a.swf" rel=next>
|
||||
<LINK href="ROMCache/TopBackground_Classic.jpg" rel=next>
|
||||
<LINK href="ROMCache/Community.gif" rel=next>
|
||||
<LINK href="ROMCache/UtilityBullet.gif" rel=next>
|
||||
<form action=/ValidateLogin enctype="x-www-form-encoded" method=post>
|
||||
<input type="hidden" NAME="target-url" VALUE="">
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
|
||||
@@ -17,7 +17,7 @@ ${minisrv_config.config.service_name} Service Privacy Statement
|
||||
<tr>
|
||||
<td colspan=3 abswidth=104 absheight=4>
|
||||
<td rowspan=99 width=6 absheight=420 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
|
||||
<img src="ROMCache/Shadow.gif" width=6 height=420>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=92 absheight=76>
|
||||
@@ -30,10 +30,10 @@ ${minisrv_config.config.service_name} Service Privacy Statement
|
||||
<tr><td absheight=5 colspan=3>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="5a4521">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr><td abswidth=104 absheight=1 valign=top align=left>
|
||||
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="c0954a">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=1 height=1>
|
||||
</table>
|
||||
<tr><td absheight=100>
|
||||
<tr><td absheight=244 align=right colspan=3>
|
||||
|
||||
@@ -53,7 +53,7 @@ xnocancel>
|
||||
<HTML>
|
||||
<head>
|
||||
<title>
|
||||
${html_entities.encode((message.subject) ? message.subject : '(No subject)')}
|
||||
${(message.subject) ? wtvshared.htmlEntitize(message.subject) : '(No subject)'}
|
||||
</title>
|
||||
</head>
|
||||
<body
|
||||
@@ -236,9 +236,9 @@ From:
|
||||
<td width=10>
|
||||
<td>`;
|
||||
if (message.from_name != message.from_addr) {
|
||||
data += `${html_entities.encode(message.from_addr)} <a href="client:showalert?sound=none&message=To%20add%20%3Cblackface%3E${escape(escape(message.from_name))}%3C%2Fblackface%3E%20to%20your%20Address%20book,%20choose%20%3Cb%3EAdd%3C%2Fb%3E.&buttonlabel2=Cancel&buttonaction2=client:donothing&buttonlabel1=Add&buttonaction1=wtv-mail:/addressbook%3Faction%3Deditfromheader%26noresponse%3Dtrue%26nickname%3D${escape(escape(message.from_name))}%26address%3D${escape(escape(message.from_addr))}%26new_address%3Dtrue">(${html_entities.encode(message.from_name)})</a>`;
|
||||
data += `${wtvshared.htmlEntitize(message.from_addr)} <a href="client:showalert?sound=none&message=To%20add%20%3Cblackface%3E${escape(escape(message.from_name))}%3C%2Fblackface%3E%20to%20your%20Address%20book,%20choose%20%3Cb%3EAdd%3C%2Fb%3E.&buttonlabel2=Cancel&buttonaction2=client:donothing&buttonlabel1=Add&buttonaction1=wtv-mail:/addressbook%3Faction%3Deditfromheader%26noresponse%3Dtrue%26nickname%3D${escape(escape(message.from_name))}%26address%3D${escape(escape(message.from_addr))}%26new_address%3Dtrue">(${wtvshared.htmlEntitize(message.from_name)})</a>`;
|
||||
} else {
|
||||
data += `${html_entities.encode(message.from_addr)}`;
|
||||
data += `${wtvshared.htmlEntitize(message.from_addr)}`;
|
||||
}
|
||||
|
||||
data += `<tr>
|
||||
@@ -252,7 +252,7 @@ ${strftime("%a, %b %e, %Y, %I:%M %P", new Date(message.date * 1000))} (UTC)
|
||||
To:
|
||||
<td>
|
||||
<td>
|
||||
${html_entities.encode(message.to_addr)} ${(html_entities.encode(message.to_name)) ? '(' + html_entities.encode(message.to_name) + ')' : ''}
|
||||
${wtvshared.htmlEntitize(message.to_addr)} ${(message.to_name) ? '(' + wtvshared.htmlEntitize(message.to_name) + ')' : ''}
|
||||
<tr>
|
||||
<td nowrap valign=top>
|
||||
Subject: <td>
|
||||
@@ -260,7 +260,7 @@ Subject: <td>
|
||||
|
||||
if (typeof message.subject == "object") message.subject = new Buffer.from(message.subject).toString('latin1');
|
||||
data += `
|
||||
${html_entities.encode((message.subject) ? message.subject : '(No subject)')}
|
||||
${(message.subject) ? wtvshared.htmlEntitize(message.subject) : '(No subject)'}
|
||||
<tr>
|
||||
<td height=10>
|
||||
<spacer type=vertical size=10>
|
||||
@@ -270,22 +270,22 @@ ${html_entities.encode((message.subject) ? message.subject : '(No subject)')}
|
||||
<tr>
|
||||
<td width=425>
|
||||
<p>`;
|
||||
if (typeof message.body == "object") {
|
||||
if (typeof message.body === "object" && message.body) {
|
||||
message.body = wtvshared.decodeBufferText(message.body);
|
||||
}
|
||||
data += `
|
||||
${html_entities.encode(message.body).replace(/\n/gi, "<br>").replace(/\r/gi, "").replace(/'/gi, "'")}
|
||||
${wtvshared.htmlEntitize(message.body, true)}
|
||||
<br>
|
||||
<br>`;
|
||||
if (message.signature) {
|
||||
data += ssid_sessions[socket.ssid].mailstore.sanitizeSignature(message.signature);
|
||||
}
|
||||
data += `<p>
|
||||
data += `<p>
|
||||
`;
|
||||
if (message.attachments) {
|
||||
message.attachments.forEach((v, k) => {
|
||||
if (v) {
|
||||
console.log("*****************",v['Content-Type']);
|
||||
console.log("*****************", v['Content-Type']);
|
||||
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>`;
|
||||
@@ -293,7 +293,7 @@ data += `<p>
|
||||
case "audio/wav":
|
||||
data += `<table href="wtv-mail:/get-attachment?message_id=${messageid}&attachment_id=${k}&wtv-title=Voice%20Mail" width=386 cellspacing=0 cellpadding=0>
|
||||
<td align=left valign=middle>
|
||||
<img src="wtv-mail:/ROMCache/FileSound.gif" align=absmiddle> Recording
|
||||
<img src="ROMCache/FileSound.gif" align=absmiddle> Recording
|
||||
<td align=right valign=middle>
|
||||
</table><br><br>
|
||||
`;
|
||||
@@ -302,7 +302,7 @@ data += `<p>
|
||||
}
|
||||
});
|
||||
}
|
||||
data += `<p>
|
||||
data += `<p>
|
||||
<p>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
@@ -71,10 +71,10 @@ Content-Type: audio/wav`;
|
||||
'noback': true,
|
||||
}).getURL();
|
||||
|
||||
if (request_headers.query.sendoff == "Send" || request_headers.query.saveoff || request_headers.query.get_snap || request_headers.query.get_gab) {
|
||||
if ((typeof request_headers.query.sendoff !== 'undefined' && request_headers.query.sendoff != false) || request_headers.query.saveoff || request_headers.query.get_snap || request_headers.query.get_gab) {
|
||||
var from_addr = address;
|
||||
var signature = ssid_sessions[socket.ssid].getSessionData("subscriber_signature") || null;
|
||||
if (request_headers.query.sendoff == "Send") {
|
||||
if (typeof request_headers.query.sendoff !== 'undefined' && request_headers.query.sendoff != false) {
|
||||
var attachments = [];
|
||||
|
||||
|
||||
@@ -459,30 +459,30 @@ USESTYLE NOARGS>
|
||||
if ((request_headers.query.snapping && request_headers.query.snapping !== 'false') || mail_draft_attachments.message_snapshot_data) {
|
||||
data += `<tr>
|
||||
<td absheight="10">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="10">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="10">
|
||||
</td></tr></tbody></table>
|
||||
<table cellspacing="0" cellpadding="0" bgcolor="#1F2033" background="">
|
||||
<tbody><tr>
|
||||
<td rowspan="100" abswidth="10" bgcolor="191919">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="10" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="10" height="1">
|
||||
</td><td colspan="9" abswidth="422" valign="bottom">
|
||||
<img src="wtv-mail:/ROMCache/PaperTopFlat.gif" noprint="" width="422" height="6">
|
||||
<img src="ROMCache/PaperTopFlat.gif" noprint="" width="422" height="6">
|
||||
</td></tr><tr>
|
||||
<td rowspan="100" abswidth="2" absheight="0" bgcolor="313131">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td rowspan="100" abswidth="14" absheight="0">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td colspan="2" abswidth="386">
|
||||
</td><td rowspan="100" abswidth="14" absheight="0">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td rowspan="100" abswidth="3" absheight="0" bgcolor="0b0b0b">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td rowspan="100" abswidth="1" absheight="0" bgcolor="0f0f0f">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td rowspan="100" abswidth="1" absheight="0" bgcolor="131313">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td rowspan="100" abswidth="1" absheight="0" bgcolor="171717">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td></tr><tr>
|
||||
<td colspan="2" absheight="15">`;
|
||||
if (!mail_draft_attachments.message_snapshot_data) {
|
||||
@@ -502,51 +502,51 @@ USESTYLE NOARGS>
|
||||
<tbody><tr><td valign="middle">
|
||||
</td><td valign="middle" align="right">
|
||||
<a href="javascript:ErasingMedia('snapping')">
|
||||
Detach <img src="wtv-mail:/ROMCache/RemoveButton.gif" width="25" height="25" align="absmiddle"></a>
|
||||
Detach <img src="ROMCache/RemoveButton.gif" width="25" height="25" align="absmiddle"></a>
|
||||
</td></tr></tbody></table>
|
||||
</td></tr><tr>
|
||||
<td colspan="2" absheight="8">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="8">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="8">
|
||||
</td></tr></tbody></table>
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody><tr>
|
||||
<td rowspan="100" abswidth="10">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="10" height="2">
|
||||
<img src="ROMCache/Spacer.gif" width="10" height="2">
|
||||
</td><td abswidth="422">
|
||||
<img src="wtv-mail:/ROMCache/PaperBase.gif" noprint="" width="422" height="6">
|
||||
<img src="ROMCache/PaperBase.gif" noprint="" width="422" height="6">
|
||||
</td></tr><tr>
|
||||
<td absheight="6">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="6">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="6">
|
||||
</td></tr>`;
|
||||
}
|
||||
|
||||
if ((request_headers.query.gabbing && request_headers.query.gabbing !== 'false') || mail_draft_attachments.message_voicemail_data) {
|
||||
data += `<tr>
|
||||
<td absheight="10">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="10">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="10">
|
||||
</td></tr></tbody></table>
|
||||
<table cellspacing="0" cellpadding="0" bgcolor="#1F2033" background="">
|
||||
<tbody><tr>
|
||||
<td rowspan="100" abswidth="10" bgcolor="191919">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="10" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="10" height="1">
|
||||
</td><td colspan="9" abswidth="422" valign="bottom">
|
||||
<img src="wtv-mail:/ROMCache/PaperTopFlat.gif" noprint="" width="422" height="6">
|
||||
<img src="ROMCache/PaperTopFlat.gif" noprint="" width="422" height="6">
|
||||
</td></tr><tr>
|
||||
<td rowspan="100" abswidth="2" absheight="0" bgcolor="313131">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td rowspan="100" abswidth="14" absheight="0">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td colspan="2" abswidth="386">
|
||||
</td><td rowspan="100" abswidth="14" absheight="0">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td rowspan="100" abswidth="3" absheight="0" bgcolor="0b0b0b">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td rowspan="100" abswidth="1" absheight="0" bgcolor="0f0f0f">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td rowspan="100" abswidth="1" absheight="0" bgcolor="131313">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td><td rowspan="100" abswidth="1" absheight="0" bgcolor="171717">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="1">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="1">
|
||||
</td></tr><tr>
|
||||
<td colspan="2" absheight="15">
|
||||
<input type=file device=audio name=message_voicemail_data
|
||||
@@ -556,23 +556,23 @@ ${(!mail_draft_attachments.message_voicemail_data) ? '' : '<input type=hidden na
|
||||
<td colspan="2" align="center">
|
||||
<table width=386 cellspacing=0 cellpadding=0>
|
||||
<td align=left valign=middle>
|
||||
<a href="${(mail_draft_attachments.message_voicemail_data) ? 'wtv-mail:/sendmail?get_gab=true&wtv-title=Voice%20Mail' : 'cache:voicemail.wav'}" id=focus><img src="wtv-mail:/ROMCache/FileSound.gif" align=absmiddle></a> Recording
|
||||
<a href="${(mail_draft_attachments.message_voicemail_data) ? 'wtv-mail:/sendmail?get_gab=true&wtv-title=Voice%20Mail' : 'cache:voicemail.wav'}" id=focus><img src="ROMCache/FileSound.gif" align=absmiddle></a> Recording
|
||||
<td align=right valign=middle>
|
||||
<a href="javascript:ErasingMedia('gabbing')">
|
||||
Detach <img src="wtv-mail:/ROMCache/RemoveButton.gif" align=absmiddle height=25 width=25></a>
|
||||
Detach <img src="ROMCache/RemoveButton.gif" align=absmiddle height=25 width=25></a>
|
||||
</table><tr>
|
||||
<td colspan="2" absheight="8">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="8">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="8">
|
||||
</td></tr></tbody></table>
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody><tr>
|
||||
<td rowspan="100" abswidth="10">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="10" height="2">
|
||||
<img src="ROMCache/Spacer.gif" width="10" height="2">
|
||||
</td><td abswidth="422">
|
||||
<img src="wtv-mail:/ROMCache/PaperBase.gif" noprint="" width="422" height="6">
|
||||
<img src="ROMCache/PaperBase.gif" noprint="" width="422" height="6">
|
||||
</td></tr><tr>
|
||||
<td absheight="6">
|
||||
<img src="wtv-star:/ROMCache/Spacer.gif" width="1" height="6">
|
||||
<img src="ROMCache/Spacer.gif" width="1" height="6">
|
||||
</td></tr>`;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ Users setup
|
||||
<tr>
|
||||
<td colspan=3 abswidth=104 absheight=4>
|
||||
<td rowspan=99 width=6 absheight=420 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
|
||||
<img src="ROMCache/Shadow.gif" width=6 height=420>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=92 absheight=76>
|
||||
@@ -35,10 +35,10 @@ Users setup
|
||||
<tr><td absheight=5 colspan=3>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="1C1E28">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr><td abswidth=104 absheight=1 valign=top align=left>
|
||||
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="4D5573">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=1 height=1>
|
||||
</table>
|
||||
<tr><td absheight=37>
|
||||
<tr><td absheight=263 align=right colspan=3>
|
||||
@@ -96,14 +96,14 @@ Subscriber:
|
||||
<tr>
|
||||
<TD>
|
||||
<td colspan=4 height=2 valign=middle align=center bgcolor="2B2B2B">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=436 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=436 height=1>
|
||||
<tr>
|
||||
<TD>
|
||||
<td colspan=4 height=1 valign=top align=left>
|
||||
<tr>
|
||||
<TD>
|
||||
<td colspan=4 height=2 valign=top align=left bgcolor="0D0D0D">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=436 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=436 height=1>
|
||||
<TR>
|
||||
<TD>
|
||||
<TD COLSPAN=4 HEIGHT=4 VALIGN=top ALIGN=left>
|
||||
@@ -114,11 +114,11 @@ Subscriber:
|
||||
<INPUT action="/remove-users?user-count=x"
|
||||
name="RemoveUser" value="Remove User" WIDTH=140 ${(num_accounts >= 1) ? 'USESTYLE' : 'disabled="disabled" text=gray' }
|
||||
TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" NAME="Button1" WIDTH=103>
|
||||
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=4 HEIGHT=1>
|
||||
<IMG SRC="ROMCache/Spacer.gif" WIDTH=4 HEIGHT=1>
|
||||
<INPUT action="/add-user?user_count=${num_accounts}"
|
||||
name="AddUser" value="Add User" WIDTH=120 ${(num_accounts >= minisrv_config.config.user_accounts.max_users_per_account) ? 'disabled="disabled" text=gray' : 'USESTYLE'}
|
||||
TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" NAME="Button2" WIDTH=103>
|
||||
<IMG SRC="wtv-home:/ROMCache/Spacer.gif" WIDTH=4 HEIGHT=1>
|
||||
<IMG SRC="ROMCache/Spacer.gif" WIDTH=4 HEIGHT=1>
|
||||
<INPUT action="client:goback"
|
||||
name="Done"
|
||||
value="Done"
|
||||
|
||||
@@ -36,7 +36,7 @@ noscroll>
|
||||
<tr>
|
||||
<td colspan=3 abswidth=104 absheight=4>
|
||||
<td rowspan=99 width=6 absheight=420 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
|
||||
<img src="ROMCache/Shadow.gif" width=6 height=420>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=92 absheight=76>
|
||||
@@ -49,10 +49,10 @@ noscroll>
|
||||
<tr><td absheight=5 colspan=3>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="1C1E28">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr><td abswidth=104 absheight=1 valign=top align=left>
|
||||
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="4D5573">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=1 height=1>
|
||||
</table>
|
||||
<tr><td absheight=37>
|
||||
<tr><td absheight=263 align=right colspan=3>
|
||||
@@ -123,13 +123,13 @@ MAXLENGTH="${minisrv_config.config.passwords.max_length}">
|
||||
<tr>
|
||||
<td>
|
||||
<td colspan=2 absheight=2 bgcolor="2B2B2B">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=426 height=1>
|
||||
<tr>
|
||||
<td absheight=1>
|
||||
<tr>
|
||||
<td>
|
||||
<td colspan=2 absheight=2 bgcolor="0D0D0D">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=426 height=1>
|
||||
<tr>
|
||||
<td absheight=4>
|
||||
</table>
|
||||
|
||||
@@ -40,7 +40,7 @@ noscroll>
|
||||
<tr>
|
||||
<td colspan=3 abswidth=104 absheight=4>
|
||||
<td rowspan=99 width=6 absheight=420 valign=top align=left>
|
||||
<img src="wtv-home:/ROMCache/Shadow.gif" width=6 height=420>
|
||||
<img src="ROMCache/Shadow.gif" width=6 height=420>
|
||||
<tr>
|
||||
<td abswidth=6>
|
||||
<td abswidth=92 absheight=76>
|
||||
@@ -53,10 +53,10 @@ noscroll>
|
||||
<tr><td absheight=5 colspan=3>
|
||||
<table cellspacing=0 cellpadding=0>
|
||||
<tr><td abswidth=104 absheight=2 valign=middle align=center bgcolor="1C1E28">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=1 height=1>
|
||||
<tr><td abswidth=104 absheight=1 valign=top align=left>
|
||||
<tr><td abswidth=104 absheight=2 valign=top align=left bgcolor="4D5573">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=1 height=1>
|
||||
</table>
|
||||
<tr><td absheight=37>
|
||||
<tr><td absheight=263 align=right colspan=3>
|
||||
@@ -154,13 +154,13 @@ user_password2=${request_headers.query.user_password2}">`;
|
||||
<tr>
|
||||
<td>
|
||||
<td colspan=2 absheight=2 bgcolor="2B2B2B">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=426 height=1>
|
||||
<tr>
|
||||
<td absheight=1>
|
||||
<tr>
|
||||
<td>
|
||||
<td colspan=2 absheight=2 bgcolor="0D0D0D">
|
||||
<img src="wtv-home:/ROMCache/Spacer.gif" width=426 height=1>
|
||||
<img src="ROMCache/Spacer.gif" width=426 height=1>
|
||||
<tr>
|
||||
<td absheight=4>
|
||||
</table>
|
||||
|
||||
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 43 B |
|
Before Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 167 B |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 65 B After Width: | Height: | Size: 65 B |
|
Before Width: | Height: | Size: 47 B After Width: | Height: | Size: 47 B |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 84 B After Width: | Height: | Size: 84 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 98 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 843 B After Width: | Height: | Size: 843 B |
|
Before Width: | Height: | Size: 967 B After Width: | Height: | Size: 967 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 763 B After Width: | Height: | Size: 763 B |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 779 B After Width: | Height: | Size: 779 B |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 66 B After Width: | Height: | Size: 66 B |
|
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 186 B |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 185 B After Width: | Height: | Size: 185 B |
|
Before Width: | Height: | Size: 87 B After Width: | Height: | Size: 87 B |
|
Before Width: | Height: | Size: 484 B After Width: | Height: | Size: 484 B |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
|
Before Width: | Height: | Size: 84 B After Width: | Height: | Size: 84 B |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
|
Before Width: | Height: | Size: 84 B After Width: | Height: | Size: 84 B |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
|
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 83 B |
|
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 83 B |
|
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 83 B |
|
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 83 B |
|
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 83 B |
|
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 91 B |
|
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 91 B |
|
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 91 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 44 B After Width: | Height: | Size: 44 B |
|
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 120 B |
|
Before Width: | Height: | Size: 84 B After Width: | Height: | Size: 84 B |
|
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 127 B |
|
Before Width: | Height: | Size: 128 B After Width: | Height: | Size: 128 B |
|
Before Width: | Height: | Size: 875 B After Width: | Height: | Size: 875 B |
|
Before Width: | Height: | Size: 43 B After Width: | Height: | Size: 43 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
BIN
zefie_wtvp_minisrv/SharedROMCache/ZefieTV.gif
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
@@ -7,8 +7,9 @@ class WTVShared {
|
||||
|
||||
path = require('path');
|
||||
fs = require('fs');
|
||||
html_entities = require('html-entities'); // used externally by service scripts
|
||||
minisrv_config = [];
|
||||
|
||||
|
||||
constructor(minisrv_config) {
|
||||
if (minisrv_config == null) this.minisrv_config = this.readMiniSrvConfig();
|
||||
else this.minisrv_config = minisrv_config;
|
||||
@@ -23,6 +24,12 @@ class WTVShared {
|
||||
}
|
||||
}
|
||||
|
||||
htmlEntitize(string, process_newline = false) {
|
||||
string = this.html_entities.encode(string).replace(/'/g, "'");
|
||||
if (process_newline) string = string.replace(/\n/gi, "<br>").replace(/\r/gi, "");
|
||||
return string;
|
||||
}
|
||||
|
||||
isASCII(str) {
|
||||
for (var i = 0, strLen = str.length; i < strLen; ++i) {
|
||||
if (str.charCodeAt(i) > 127) return false;
|
||||
@@ -327,10 +334,16 @@ class WTVShared {
|
||||
* @param {string} base Base path
|
||||
* @param {string} target Sub path
|
||||
*/
|
||||
makeSafePath(base, target) {
|
||||
target.replace(/[\|\&\;\$\%\@\"\<\>\+\,\\]/g, "");
|
||||
var targetPath = this.path.posix.normalize(target)
|
||||
return this.fixPathSlashes(base + this.path.sep + targetPath);
|
||||
makeSafePath(base, target = null) {
|
||||
if (target) {
|
||||
target.replace(/[\|\&\;\$\%\@\"\<\>\+\,\\]/g, "");
|
||||
var targetPath = this.path.posix.normalize(target)
|
||||
return this.fixPathSlashes(base + this.path.sep + targetPath);
|
||||
} else {
|
||||
base.replace(/[\|\&\;\$\%\@\"\<\>\+\,\\]/g, "");
|
||||
var targetPath = this.path.posix.normalize(base)
|
||||
return this.fixPathSlashes(base);
|
||||
}
|
||||
}
|
||||
|
||||
makeSafeUsername(username) {
|
||||
|
||||
@@ -6,7 +6,6 @@ const zlib = require('zlib');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const strftime = require('strftime'); // used externally by service scripts
|
||||
const html_entities = require('html-entities'); // used externally by service scripts
|
||||
const net = require('net');
|
||||
const CryptoJS = require('crypto-js');
|
||||
const { crc16 } = require('easy-crc');
|
||||
@@ -101,162 +100,183 @@ async function sendRawFile(socket, path) {
|
||||
});
|
||||
}
|
||||
|
||||
async function processPath(socket, service_vault_file_path, request_headers = new Array(), service_name) {
|
||||
async function processPath(socket, service_vault_file_path, request_headers = new Array(), service_name, shared_romcache = null) {
|
||||
var headers, data = null;
|
||||
var request_is_async = false;
|
||||
var service_vault_found = false;
|
||||
var service_path = unescape(service_vault_file_path);
|
||||
var usingSharedROMCache = false;
|
||||
try {
|
||||
service_vaults.forEach(function (service_vault_dir) {
|
||||
if (service_vault_found) return;
|
||||
service_vault_file_path = wtvshared.makeSafePath(service_vault_dir, service_path);
|
||||
// deny access to catchall file name directly
|
||||
var service_path_split = service_path.split("/");
|
||||
var service_path_request_file = service_path_split[service_path_split.length - 1];
|
||||
if (minisrv_config.config.catchall_file_name) {
|
||||
var minisrv_catchall = null;
|
||||
if (minisrv_config.services[service_name]) minisrv_catchall = minisrv_config.services[service_name].catchall_file_name || minisrv_config.config.catchall_file_name || null;
|
||||
else minisrv_catchall = minisrv_config.config.catchall_file_name || null;
|
||||
if (minisrv_catchall) {
|
||||
if (service_path_request_file == minisrv_catchall) {
|
||||
request_is_async = true;
|
||||
var errpage = wtvshared.doErrorPage(401, "Access Denied");
|
||||
sendToClient(socket, errpage[0], errpage[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
var is_dir = false;
|
||||
var file_exists = false;
|
||||
minisrv_catchall, service_path_split, service_path_request_file = null;
|
||||
if (fs.existsSync(service_vault_file_path)) {
|
||||
file_exists = true;
|
||||
is_dir = fs.lstatSync(service_vault_file_path).isDirectory()
|
||||
}
|
||||
|
||||
if (file_exists && !is_dir) {
|
||||
// file exists, read it and return it
|
||||
service_vault_found = true;
|
||||
request_is_async = true;
|
||||
request_headers.service_file_path = service_vault_file_path;
|
||||
request_headers.raw_file = true;
|
||||
|
||||
// service parsed files, we might not want to expose our service source files so we can protect them with a flag on the first line
|
||||
if (wtvshared.getFileExt(service_vault_file_path).toLowerCase() == "js" || wtvshared.getFileExt(service_vault_file_path).toLowerCase() == "txt") {
|
||||
if (wtvshared.getFileExt(service_vault_file_path).toLowerCase() == "js") {
|
||||
wtvshared.getLineFromFile(service_vault_file_path, 0, function (status, line) {
|
||||
if (!status) {
|
||||
if (line.match(/minisrv\_service\_file.*true/i)) {
|
||||
var errpage = wtvshared.doErrorPage(403, "Access Denied");
|
||||
sendToClient(socket, errpage[0], errpage[1]);
|
||||
} else {
|
||||
sendRawFile(socket, service_vault_file_path);
|
||||
}
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(400);
|
||||
sendToClient(socket, errpage[0], errpage[1]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (wtvshared.getFileExt(service_vault_file_path).toLowerCase() == "txt") {
|
||||
wtvshared.getLineFromFile(service_vault_file_path, 0, function (status, line) {
|
||||
if (!status) {
|
||||
if (line.match(/^#!minisrv/i)) {
|
||||
var errpage = wtvshared.doErrorPage(403, "Access Denied");
|
||||
sendToClient(socket, errpage[0], errpage[1]);
|
||||
} else {
|
||||
sendRawFile(socket, service_vault_file_path);
|
||||
}
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(400);
|
||||
sendToClient(socket, errpage[0], errpage[1]);
|
||||
}
|
||||
});
|
||||
if (!usingSharedROMCache) {
|
||||
if (minisrv_config.config.SharedROMCache && shared_romcache) {
|
||||
if (shared_romcache.indexOf(minisrv_config.config.SharedROMCache) != -1) {
|
||||
var service_path_presplit = shared_romcache.split(path.sep);
|
||||
service_path_presplit.splice(service_path_presplit.findIndex((element) => element === 'ROMCache'), 1);
|
||||
var service_path_romcache = service_path_presplit.join(path.sep);
|
||||
var service_vault_file_path_romcache = wtvshared.returnAbsolutePath(wtvshared.makeSafePath(service_path_romcache));
|
||||
if (fs.existsSync(service_vault_file_path_romcache)) {
|
||||
service_path = service_path.replace(wtvshared.fixPathSlashes(minisrv_config.config.SharedROMCache), 'ROMCache');
|
||||
service_vault_file_path = service_vault_file_path_romcache;
|
||||
usingSharedROMCache = true;
|
||||
} else {
|
||||
service_vault_file_path = wtvshared.makeSafePath(service_vault_dir, service_path);
|
||||
}
|
||||
} else {
|
||||
service_vault_file_path = wtvshared.makeSafePath(service_vault_dir, service_path);
|
||||
}
|
||||
} else {
|
||||
// not a potential service file, so save to send
|
||||
sendRawFile(socket, service_vault_file_path);
|
||||
service_vault_file_path = wtvshared.makeSafePath(service_vault_dir, service_path);
|
||||
}
|
||||
// deny access to catchall file name directly
|
||||
var service_path_split = service_path.split("/");
|
||||
var service_path_request_file = service_path_split[service_path_split.length - 1];
|
||||
if (minisrv_config.config.catchall_file_name) {
|
||||
var minisrv_catchall = null;
|
||||
if (minisrv_config.services[service_name]) minisrv_catchall = minisrv_config.services[service_name].catchall_file_name || minisrv_config.config.catchall_file_name || null;
|
||||
else minisrv_catchall = minisrv_config.config.catchall_file_name || null;
|
||||
if (minisrv_catchall) {
|
||||
if (service_path_request_file == minisrv_catchall) {
|
||||
request_is_async = true;
|
||||
var errpage = wtvshared.doErrorPage(401, "Access Denied");
|
||||
sendToClient(socket, errpage[0], errpage[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
var is_dir = false;
|
||||
var file_exists = false;
|
||||
minisrv_catchall, service_path_split, service_path_request_file = null;
|
||||
if (fs.existsSync(service_vault_file_path)) {
|
||||
file_exists = true;
|
||||
is_dir = fs.lstatSync(service_vault_file_path).isDirectory()
|
||||
}
|
||||
|
||||
} else if (fs.existsSync(service_vault_file_path + ".txt")) {
|
||||
// raw text format, entire payload expected (headers and content)
|
||||
service_vault_found = true;
|
||||
request_is_async = true;
|
||||
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Found " + service_vault_file_path + ".txt to handle request (Raw TXT Mode) [Socket " + socket.id + "]");
|
||||
request_headers.service_file_path = service_vault_file_path + ".txt";
|
||||
fs.readFile(service_vault_file_path + ".txt", 'Utf-8', function (err, file_raw) {
|
||||
if (file_raw.indexOf("\n\n") > 0) {
|
||||
// split headers and data by newline (unix format)
|
||||
var file_raw_split = file_raw.split("\n\n");
|
||||
headers = file_raw_split[0];
|
||||
file_raw_split.shift();
|
||||
data = file_raw_split.join("\n");
|
||||
} else if (file_raw.indexOf("\r\n\r\n") > 0) {
|
||||
// split headers and data by carrage return + newline (windows format)
|
||||
var file_raw_split = file_raw.split("\r\n\r\n");
|
||||
headers = file_raw_split[0].replace(/\r/g, "");
|
||||
file_raw_split.shift();
|
||||
data = file_raw_split.join("\r\n");
|
||||
} else {
|
||||
// couldn't find two line breaks, assume entire file is just headers
|
||||
headers = file_raw;
|
||||
data = '';
|
||||
}
|
||||
sendToClient(socket, headers, data);
|
||||
});
|
||||
} else if (fs.existsSync(service_vault_file_path + ".js")) {
|
||||
// synchronous js scripting, process with vars, must set 'headers' and 'data' appropriately.
|
||||
// loaded script will have r/w access to any JavaScript vars this function does.
|
||||
// request headers are in an array named `request_headers`.
|
||||
// Query arguments in `request_headers.query`
|
||||
// Can upgrade to asynchronous by setting `request_is_async` to `true`
|
||||
// In Asynchronous mode, you are expected to call sendToClient(socket,headers,data) by the end of your script
|
||||
// `socket` is already defined and should be passed-through.
|
||||
service_vault_found = true;
|
||||
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Found " + service_vault_file_path + ".js to handle request (JS Interpreter mode) [Socket " + socket.id + "]");
|
||||
request_headers.service_file_path = service_vault_file_path + ".js";
|
||||
// expose var service_dir for script path to the root of the wtv-service
|
||||
var service_dir = service_vault_dir + path.sep + service_name;
|
||||
socket_sessions[socket.id].starttime = Math.floor(new Date().getTime() / 1000);
|
||||
var jscript_eval = fs.readFileSync(service_vault_file_path + ".js").toString();
|
||||
eval(jscript_eval);
|
||||
if (request_is_async && !minisrv_config.config.debug_flags.quiet) console.log(" * Script requested Asynchronous mode");
|
||||
}
|
||||
else if (fs.existsSync(service_vault_file_path + ".html")) {
|
||||
// Standard HTML with no headers, WTV Style
|
||||
service_vault_found = true;
|
||||
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Found " + service_vault_file_path + ".html to handle request (HTML Mode) [Socket " + socket.id + "]");
|
||||
request_headers.service_file_path = service_vault_file_path + ".html";
|
||||
request_is_async = true;
|
||||
headers = "200 OK\n"
|
||||
headers += "Content-Type: text/html"
|
||||
fs.readFile(service_vault_file_path + ".html", null, function (err, data) {
|
||||
sendToClient(socket, headers, data);
|
||||
});
|
||||
} else {
|
||||
// look for a catchallin the current path and all parent paths up until the service root
|
||||
if (minisrv_config.config.catchall_file_name) {
|
||||
var minisrv_catchall_file_name = null;
|
||||
if (minisrv_config.services[service_name]) minisrv_catchall_file_name = minisrv_config.services[service_name].catchall_file_name || minisrv_config.config.catchall_file_name || null;
|
||||
else minisrv_catchall_file_name = minisrv_config.config.catchall_file_name || null;
|
||||
if (minisrv_catchall_file_name) {
|
||||
var service_check_dir = service_vault_file_path.split(path.sep);
|
||||
service_check_dir.pop(); // pop filename
|
||||
if (file_exists && !is_dir) {
|
||||
// file exists, read it and return it
|
||||
service_vault_found = true;
|
||||
request_is_async = true;
|
||||
request_headers.service_file_path = service_vault_file_path;
|
||||
request_headers.raw_file = true;
|
||||
|
||||
while (service_check_dir.join(path.sep) != service_vault_dir) {
|
||||
var catchall_file = service_check_dir.join(path.sep) + path.sep + minisrv_catchall_file_name;
|
||||
if (fs.existsSync(catchall_file)) {
|
||||
service_vault_found = true;
|
||||
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Found catchall at " + catchall_file + " to handle request (JS Interpreter Mode) [Socket " + socket.id + "]");
|
||||
request_headers.service_file_path = catchall_file;
|
||||
var jscript_eval = fs.readFileSync(catchall_file).toString();
|
||||
// don't pass these vars to the script
|
||||
var service_check_dir, minisrv_catchall_file_name = null;
|
||||
eval(jscript_eval);
|
||||
if (request_is_async && !minisrv_config.config.debug_flags.quiet) console.log(" * Script requested Asynchronous mode");
|
||||
} else {
|
||||
service_check_dir.pop();
|
||||
// service parsed files, we might not want to expose our service source files so we can protect them with a flag on the first line
|
||||
if (wtvshared.getFileExt(service_vault_file_path).toLowerCase() == "js" || wtvshared.getFileExt(service_vault_file_path).toLowerCase() == "txt") {
|
||||
if (wtvshared.getFileExt(service_vault_file_path).toLowerCase() == "js") {
|
||||
wtvshared.getLineFromFile(service_vault_file_path, 0, function (status, line) {
|
||||
if (!status) {
|
||||
if (line.match(/minisrv\_service\_file.*true/i)) {
|
||||
var errpage = wtvshared.doErrorPage(403, "Access Denied");
|
||||
sendToClient(socket, errpage[0], errpage[1]);
|
||||
} else {
|
||||
sendRawFile(socket, service_vault_file_path);
|
||||
}
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(400);
|
||||
sendToClient(socket, errpage[0], errpage[1]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (wtvshared.getFileExt(service_vault_file_path).toLowerCase() == "txt") {
|
||||
wtvshared.getLineFromFile(service_vault_file_path, 0, function (status, line) {
|
||||
if (!status) {
|
||||
if (line.match(/^#!minisrv/i)) {
|
||||
var errpage = wtvshared.doErrorPage(403, "Access Denied");
|
||||
sendToClient(socket, errpage[0], errpage[1]);
|
||||
} else {
|
||||
sendRawFile(socket, service_vault_file_path);
|
||||
}
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(400);
|
||||
sendToClient(socket, errpage[0], errpage[1]);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// not a potential service file, so save to send
|
||||
sendRawFile(socket, service_vault_file_path);
|
||||
}
|
||||
|
||||
} else if (fs.existsSync(service_vault_file_path + ".txt")) {
|
||||
// raw text format, entire payload expected (headers and content)
|
||||
service_vault_found = true;
|
||||
request_is_async = true;
|
||||
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Found " + service_vault_file_path + ".txt to handle request (Raw TXT Mode) [Socket " + socket.id + "]");
|
||||
request_headers.service_file_path = service_vault_file_path + ".txt";
|
||||
fs.readFile(service_vault_file_path + ".txt", 'Utf-8', function (err, file_raw) {
|
||||
if (file_raw.indexOf("\n\n") > 0) {
|
||||
// split headers and data by newline (unix format)
|
||||
var file_raw_split = file_raw.split("\n\n");
|
||||
headers = file_raw_split[0];
|
||||
file_raw_split.shift();
|
||||
data = file_raw_split.join("\n");
|
||||
} else if (file_raw.indexOf("\r\n\r\n") > 0) {
|
||||
// split headers and data by carrage return + newline (windows format)
|
||||
var file_raw_split = file_raw.split("\r\n\r\n");
|
||||
headers = file_raw_split[0].replace(/\r/g, "");
|
||||
file_raw_split.shift();
|
||||
data = file_raw_split.join("\r\n");
|
||||
} else {
|
||||
// couldn't find two line breaks, assume entire file is just headers
|
||||
headers = file_raw;
|
||||
data = '';
|
||||
}
|
||||
sendToClient(socket, headers, data);
|
||||
});
|
||||
} else if (fs.existsSync(service_vault_file_path + ".js")) {
|
||||
// synchronous js scripting, process with vars, must set 'headers' and 'data' appropriately.
|
||||
// loaded script will have r/w access to any JavaScript vars this function does.
|
||||
// request headers are in an array named `request_headers`.
|
||||
// Query arguments in `request_headers.query`
|
||||
// Can upgrade to asynchronous by setting `request_is_async` to `true`
|
||||
// In Asynchronous mode, you are expected to call sendToClient(socket,headers,data) by the end of your script
|
||||
// `socket` is already defined and should be passed-through.
|
||||
service_vault_found = true;
|
||||
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Found " + service_vault_file_path + ".js to handle request (JS Interpreter mode) [Socket " + socket.id + "]");
|
||||
request_headers.service_file_path = service_vault_file_path + ".js";
|
||||
// expose var service_dir for script path to the root of the wtv-service
|
||||
var service_dir = service_vault_dir + path.sep + service_name;
|
||||
socket_sessions[socket.id].starttime = Math.floor(new Date().getTime() / 1000);
|
||||
var jscript_eval = fs.readFileSync(service_vault_file_path + ".js").toString();
|
||||
eval(jscript_eval);
|
||||
if (request_is_async && !minisrv_config.config.debug_flags.quiet) console.log(" * Script requested Asynchronous mode");
|
||||
}
|
||||
else if (fs.existsSync(service_vault_file_path + ".html")) {
|
||||
// Standard HTML with no headers, WTV Style
|
||||
service_vault_found = true;
|
||||
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Found " + service_vault_file_path + ".html to handle request (HTML Mode) [Socket " + socket.id + "]");
|
||||
request_headers.service_file_path = service_vault_file_path + ".html";
|
||||
request_is_async = true;
|
||||
headers = "200 OK\n"
|
||||
headers += "Content-Type: text/html"
|
||||
fs.readFile(service_vault_file_path + ".html", null, function (err, data) {
|
||||
sendToClient(socket, headers, data);
|
||||
});
|
||||
} else {
|
||||
// look for a catchallin the current path and all parent paths up until the service root
|
||||
if (minisrv_config.config.catchall_file_name) {
|
||||
var minisrv_catchall_file_name = null;
|
||||
if (minisrv_config.services[service_name]) minisrv_catchall_file_name = minisrv_config.services[service_name].catchall_file_name || minisrv_config.config.catchall_file_name || null;
|
||||
else minisrv_catchall_file_name = minisrv_config.config.catchall_file_name || null;
|
||||
if (minisrv_catchall_file_name) {
|
||||
var service_check_dir = service_vault_file_path.split(path.sep);
|
||||
service_check_dir.pop(); // pop filename
|
||||
|
||||
while (service_check_dir.join(path.sep) != service_vault_dir && service_check_dir.length > 0) {
|
||||
var catchall_file = service_check_dir.join(path.sep) + path.sep + minisrv_catchall_file_name;
|
||||
if (fs.existsSync(catchall_file)) {
|
||||
service_vault_found = true;
|
||||
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Found catchall at " + catchall_file + " to handle request (JS Interpreter Mode) [Socket " + socket.id + "]");
|
||||
request_headers.service_file_path = catchall_file;
|
||||
var jscript_eval = fs.readFileSync(catchall_file).toString();
|
||||
// don't pass these vars to the script
|
||||
var service_check_dir, minisrv_catchall_file_name = null;
|
||||
eval(jscript_eval);
|
||||
if (request_is_async && !minisrv_config.config.debug_flags.quiet) console.log(" * Script requested Asynchronous mode");
|
||||
} else {
|
||||
service_check_dir.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,7 +292,7 @@ async function processPath(socket, service_vault_file_path, request_headers = ne
|
||||
}
|
||||
if (!request_is_async) {
|
||||
if (!service_vault_found) {
|
||||
console.error(" * Could not find a Service Vault for " + service_name + ":/" + service_path.replace(service_name + path.sep, ""));
|
||||
console.error(" * Could not find a Service Vault for " + service_name + ":/" + service_path.replace(service_name + path.sep, "").replace(path.sep, '/'));
|
||||
var errpage = wtvshared.doErrorPage(404, null, socket.minisrv_pc_mode);
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
@@ -428,9 +448,13 @@ Location: " + minisrv_config.config.unauthorized_url`;
|
||||
// assume webtv since there is a :/ in the GET
|
||||
var service_name = shortURL.split(':/')[0];
|
||||
var urlToPath = wtvshared.fixPathSlashes(service_name + path.sep + shortURL.split(':/')[1]);
|
||||
var shared_romcache = null;
|
||||
if (shortURL.indexOf("/ROMCache/") != -1 && minisrv_config.config.enable_shared_romcache) {
|
||||
shared_romcache = wtvshared.fixPathSlashes(minisrv_config.config.SharedROMCache + path.sep + shortURL.split(':/')[1]);
|
||||
}
|
||||
if (minisrv_config.config.debug_flags.show_headers) console.log(" * Incoming headers on socket ID", socket.id, (await wtvshared.decodePostData(wtvshared.filterSSID(Object.assign({}, request_headers)))));
|
||||
socket_sessions[socket.id].request_headers = request_headers;
|
||||
processPath(socket, urlToPath, request_headers, service_name);
|
||||
processPath(socket, urlToPath, request_headers, service_name, shared_romcache);
|
||||
} else if (shortURL.indexOf('http://') >= 0 || shortURL.indexOf('https://') >= 0) {
|
||||
doHTTPProxy(socket, request_headers);
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
"ServiceVault"
|
||||
],
|
||||
"SessionStore": "SessionStore",
|
||||
"SharedROMCache": "SharedROMCache",
|
||||
"enable_shared_romcache": true,
|
||||
"service_owner": "a minisrv user",
|
||||
"service_owner_account": "minisrvuser",
|
||||
"service_owner_contact": "someone",
|
||||
|
||||
@@ -338,6 +338,63 @@
|
||||
<Content Include="ServiceVault\wtv-head-waiter\login.js" />
|
||||
<Content Include="ServiceVault\wtv-home\splash.js" />
|
||||
<Content Include="ServiceVault\wtv-log\log.js" />
|
||||
<Content Include="SharedROMCache\AccountBanner.gif" />
|
||||
<Content Include="SharedROMCache\AroundTownIcon2.gif" />
|
||||
<Content Include="SharedROMCache\AT_BannerGradient.gif" />
|
||||
<Content Include="SharedROMCache\AT_BannerIcon.gif" />
|
||||
<Content Include="SharedROMCache\AT_BottomShadow.gif" />
|
||||
<Content Include="SharedROMCache\AT_Shadow.gif" />
|
||||
<Content Include="SharedROMCache\BulletArrow.gif" />
|
||||
<Content Include="SharedROMCache\Chat.gif" />
|
||||
<Content Include="SharedROMCache\CommunityBanner.gif" />
|
||||
<Content Include="SharedROMCache\DottedLine.gif" />
|
||||
<Content Include="SharedROMCache\ExploreTitle.gif" />
|
||||
<Content Include="SharedROMCache\FileImage.gif" />
|
||||
<Content Include="SharedROMCache\FileMovie.gif" />
|
||||
<Content Include="SharedROMCache\FilePackage.gif" />
|
||||
<Content Include="SharedROMCache\FileSound.gif" />
|
||||
<Content Include="SharedROMCache\FileText.gif" />
|
||||
<Content Include="SharedROMCache\HackTVLogoJewel.gif" />
|
||||
<Content Include="SharedROMCache\help\common\helpMastheadBlank.swf" />
|
||||
<Content Include="SharedROMCache\HomeBanner.gif" />
|
||||
<Content Include="SharedROMCache\kb.gif" />
|
||||
<Content Include="SharedROMCache\kb_alpha.gif" />
|
||||
<Content Include="SharedROMCache\MSNLogo.gif" />
|
||||
<Content Include="SharedROMCache\news_icon.gif" />
|
||||
<Content Include="SharedROMCache\PanelEdge.gif" />
|
||||
<Content Include="SharedROMCache\PaperBase.gif" />
|
||||
<Content Include="SharedROMCache\PaperTop.gif" />
|
||||
<Content Include="SharedROMCache\PaperTopFlat.gif" />
|
||||
<Content Include="SharedROMCache\PromotionLeftEdge.gif" />
|
||||
<Content Include="SharedROMCache\RemoveButton.gif" />
|
||||
<Content Include="SharedROMCache\S20BV1.gif" />
|
||||
<Content Include="SharedROMCache\S20BV2.gif" />
|
||||
<Content Include="SharedROMCache\S20TH1.gif" />
|
||||
<Content Include="SharedROMCache\S20TV1.gif" />
|
||||
<Content Include="SharedROMCache\S20TV2.gif" />
|
||||
<Content Include="SharedROMCache\S40H1.gif" />
|
||||
<Content Include="SharedROMCache\S40V1.gif" />
|
||||
<Content Include="SharedROMCache\S40V2.gif" />
|
||||
<Content Include="SharedROMCache\S60HS1.gif" />
|
||||
<Content Include="SharedROMCache\S60HS2.gif" />
|
||||
<Content Include="SharedROMCache\S60HS3.gif" />
|
||||
<Content Include="SharedROMCache\S60HS4.gif" />
|
||||
<Content Include="SharedROMCache\S60HS5.gif" />
|
||||
<Content Include="SharedROMCache\SAdH1.gif" />
|
||||
<Content Include="SharedROMCache\SAdH2.gif" />
|
||||
<Content Include="SharedROMCache\SAdH3.gif" />
|
||||
<Content Include="SharedROMCache\SettingsBanner.gif" />
|
||||
<Content Include="SharedROMCache\Shadow.gif" />
|
||||
<Content Include="SharedROMCache\ShadowCorner.gif" />
|
||||
<Content Include="SharedROMCache\ShadowH.gif" />
|
||||
<Content Include="SharedROMCache\ShadowHCap.gif" />
|
||||
<Content Include="SharedROMCache\ShadowHStart.gif" />
|
||||
<Content Include="SharedROMCache\SiteShowcase.gif" />
|
||||
<Content Include="SharedROMCache\Spacer.gif" />
|
||||
<Content Include="SharedROMCache\splash_logo_hacktv.gif" />
|
||||
<Content Include="SharedROMCache\up-arrows.swf" />
|
||||
<Content Include="SharedROMCache\UsingWebTVBanner.gif" />
|
||||
<Content Include="SharedROMCache\WebTVLogoJewel.gif" />
|
||||
<Content Include="test.js" />
|
||||
<Content Include="WTVBGMusic.js">
|
||||
<SubType>Code</SubType>
|
||||
@@ -405,6 +462,9 @@
|
||||
<Folder Include="ServiceVault\wtv-log\" />
|
||||
<Folder Include="ServiceVault\wtv-disk\content\" />
|
||||
<Folder Include="ServiceVault\wtv-disk\content\diskmaps\" />
|
||||
<Folder Include="SharedROMCache\" />
|
||||
<Folder Include="SharedROMCache\help\" />
|
||||
<Folder Include="SharedROMCache\help\common\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsToolsV2.targets" />
|
||||
</Project>
|
||||