even more mail stuff

This commit is contained in:
zefie
2022-02-10 20:49:48 -05:00
parent a5a035438b
commit 123c8f7823
20 changed files with 601 additions and 419 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 843 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 967 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

View File

@@ -0,0 +1,22 @@
var minisrv_service_file = true;
var errpage = null;
var messageid = request_headers.query.message_id;
var attachment_id = request_headers.query.attachment_id;
if (!attachment_id && attachment_id != 0) errpage = wtvshared.doErrorPage(400, "Attachment ID required.");
else {
var message = ssid_sessions[socket.ssid].mailstore.getMessageByID(messageid);
if (!message) errpage = wtvshared.doErrorPage(400, "Invalid Message ID");
else {
if (!message.attachments) message.attachments = []; // backwards compat
if (attachment_id > message.attachments.length) errpage = wtvshared.doErrorPage(400, "Invalid Attachment ID");
}
}
if (!errpage) {
headers = `200 OK
Content-Type: ${message.attachments[attachment_id]['Content-Type']}`;
data = new Buffer.from(message.attachments[attachment_id]['data'], 'base64');
fs.writeFileSync("D:\\test.jpg", data);
}

View File

@@ -0,0 +1,19 @@
var minisrv_service_file = true;
var errpage = null;
var messageid = request_headers.query.message_id || null;
if (!messageid) {
// get user signature
data = ssid_sessions[socket.ssid].getSessionData("subscriber_signature");
} else {
// get message signature
var message = ssid_sessions[socket.ssid].mailstore.getMessageByID(messageid);
if (!message) errpage = wtvshared.doErrorPage(400, "Invalid Message ID");
data = message.signature
}
if (!errpage) {
headers = `200 OK
wtv-trusted: false
Content-Type: text/html`
}

View File

@@ -53,7 +53,7 @@ xnocancel>
<HTML> <HTML>
<head> <head>
<title> <title>
${message.subject} ${html_entities.encode((message.subject) ? message.subject : '(No subject)')}
</title> </title>
</head> </head>
<body <body
@@ -257,7 +257,7 @@ ${html_entities.encode(message.to_addr)} ${(html_entities.encode(message.to_name
<td nowrap valign=top> <td nowrap valign=top>
Subject: <td> Subject: <td>
<td> <td>
${html_entities.encode(message.subject)} ${html_entities.encode((message.subject) ? message.subject : '(No subject)')}
<tr> <tr>
<td height=10> <td height=10>
<spacer type=vertical size=10> <spacer type=vertical size=10>
@@ -267,8 +267,32 @@ ${html_entities.encode(message.subject)}
<tr> <tr>
<td width=425> <td width=425>
<p> <p>
`;
if (message.attachments) {
message.attachments.forEach((v, k) => {
if (v) {
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">`;
break;
case "audio/wav":
data += `<table width=386 cellspacing=0 cellpadding=0>
<td align=left valign=middle>
<a href="wtv-mail:/get-attachment?message_id=${messageid}&attachment_id=${k}&wtv-title=Voice%20Mail" id=focus><img src="wtv-mail:/ROMCache/FileSound.gif" align=absmiddle></a>&nbsp;&nbsp;Recording
<td align=right valign=middle>
</table>
`;
break;
}
}
});
}
data += `
${html_entities.encode(message.body).replace("\n", "<br>")} ${html_entities.encode(message.body).replace("\n", "<br>")}
${(message.signature) ? '<embed src="wtv-mail:/get-signature?message_id=${messageid}>' : ''} <br>
${(message.signature) ? '<embed src="wtv-mail:/get-signature?message_id='+messageid+'">' : ''}
<p> <p>
<p> <p>
</table> </table>

View File

@@ -1,4 +1,6 @@
var minisrv_service_file = true; var minisrv_service_file = true;
var message_snapshot_data = null;
var message_voicemail_data = null;
var intro_seen = ssid_sessions[socket.ssid].mailstore.checkMailIntroSeen(); var intro_seen = ssid_sessions[socket.ssid].mailstore.checkMailIntroSeen();
if (!intro_seen && !request_headers.query.intro_seen) { if (!intro_seen && !request_headers.query.intro_seen) {
@@ -21,64 +23,117 @@ if (!intro_seen && !request_headers.query.intro_seen) {
var msg_subject = request_headers.query.message_subject || null; var msg_subject = request_headers.query.message_subject || null;
var msg_body = request_headers.query.message_body || null; var msg_body = request_headers.query.message_body || null;
var to_name = request_headers.query.whatever_webtv_sends_this_as || null; var to_name = request_headers.query.whatever_webtv_sends_this_as || null;
var no_signature = request_headers.query.no_signature || false; var no_signature = (request_headers.query.togglesign == "true") ? false : true; // opposite webtv
var mail_draft_data = ssid_sessions[socket.ssid].getSessionData("mail_draft"); var mail_draft_data = ssid_sessions[socket.ssid].getSessionData("mail_draft");
var mail_draft_attachments = ssid_sessions[socket.ssid].getSessionData("mail_draft_attachments");
if (mail_draft_data) { if (mail_draft_data) {
ssid_sessions[socket.ssid].deleteSessionData("mail_draft") ssid_sessions[socket.ssid].deleteSessionData("mail_draft");
to_addr = mail_draft_data.to_addr; to_addr = mail_draft_data.to_addr;
msg_subject = mail_draft_data.msg_subject; msg_subject = mail_draft_data.msg_subject;
msg_body = mail_draft_data.msg_body; msg_body = mail_draft_data.msg_body;
no_signature = mail_draft_data.no_signature; no_signature = mail_draft_data.no_signature;
} }
if (mail_draft_attachments) {
if (mail_draft_attachments.message_snapshot_data) message_snapshot_data = mail_draft_attachments.message_snapshot_data;
else if (request_headers.query.message_snapshot_data) message_snapshot_data = request_headers.query.message_snapshot_data;
if (mail_draft_attachments.message_voicemail_data) message_voicemail_data = mail_draft_attachments.message_voicemail_data;
else if (request_headers.query.message_voicemail_data) message_voicemail_data = request_headers.query.message_voicemail_data;
}
if (message_snapshot_data && request_headers.query.get_snap) {
var username = ssid_sessions[socket.ssid].getSessionData("subscriber_username"); headers = `200 OK
var userdisplayname = html_entities.encode(ssid_sessions[socket.ssid].getSessionData("subscriber_name")); Content-Type: image/jpeg`;
var address = username + "@" + minisrv_config.config.service_name data = message_snapshot_data;
var notImplementedAlert = new clientShowAlert({ } else if (message_voicemail_data && request_headers.query.get_snap) {
'image': minisrv_config.config.service_logo, headers = `200 OK
'message': "This feature is not available.", Content-Type: audio/wav`;
'buttonlabel1': "Okay", data = message_voicemail_data;
'buttonaction1': "client:donothing",
'noback': true,
}).getURL();
if (request_headers.query.sendoff == "Send" || request_headers.query.saveoff) {
var from_addr = address;
var signature = ssid_sessions[socket.ssid].getSessionData("subscriber_signature") || null;
if (request_headers.query.sendoff == "Send") {
var messagereturn = ssid_sessions[socket.ssid].mailstore.sendMessageToAddr(from_addr, to_addr, msg_body, msg_subject, userdisplayname, to_name, signature);
if (messagereturn !== true) {
var errpage = wtvshared.doErrorPage(400, messagereturn);
headers = errpage[0];
data = errpage[1];
} else {
headers = `300 OK
wtv-expire: wtv-mail:/listmail
Location: wtv-mail:/listmail`;
}
} else {
var mail_draft_data = {
to_addr: to_addr,
msg_subject: msg_subject,
msg_body: msg_body,
no_signature: no_signature
}
ssid_sessions[socket.ssid].setSessionData("mail_draft", mail_draft_data);
headers = `200 OK
Content-type text/html
wtv-expire: wtv-mail:/sendmail`;
}
} else { } else {
headers = `200 OK var username = ssid_sessions[socket.ssid].getSessionData("subscriber_username");
Content-type text/html`; var userdisplayname = html_entities.encode(ssid_sessions[socket.ssid].getSessionData("subscriber_name"));
var address = username + "@" + minisrv_config.config.service_name
var notImplementedAlert = new clientShowAlert({
'image': minisrv_config.config.service_logo,
'message': "This feature is not available.",
'buttonlabel1': "Okay",
'buttonaction1': "client:donothing",
'noback': true,
}).getURL();
data = `<html> if (request_headers.query.sendoff == "Send" || 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") {
var attachments = [];
if (typeof message_snapshot_data == "object") {
attachments.push({ 'Content-Type': 'image/jpeg', data: new Buffer.from(message_snapshot_data).toString('base64') });
} else {
attachments.push({ 'Content-Type': 'image/jpeg', data: message_snapshot_data });
}
if (typeof message_snapshot_data == "object") {
attachments.push({ 'Content-Type': 'audio/wav', data: new Buffer.from(message_snapshot_data).toString('base64') });
} else {
attachments.push({ 'Content-Type': 'audio/wav', data: new message_snapshot_data });
}
var messagereturn = ssid_sessions[socket.ssid].mailstore.sendMessageToAddr(from_addr, to_addr, msg_body, msg_subject, userdisplayname, to_name, signature, attachments);
if (messagereturn !== true) {
var errpage = wtvshared.doErrorPage(400, messagereturn);
headers = errpage[0];
data = errpage[1];
} else {
ssid_sessions[socket.ssid].deleteSessionData("mail_draft");
ssid_sessions[socket.ssid].deleteSessionData("mail_draft_attachments");
headers = `300 OK
wtv-expire: wtv-mail:/listmail
wtv-expire: wtv-mail:/sendmail
Location: wtv-mail:/listmail`;
}
} else if (request_headers.query.saveoff) {
var mail_draft_data = {
to_addr: to_addr,
msg_subject: msg_subject,
msg_body: msg_body,
no_signature: no_signature
}
ssid_sessions[socket.ssid].setSessionData("mail_draft", mail_draft_data);
headers = `200 OK
Content-type: text/html
wtv-expire: wtv-mail:/sendmail`;
}
} else {
headers = `200 OK
Content-type: text/html`;
if (request_headers.query.snapping == "false") headers += "\nwtv-expire: cache:snapshot.jpg";
if (request_headers.query.gabbing == "false") headers += "\nwtv-expire: cache:voicemail.wav";
var mail_draft_data = ssid_sessions[socket.ssid].getSessionData("mail_draft_attachments") || {};
if (request_headers.query.message_snapshot_data) {
mail_draft_data.message_snapshot_data = request_headers.query.message_snapshot_data
ssid_sessions[socket.ssid].setSessionData("mail_draft_attachments", mail_draft_data);
}
if (request_headers.query.message_voicemail_data) {
mail_draft_data.message_voicemail_data = request_headers.query.message_voicemail_data
ssid_sessions[socket.ssid].setSessionData("mail_draft_attachments", mail_draft_data);
}
data = `<HTML>
<head> <head>
<display poweroffalert > <display poweroffalert >
<sendpanel
action="javascript:Submit()"
message="Send this message now"
label="Send message">
<savepanel message="Messages that you are writing cannot be saved. Send it to yourself if you would like a copy.">
<script language=javascript> <script language=javascript>
function Submit() { window.open("client:showsplash?message=Sending%20Message&animation=file://ROM/Animations/mail.ani&action=client:submitform%3Fname%3Dsendform%26submitname%3Dsendoff%26submitvalue%3DSend"); function Submit() { if (document.sendform.message_to.value == "") { location = "client:showalert?message=Your%20message%20could%20not%20be%20sent.%3Cp%3E%0AYou%20must%20specify%20an%20addressee%20in%20the%20%3Cblackface%3ETo%3A%3C%2Fblackface%3E%20area.%0A&buttonLabel1=Continue%0A&buttonAction1=client%3Adonothing&buttonLabel2=";
} else { location = "client:showsplash?message=Sending%20Message&animation=file://ROM/Animations/mail.ani&action=client:submitform%3Fname%3Dsendform%26submitname%3Dsendoff%26submitvalue%3DSend";
}
} }
function ErasingMedia(victim) { var myURL; function ErasingMedia(victim) { var myURL;
myURL = "client:submitform?name=sendform&submitvalue=false" + "&submitname=" + victim; myURL = "client:submitform?name=sendform&submitvalue=false" + "&submitname=" + victim;
@@ -86,316 +141,199 @@ if (victim == "gabbing") { document.forms.sendform.elements.message_voicemail_da
} }
if (victim == "snapping") { document.forms.sendform.elements.message_snapshot_data.disabled = true; if (victim == "snapping") { document.forms.sendform.elements.message_snapshot_data.disabled = true;
} }
window.open(myURL); } location = myURL;
function DoneSnapping() { var myURL; location.reload(); }
myURL = "client:submitform?name=sendform&submitname=snapping&submitvalue=cache%3Asnapshot.jpg"; function Signing(desiredState) { var myURL;
window.open(myURL); } myURL="client:submitform?name=sendform&submitvalue="+desiredState+"&submitname=togglesign";
location = myURL;
location.reload();
}
function DoneSnapping() { location = "client:submitform?name=sendform&submitname=snapping&submitvalue=true";
location.reload(); }
function DoneGabbing() { var myURL; function DoneGabbing() { var myURL;
myURL = "client:submitform?name=sendform&submitname=gabbing&submitvalue=cache%3Avoicemail.jpg"; myURL = "client:submitform?name=sendform&submitname=gabbing&submitvalue=cache%3Avoicemail.wav";
window.open(myURL); } location = "client:submitform?name=sendform&submitname=gabbing&submitvalue=true";
location.reload(); }
</script> </script>
<sendpanel
action="javascript:Submit()"
message="Send this message now"
label="Send message"
>
<savepanel message="Messages that you are writing cannot be saved. Send it to yourself if you would like a copy." >
<title> <title>
Write a message Write an e-mail message
</title> </title>
</head> </head>
<print blackandwhite> <body bgcolor="#171726" text="#82A9D9" link="#BDA73A" vlink="#62B362" vspace=0 hspace=0>
<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="${minisrv_config.config.service_logo}" 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 href="client:openaddresspanel" id=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">Address</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:videocapture?notify=javascript%3ADoneSnapping()&device=video&width=75%25&height=75%25&name=cache%3Asnapshot.jpg&donebuttonlabel=Add%20to%20Message&open"
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">Photo</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:soundcapture?notify=javascript%3ADoneGabbing()&device=audio&rate=8000&name=cache%3Avoicemail.wav&donebuttonlabel=Add%20to%20Message&open"
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">Recording</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?sound=none&message=Are%20you%20sure%20you%20want%20to%20erase%20the%20changes%20to%20this%20message%3F&buttonlabel2=Don't%20Erase&buttonaction2=client:donothing&buttonlabel1=Erase&buttonaction1=wtv-mail:/sendmail%3Fclear%3Dtrue%26wtv-saved-message-id%3Dwritemessage-outbox#focus"
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">Erase</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:submitform?name=sendform&submitname=spelling&submitvalue=true"
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">Spelling</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:/help/Mail/Write/Writing"
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=81 valign=bottom align=right>
<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 height=47 valign=top>
<font size=+1 color="E7CE4A">
<blackface>
<shadow>
<a id=focus></a>
<img src="wtv-home:/ROMCache/Spacer.gif" width=4 height=2>
Write a message
</shadow>
</blackface>
</font>
</table>
<form action="wtv-mail:/sendmail#focus" method="post" name=sendform > <form action="wtv-mail:/sendmail#focus" method="post" name=sendform >
<input type=hidden name="wtv-saved-message-id" value="writemessage-outbox"> <input type=hidden name="wtv-saved-message-id" value="writemessage-outbox">
<input type=hidden name="message_reply_all_cc" value=""> <input type=hidden name="message_reply_all_cc" value="">
<input type=hidden name="saveoff" value="true" autosubmit="onleave"> <input type=hidden name="saveoff" value="true" autosubmit="onleave">
<table cellspacing=0 cellpadding=0 bgcolor="242424" <sidebar width=109>
background="" <table cellspacing=0 cellpadding=0>
>
<tr> <tr>
<td rowspan=100 abswidth=10 bgcolor=191919> <td width=104 height=420 bgcolor=#262E3D valign=top>
<img src="wtv-home:/ROMCache/Spacer.gif" width=10 height=1> <table cellspacing=0 cellpadding=0>
<td colspan=9 abswidth=422 valign=bottom>
<img src="wtv-mail:/ROMCache/PaperTop.gif" noprint width=422 height=26>
<tr> <tr>
<td rowspan=100 abswidth=2 absheight=0 bgcolor=313131> <td height=7 colspan=3>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1> <spacer type=vertical size=7>
<td rowspan=100 abswidth=14 absheight=0> <tr>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1> <td width=7>
<td colspan=2 abswidth=386> <spacer type=horizontal size=7>
<td rowspan=100 abswidth=14 absheight=0> <td width=87 href="wtv-home:/home">
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1> <img src="${minisrv_config.config.service_logo}" width=87 height=67>
<td rowspan=100 abswidth=3 bgcolor=0b0b0b absheight=0> <td width=10>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1> <spacer type=horizontal size=10>
<td rowspan=100 abswidth=1 bgcolor=0f0f0f absheight=0> </table>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1> <spacer type=vertical size=6>
<td rowspan=100 abswidth=1 bgcolor=131313 absheight=0> <table cellspacing=0 cellpadding=0 border=0>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1> <tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
<td rowspan=100 abswidth=1 bgcolor=171717 absheight=0> <tr>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1> <td width=10 height=26>
<tr absheight=30> <td width=89 valgn=middle>
<td abswidth=80 valign=top align=right> <table cellspacing=0 cellpadding=0 href="wtv-mail:/listmail" >
<font color="42BD52"> <tr>
From:&nbsp; <td height=1>
<td abswidth=306> <tr>
<font color="42BD52"> <td><shadow><font sizerange=medium color=#E6CD4A>Mail list</font></shadow>
${address} </table>
(${userdisplayname})</font> <td width=5>
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
<tr>
<td width=10 height=26>
<td width=89 valgn=middle>
<table cellspacing=0 cellpadding=0 href="client:openaddresspanel" id=addressbook>
<tr>
<td height=1>
<tr>
<td><shadow><font sizerange=medium color=#E6CD4A>Address</font></shadow>
</table>
<td width=5>
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
<tr>
<td width=10 height=26>
<td width=89 valgn=middle>
<table cellspacing=0 cellpadding=0 href="client:videocapture?notify=javascript%3ADoneSnapping()&device=video&width=100%25&height=100%25&name=cache%3Asnapshot.jpg&donebuttonlabel=Add%20to%20Message&open" id=addressbook>
<tr>
<td height=1>
<tr>
<td><shadow><font sizerange=medium color=#E6CD4A>Photo</font></shadow>
</table>
<td width=5>
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
<tr>
<td width=10 height=26>
<td width=89 valgn=middle>
<table cellspacing=0 cellpadding=0 href="client:soundcapture?notify=javascript%3ADoneGabbing()&device=audio&rate=8000&name=cache%3Avoicemail.wav&donebuttonlabel=Add%20to%20Message&open" id=addressbook>
<tr>
<td height=1>
<tr>
<td><shadow><font sizerange=medium color=#E6CD4A>Recording</font></shadow>
</table>
<td width=5>
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
<tr>
<td width=10 height=26>
<td width=89 valgn=middle>
<table cellspacing=0 cellpadding=0 href="client:showalert?sound=none&message=Are%20you%20sure%20you%20want%20to%20erase%20this%20entire%20message%3F&buttonlabel2=Don't%20Erase&buttonaction2=client:donothing&buttonlabel1=Erase&buttonaction1=wtv-mail:/sendmail%3Fclear%3Dtrue%26wtv-saved-message-id%3Dwritemessage-outbox" id=addressbook>
<tr>
<td height=1>
<tr>
<td><shadow><font sizerange=medium color=#E6CD4A>Erase</font></shadow>
</table>
<td width=5>
<tr> <td bgcolor=#4A525A height=2 width=104 colspan=3>
<tr>
<td width=10 height=26>
<td width=89 valgn=middle>
</table>
<td width=5 bgcolor=#5B6C81>
</table>
</sidebar>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td width=451 colspan=2 align=center bgcolor=#5B6C81>
<spacer type=vertical size=13>
<tr>
<td height=8 bgcolor=#171726 colspan=2>
<img src="wtv-mail:/content/images/CornerTop.gif" width=8 height=8>
<tr>
<td bgcolor=#171726 width=451 valign=top>
<table cellspacing=0 cellpadding=0 width=451>
<tr>
<td bgcolor=#171726 width=13>
<spacer type=horizontal size=13>
<td height=80>
<img src="wtv-mail:/content/images/Mail.gif" width=87 height=45>
<img src="wtv-mail:/content/images/${ssid_sessions[socket.ssid].mailstore.getMailboxIcon()}" width=74 height=45 transparency=60>
<td width=250 align=left><font sizerange=small>
</table>
<tr> <tr>
<td colspan=2 absheight=5>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=5>
<tr absheight=4>
<td colspan=2> <td colspan=2>
<img src="wtv-mail:/ROMCache/DottedLine.gif" width=386 height=2> <table cellspacing=0 cellpadding=0 bgcolor=#2C323D>
<tr> <tr>
<td colspan=2 absheight=5> <td width=451 absheight=25>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=5> <table cellspacing=0 cellpadding=0>
<tr height=30> <tr>
<td abswidth=80 valign=top align=right> <td width=13 absheight=25>
<a href="client:openaddresspanel"> <spacer type=horizontal size=13>
To:</a>&nbsp; <td width=370 maxlines=1>
<td abswidth=306> <font sizerange=medium color=#D6D6D6><blackface>
Write an e-mail message
</blackface></font>
<!--
<td width=21>
<img src="wtv-mail:/content/images/widget.gif" width=16 height=16 noprint>
<td width=36>
<spacer type=vertical size=1><br>
<a href="wtv-guide:/help?topic=Mail&subtopic=Index&appName=Mail" ><img src="wtv-mail:/content/images/mail_help_image.gif" width=35 height=17 noprint></a> -->
<td width=13>
<spacer type=horizontal size=13>
</table>
</table>
</table>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td bgcolor=#171726 width=13>
<spacer type=horizontal size=13>
<td bgcolor=#171726 width=438 valign=top>
<spacer type=vertical size=5><br>
<table cellspacing=0 cellpadding=0 bgcolor="#1F2033">
<tr>
<td absheight=2 colspan=5 bgcolor=#495360>
<tr>
<td abswidth=2 bgcolor=#495360>
<td absheight=13 colspan=3>
<td abswidth=2 bgcolor=#000000>
<tr>
<td abswidth=2 bgcolor=#495360>
<td abswidth=13>
<td abswidth=385>
<table cellspacing=0 cellpadding=0> <tr>
<td width=80 valign=top align=right>
<font color=#82A9D9>From:&nbsp;</font>
<td width=305 valign=top>
<font color=#82A9D9><table cellspacing=0 cellpadding=0 border=0>
<TR><TD maxlines="1">
${address}
</TD></TR>
</TABLE></font>
<font color=#82A9D9>(${userdisplayname})</font>
<tr>
<td height=13 valign=middle colspan=2>
<img src="wtv-mail:/content/images/sendmail_panel_dots.gif" width=385 height=2>
<tr>
<td width=80 valign=top align=right>
<a href="client:openaddresspanel">To:</a>&nbsp;
<td width=305 valign=top>
<textarea <textarea
bgcolor="242424" bgcolor="#1F2033"
cursor=#cc9933 cursor=#BDA73A
nosoftbreaks nosoftbreaks
borderimage="file://ROM/Borders/textfield.alt1.bif" borderimage="file://ROM/Borders/textfield.alt1.bif"
nohardbreaks nohardbreaks
selected selected
font=proportional font=proportional
text="42BD52" text=#82A9D9
name="message_to" name="message_to"
border=0 border=0
width=306 rows=1 width=305 rows=1
growable growable
autoactivate autoactivate
addresses addresses
@@ -403,29 +341,22 @@ autoascii
nohighlight nohighlight
>${(to_addr) ? to_addr : ''}</textarea> >${(to_addr) ? to_addr : ''}</textarea>
<tr> <tr>
<td colspan=2 absheight=5> <td height=13 valign=middle colspan=2>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=5> <img src="wtv-mail:/content/images/sendmail_panel_dots.gif" width=385 height=2>
<tr absheight=4>
<td colspan=2>
<img src="wtv-mail:/ROMCache/DottedLine.gif" width=386 height=2>
<tr> <tr>
<td colspan=2 absheight=5> <td abswidth=83 valign=top align=right>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=5> <font color=#82A9D9>Subject:&nbsp;</font>
<tr height=30> <td width=305 valign=top>
<td abswidth=80 valign=top align=right nowrap>
<font color="42BD52">
Subject:&nbsp;
<td abswidth=306>
<textarea <textarea
bgcolor="242424" bgcolor="#1F2033"
cursor=#cc9933 cursor=#BDA73A
nosoftbreaks nosoftbreaks
borderimage="file://ROM/Borders/textfield.alt1.bif" borderimage="file://ROM/Borders/textfield.alt1.bif"
nohardbreaks nohardbreaks
text="42BD52" text=#82A9D9
name="message_subject" font=proportional name="message_subject" font=proportional
border=0 border=0
width=306 rows=1 width=305 rows=1
growable growable
autoactivate autoactivate
maxlength=70 maxlength=70
@@ -433,52 +364,34 @@ nohighlight
autohiragana autohiragana
>${(msg_subject) ? msg_subject : ''}</textarea> >${(msg_subject) ? msg_subject : ''}</textarea>
<tr> <tr>
<td colspan=2 absheight=5> <td height=13 valign=middle colspan=2>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=5> <img src="wtv-mail:/content/images/sendmail_panel_dots.gif" width=385 height=2>
<tr absheight=4>
<td colspan=2>
<img src="wtv-mail:/ROMCache/DottedLine.gif" width=386 height=2>
<tr> <tr>
<td colspan=2 absheight=5> <td width=305 colspan=2>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=5>
<tr>
<td colspan=2 absheight=10>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=10>
<tr>
<td colspan=2 abswidth=386 !!xabswidth=386>
<textarea nosoftbreaks <textarea nosoftbreaks
bgcolor="242424" bgcolor="#1F2033"
text="42BD52" text=#82A9D9
cursor=#cc9933 cursor=#BDA73A
name="message_body" font=proportional name="message_body" font=proportional
border=0 border=0
rows=5 rows=4
width=386 width=386
nohighlight nohighlight
autoactivate autoactivate
growable>${(msg_body) ? msg_body : ''}</textarea> autohiragana
<input type=hidden name="no_signature" value="true"> growable
<tr> nextdown="Send">${(msg_body) ? msg_body : ''}</textarea>
<td colspan=2 absheight=8>
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=8>
</table> </table>
<table cellspacing=0 cellpadding=0> <body bgcolor=#1F2033
<tr> text=#82A9D9
<td rowspan=100 abswidth=10> link=#BDA73A
<img src="wtv-home:/ROMCache/Spacer.gif" width=10 height=2> vlink=#62B362
<td abswidth=422> vspace=0
<img src="wtv-mail:/ROMCache/PaperBase.gif" noprint hspace=0>`;
width=422 height=6> if (ssid_sessions[socket.ssid].getSessionData("subscriber_signature") && ssid_sessions[socket.ssid].getSessionData("subscriber_signature") != "" && !no_signature) {
<tr> data += `<embed src="wtv-mail:/get-signature" transparent>`;
<td absheight=6> }
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=6> data += `
</table>`;
if (!ssid_sessions[socket.ssid].getSessionData("subscriber_signature") || ssid_sessions[socket.ssid].getSessionData("subscriber_signature") == "") {
data += `<input type=hidden name="no_signature" value="true" ${(no_signature) ? 'checked="checked"' : ''}> <td abswidth=13>`;
} else {
data += `<input type=checkbox name="no_signature"> <td abswidth=13> Disable Signature`;
}
data += `
<td abswidth=2 bgcolor=#000000> <td abswidth=2 bgcolor=#000000>
<tr> <tr>
<td abswidth=2 bgcolor=#495360> <td abswidth=2 bgcolor=#495360>
@@ -493,7 +406,19 @@ width=422 height=6>
<spacer type=vertical size=5><br> <spacer type=vertical size=5><br>
<table cellspacing=0 cellpadding=0 border=0> <table cellspacing=0 cellpadding=0 border=0>
<tr> <tr>
<td width=305 valign=top> <td width=305 valign=top>`;
if (!ssid_sessions[socket.ssid].getSessionData("subscriber_signature") || ssid_sessions[socket.ssid].getSessionData("subscriber_signature") == "") {
data += `<input type = hidden name = "togglesign" value = "false"> <td abswidth=13 > `;
} else if (no_signature) {
data += `<a href="javascript:Signing('true')">
<img src="wtv-mail:/content/images/RemoveButton.gif" align=absmiddle height=25 width=25>&nbsp;Add signature&nbsp;</a>
<br>`;
} else {
data += `<a href="javascript:Signing('false')">
<img src="wtv-mail:/content/images/RemoveButton.gif" align=absmiddle height=25 width=25>&nbsp;Remove signature&nbsp;</a>
<br>`;
}
data += `
<td align=right valign=top width=110> <FONT COLOR="#E7CE4A"><SHADOW> <td align=right valign=top width=110> <FONT COLOR="#E7CE4A"><SHADOW>
<INPUT TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" action="javascript:Submit()" <INPUT TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" action="javascript:Submit()"
value="Send" value="Send"
@@ -505,10 +430,135 @@ USESTYLE NOARGS>
</SHADOW></FONT> </SHADOW></FONT>
</table> </table>
<spacer type=vertical size=5> <spacer type=vertical size=5>
`;
if ((request_headers.query.snapping && request_headers.query.snapping !== 'false') || message_snapshot_data) {
data += `<tr>
<td absheight="10">
<img src="wtv-star:/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">
</td><td colspan="9" abswidth="422" valign="bottom">
<img src="wtv-mail:/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">
</td><td rowspan="100" abswidth="14" absheight="0">
<img src="wtv-star:/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">
</td><td rowspan="100" abswidth="3" absheight="0" bgcolor="0b0b0b">
<img src="wtv-star:/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">
</td><td rowspan="100" abswidth="1" absheight="0" bgcolor="131313">
<img src="wtv-star:/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">
</td></tr><tr>
<td colspan="2" absheight="15">`;
if (!message_snapshot_data) {
data += `<input type="file" device="video" name="message_snapshot_data" src="cache:snapshot.jpg" invisible="" width="75%" height="75%">
<input type="hidden" name="message_snapshot_url" value="cache:snapshot.jpg">`;
}
data += `
</td></tr><tr>
<td colspan="2" align="center">
<img src="${(message_snapshot_data) ? 'wtv-mail:/sendmail?get_snap=true' : 'cache:snapshot.jpg'}>" width="380" height="290">
</td></tr><tr>
<td colspan="2" abswidth="386" absheight="10">
</td></tr><tr>
<td colspan="2">
<table width="386" cellspacing="0" cellpadding="0">
<tbody><tr><td valign="middle">
</td><td valign="middle" align="right">
<a href="javascript:ErasingMedia('snapping')">
&nbsp;Detach&nbsp;<img src="wtv-mail:/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">
</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">
</td><td abswidth="422">
<img src="wtv-mail:/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">
</td></tr>`;
}
if (request_headers.query.gabbing && request_headers.query.gabbing !== 'false') {
data += `<tr>
<td absheight="10">
<img src="wtv-star:/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">
</td><td colspan="9" abswidth="422" valign="bottom">
<img src="wtv-mail:/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">
</td><td rowspan="100" abswidth="14" absheight="0">
<img src="wtv-star:/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">
</td><td rowspan="100" abswidth="3" absheight="0" bgcolor="0b0b0b">
<img src="wtv-star:/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">
</td><td rowspan="100" abswidth="1" absheight="0" bgcolor="131313">
<img src="wtv-star:/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">
</td></tr><tr>
<td colspan="2" absheight="15">
<input type=file device=audio name=message_voicemail_data
src="cache:voicemail.wav" rate=8000 invisible>
${(message_voicemail_data) ? '' : '<input type=hidden name=message_voicemail_url value="cache:voicemail.wav">'}
</td></tr><tr>
<td colspan="2" align="center">
<table width=386 cellspacing=0 cellpadding=0>
<td align=left valign=middle>
<a href="${(message_voicemail_data) ? 'wtv-mail:/sendmail?get_gab=true' : 'cache:voicemail.wav'}" id=focus><img src="wtv-mail:/ROMCache/FileSound.gif" align=absmiddle></a>&nbsp;&nbsp;Recording
<td align=right valign=middle>
<a href="javascript:ErasingMedia('gabbing')">
&nbsp;Detach&nbsp;<img src="wtv-mail:/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">
</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">
</td><td abswidth="422">
<img src="wtv-mail:/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">
</td></tr>`;
}
data += `
</form> </form>
</tbody>
</table> </table>
</body> </body>
</HTML> </HTML>
`; `;
}
} }
} }

View File

@@ -2,6 +2,8 @@ const { lib } = require('crypto-js');
const CryptoJS = require('crypto-js'); const CryptoJS = require('crypto-js');
const WTVMail = require('./WTVMail.js') const WTVMail = require('./WTVMail.js')
const WTVSec = require('./WTVSec.js'); const WTVSec = require('./WTVSec.js');
class WTVClientSessionData { class WTVClientSessionData {
fs = require('fs'); fs = require('fs');
@@ -53,7 +55,6 @@ class WTVClientSessionData {
this.loginWhitelist.push("wtv-head-waiter:/password"); this.loginWhitelist.push("wtv-head-waiter:/password");
} }
assignMailStore() { assignMailStore() {
this.mailstore = new WTVMail(this.minisrv_config, this) this.mailstore = new WTVMail(this.minisrv_config, this)
} }
@@ -352,7 +353,7 @@ class WTVClientSessionData {
try { try {
if (this.fs.lstatSync(this.getUserStoreDirectory() + "user" + this.user_id + ".json")) { if (this.fs.lstatSync(this.getUserStoreDirectory() + "user" + this.user_id + ".json")) {
var json_data = this.fs.readFileSync(this.getUserStoreDirectory() + "user" + this.user_id + ".json", 'Utf8') var json_data = this.fs.readFileSync(this.getUserStoreDirectory() + "user" + this.user_id + ".json", 'Utf8')
if (raw_data) return json_data; if (raw_data) return JSON.parse(json_data);
var session_data = JSON.parse(json_data); var session_data = JSON.parse(json_data);
this.session_store = session_data; this.session_store = session_data;
@@ -400,13 +401,14 @@ class WTVClientSessionData {
return (password_valid); return (password_valid);
} }
saveSessionData(force_write = false) { saveSessionData(force_write = false, skip_merge = false) {
if (this.isRegistered()) { if (this.isRegistered()) {
// load data from disk and merge new data if (!skip_merge) {
var temp_store = this.session_store; // load data from disk and merge new data
if (this.loadSessionData()) this.session_store = Object.assign(this.session_store, temp_store); var temp_data = this.loadSessionData(true);
else this.session_store = temp_store; if (temp_data) this.session_store = Object.assign(temp_data, this.session_store);
temp_store = null; temp_data = null;
}
} else { } else {
// do not write file if user is not registered, return true because this is not an error // do not write file if user is not registered, return true because this is not an error
// force write needed to set the initial reg // force write needed to set the initial reg
@@ -439,8 +441,8 @@ class WTVClientSessionData {
return this.saveSessionData(force_write); return this.saveSessionData(force_write);
} }
SaveIfRegistered() { SaveIfRegistered(skip_merge = false) {
if (this.isRegistered()) return this.saveSessionData(); if (this.isRegistered()) return this.saveSessionData(false, skip_merge);
return false; return false;
} }
@@ -531,7 +533,7 @@ class WTVClientSessionData {
deleteSessionData(key) { deleteSessionData(key) {
if (key === null) throw ("ClientSessionData.delete(): invalid key provided"); if (key === null) throw ("ClientSessionData.delete(): invalid key provided");
delete this.session_store[key]; delete this.session_store[key];
this.SaveIfRegistered(); this.SaveIfRegistered(true);
} }
@@ -552,7 +554,7 @@ class WTVClientSessionData {
delete(key) { delete(key) {
if (key === null) throw ("ClientSessionData.delete(): invalid key provided"); if (key === null) throw ("ClientSessionData.delete(): invalid key provided");
delete this.data_store[key]; delete this.data_store[key];
this.SaveIfRegistered(); this.SaveIfRegistered(true);
} }
getBoxName() { getBoxName() {

View File

@@ -125,7 +125,7 @@ class WTVMail {
} }
createMessage(mailboxid, from_addr, to_addr, msgbody, subject = null, from_name = null, to_name = null, signature = null, date = null, known_sender = false) { createMessage(mailboxid, from_addr, to_addr, msgbody, subject = null, from_name = null, to_name = null, signature = null, date = null, known_sender = false, attachments = []) {
if (this.createMailbox(mailboxid)) { if (this.createMailbox(mailboxid)) {
if (!date) date = Math.floor(Date.now() / 1000); if (!date) date = Math.floor(Date.now() / 1000);
@@ -143,7 +143,8 @@ class WTVMail {
"body": msgbody, "body": msgbody,
"known_sender": known_sender, "known_sender": known_sender,
"signature": signature, "signature": signature,
"unread": true "unread": true,
"attachments": attachments
} }
try { try {
if (this.fs.existsSync(message_file_out)) { if (this.fs.existsSync(message_file_out)) {
@@ -194,6 +195,9 @@ class WTVMail {
message_data.message_file = message_file; message_data.message_file = message_file;
if (message_data) { if (message_data) {
message_data.id = messageid; message_data.id = messageid;
// backwards compat
if (!message_data.attachments) message_data.attachments = [];
return message_data; return message_data;
} }
else console.error(" # MailErr: could not parse json in ", message_file_in); else console.error(" # MailErr: could not parse json in ", message_file_in);
@@ -333,8 +337,8 @@ class WTVMail {
return false; return false;
} }
sendMessageToAddr(from_addr, to_addr, msgbody, subject = null, from_name = null, to_name = null, signature = null) { sendMessageToAddr(from_addr, to_addr, msgbody, subject = null, from_name = null, to_name = null, signature = null, attachments = []) {
if (!to_addr) return "You must type a destination address for your message."; if (!to_addr) return "Your message could not be sent.<p>You must specify an addressee in the <blackface>To:</blackface> area.";
if (to_addr.indexOf('@') === -1) to_addr += "@"+this.minisrv_config.config.service_name; if (to_addr.indexOf('@') === -1) to_addr += "@"+this.minisrv_config.config.service_name;
@@ -365,7 +369,7 @@ class WTVMail {
if (mailbox_exists) dest_user_mailstore.createWelcomeMessage(); if (mailbox_exists) dest_user_mailstore.createWelcomeMessage();
} }
// if the mailbox exists, deliver the message // if the mailbox exists, deliver the message
if (dest_user_mailstore.mailboxExists(0)) this.createMessage(0, from_addr, to_addr, msgbody, subject, from_name, to_name, signature); if (dest_user_mailstore.mailboxExists(0)) this.createMessage(0, from_addr, to_addr, msgbody, subject, from_name, to_name, signature, null, this.isInUserAddressBook(to_addr, from_addr), attachments);
else return "There was an internal error sending the message to <strong>" + to_addr + "</strong>. Please try again later"; else return "There was an internal error sending the message to <strong>" + to_addr + "</strong>. Please try again later";
// clean up // clean up
@@ -375,6 +379,11 @@ class WTVMail {
return "Unknown error"; return "Unknown error";
} }
isInUserAddressBook(address_to_check, address_to_look_for) {
// unimplemented
return false;
}
getMessageMailboxName(messageid) { getMessageMailboxName(messageid) {
// returns the mailbox id of which the message was found for the current user // returns the mailbox id of which the message was found for the current user
var self = this; var self = this;

View File

@@ -2,6 +2,7 @@
* Shared functions across all classes and apps * Shared functions across all classes and apps
*/ */
class WTVShared { class WTVShared {
path = require('path'); path = require('path');
@@ -22,6 +23,13 @@ class WTVShared {
} }
} }
isASCII(str) {
for (var i = 0, strLen = str.length; i < strLen; ++i) {
if (str.charCodeAt(i) > 127) return false;
}
return true;
}
returnAbsolutePath(check_path) { returnAbsolutePath(check_path) {
if (check_path.substring(0, 1) != this.path.sep && check_path.substring(1, 1) != ":") { if (check_path.substring(0, 1) != this.path.sep && check_path.substring(1, 1) != ":") {
// non-absolute path, so use current directory as base // non-absolute path, so use current directory as base
@@ -123,11 +131,44 @@ class WTVShared {
return new Date((new Date).getTime() + offset).toUTCString(); return new Date((new Date).getTime() + offset).toUTCString();
} }
urlEncodeBytes = (buf) => {
let encoded = ''
for (let i = 0; i < buf.length; i++) {
const charBuf = Buffer.from('00', 'hex')
charBuf.writeUInt8(buf[i])
const char = charBuf.toString()
// if the character is safe, then just print it, otherwise encode
if (isUrlSafe(char)) {
encoded += char
} else {
encoded += `%${charBuf.toString('hex').toUpperCase()}`
}
}
return encoded
}
urlDecodeBytes = (encoded) => {
let decoded = Buffer.from('')
for (let i = 0; i < encoded.length; i++) {
if (encoded[i] === '%') {
const charBuf = Buffer.from(`${encoded[i + 1]}${encoded[i + 2]}`, 'hex')
decoded = Buffer.concat([decoded, charBuf])
i += 2
} else {
const charBuf = Buffer.from(encoded[i])
decoded = Buffer.concat([decoded, charBuf])
}
}
return decoded
}
/** /**
* Returns a censored SSID * Returns a censored SSID
* @param {string|Array} obj SSID String or Headers Object * @param {string|Array} obj SSID String or Headers Object
*/ */
filterSSID(obj) { filterSSID(obj) {
var outobj = null;
if (this.minisrv_config.config.hide_ssid_in_logs === true) { if (this.minisrv_config.config.hide_ssid_in_logs === true) {
if (typeof (obj) == "string") { if (typeof (obj) == "string") {
if (obj.substr(0, 8) == "MSTVSIMU") { if (obj.substr(0, 8) == "MSTVSIMU") {
@@ -159,6 +200,11 @@ class WTVShared {
if (obj.post_data) { if (obj.post_data) {
obj.post_data = obj.post_data.toString(); obj.post_data = obj.post_data.toString();
} }
if (obj.query) {
obj.query = Object.assign({}, obj.query);
if (obj.query.message_snapshot_data) obj.query.message_snapshot_data = '(binary POST filtered, see post_data hex dump)'
if (obj.query.message_voicemail_data) obj.query.message_snapshot_data = '(binary POST filtered, see post_data hex dump)'
}
return obj; return obj;
} }

View File

@@ -315,10 +315,10 @@ async function processURL(socket, request_headers) {
if (request_headers['wtv-request-type']) socket_sessions[socket.id].wtv_request_type = request_headers['wtv-request-type']; if (request_headers['wtv-request-type']) socket_sessions[socket.id].wtv_request_type = request_headers['wtv-request-type'];
if (request_headers.post_data) { if (request_headers.post_data) {
var post_data_string = ''; var post_data_string = null;
try { try {
post_data_string = request_headers.post_data.toString(CryptoJS.enc.Utf8).replace("\0", ""); // if not text this will probably throw an exception post_data_string = request_headers.post_data.toString(CryptoJS.enc.Utf8); // if not text this will probably throw an exception
if (isUnencryptedString(post_data_string)) { if (post_data_string) {
if (post_data_string.indexOf('=')) { if (post_data_string.indexOf('=')) {
if (post_data_string.indexOf('&')) { if (post_data_string.indexOf('&')) {
var qraw = post_data_string.split('&'); var qraw = post_data_string.split('&');
@@ -327,7 +327,9 @@ async function processURL(socket, request_headers) {
var qraw_split = qraw[i].split("="); var qraw_split = qraw[i].split("=");
if (qraw_split.length == 2) { if (qraw_split.length == 2) {
var k = qraw_split[0]; var k = qraw_split[0];
request_headers.query[k] = unescape(qraw[i].split("=")[1].replace(/\+/g, "%20")); var data = unescape(qraw[i].split("=")[1].replace(/\+/g, "%20"));
if (wtvshared.isASCII(data)) request_headers.query[k] = data;
else request_headers.query[k] = wtvshared.urlDecodeBytes(qraw[i].split("=")[1].replace(/\+/g, "%20"));
} }
} }
} }
@@ -335,13 +337,15 @@ async function processURL(socket, request_headers) {
var qraw_split = post_data_string.split("="); var qraw_split = post_data_string.split("=");
if (qraw_split.length == 2) { if (qraw_split.length == 2) {
var k = qraw_split[0]; var k = qraw_split[0];
request_headers.query[k] = unescape(qraw_split[1].replace(/\+/g, "%20")); var data = unescape(qraw_split[1].replace(/\+/g, "%20"));
if (wtvshared.isASCII(data)) request_headers.query[k] = data;
else request_headers.query[k] = wtvshared.urlDecodeBytes(qraw_split[1].replace(/\+/g, "%20"));
} }
} }
} }
} }
} catch (e) { } catch (e) {
// do nothing console.log("error:",e)
} }
} }
@@ -424,7 +428,7 @@ Location: " + minisrv_config.config.unauthorized_url`;
// assume webtv since there is a :/ in the GET // assume webtv since there is a :/ in the GET
var service_name = shortURL.split(':/')[0]; var service_name = shortURL.split(':/')[0];
var urlToPath = wtvshared.fixPathSlashes(service_name + path.sep + shortURL.split(':/')[1]); var urlToPath = wtvshared.fixPathSlashes(service_name + 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(await wtvshared.filterSSID(request_headers)))); 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; socket_sessions[socket.id].request_headers = request_headers;
processPath(socket, urlToPath, request_headers, service_name); processPath(socket, urlToPath, request_headers, service_name);
} else if (shortURL.indexOf('http://') >= 0 || shortURL.indexOf('https://') >= 0) { } else if (shortURL.indexOf('http://') >= 0 || shortURL.indexOf('https://') >= 0) {
@@ -442,7 +446,7 @@ Location: " + minisrv_config.config.unauthorized_url`;
async function doHTTPProxy(socket, request_headers) { async function doHTTPProxy(socket, request_headers) {
var request_type = (request_headers.request_url.substring(0, 5) == "https") ? "https" : "http"; var request_type = (request_headers.request_url.substring(0, 5) == "https") ? "https" : "http";
if (minisrv_config.config.debug_flags.show_headers) console.log(request_type.toUpperCase() + " Proxy: Client Request Headers on socket ID", socket.id, (await wtvshared.decodePostData(await wtvshared.filterSSID(request_headers)))); if (minisrv_config.config.debug_flags.show_headers) console.log(request_type.toUpperCase() + " Proxy: Client Request Headers on socket ID", socket.id, (await wtvshared.decodePostData(wtvshared.filterSSID(Object.assign({}, request_headers)))));
switch (request_type) { switch (request_type) {
case "https": case "https":
var proxy_agent = https; var proxy_agent = https;
@@ -946,7 +950,7 @@ function moveObjectElement(currentKey, afterKey, obj) {
} }
function isUnencryptedString(string, verbose = false) { function isUnencryptedString(string) {
// a generic "isAscii" check is not sufficient, as the test will see the binary // a generic "isAscii" check is not sufficient, as the test will see the binary
// compressed / encrypted data as ASCII. This function checks for characters expected // compressed / encrypted data as ASCII. This function checks for characters expected
// in unencrypted headers, and returns true only if every character in the string matches // in unencrypted headers, and returns true only if every character in the string matches
@@ -1017,7 +1021,7 @@ async function processRequest(socket, data_hex, skipSecure = false, encryptedReq
} }
} }
} }
} }
if (!headers) return; if (!headers) return;

View File

@@ -1,12 +1,12 @@
{ {
"name": "zefie_wtvp_minisrv", "name": "zefie_wtvp_minisrv",
"version": "0.9.24", "version": "0.9.25",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "zefie_wtvp_minisrv", "name": "zefie_wtvp_minisrv",
"version": "0.9.24", "version": "0.9.25",
"license": "GPL3", "license": "GPL3",
"dependencies": { "dependencies": {
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",

View File

@@ -97,6 +97,12 @@
<Content Include="ServiceVault\wtv-home\Credits-Legal.js" /> <Content Include="ServiceVault\wtv-home\Credits-Legal.js" />
<Content Include="ServiceVault\wtv-home\Credits-Privacy.js" /> <Content Include="ServiceVault\wtv-home\Credits-Privacy.js" />
<Content Include="ServiceVault\wtv-mail\DiplomaMail.js" /> <Content Include="ServiceVault\wtv-mail\DiplomaMail.js" />
<Content Include="ServiceVault\wtv-mail\get-attachment.js">
<SubType>Code</SubType>
</Content>
<Content Include="ServiceVault\wtv-mail\get-signature.js">
<SubType>Code</SubType>
</Content>
<Content Include="ServiceVault\wtv-mail\listmail.js"> <Content Include="ServiceVault\wtv-mail\listmail.js">
<SubType>Code</SubType> <SubType>Code</SubType>
</Content> </Content>