From e6c3f4fe5f308ca6ff56bb9c4fb28df0411fb0d3 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 29 Nov 2020 00:48:38 +0100 Subject: [PATCH] mail: primitive maildir message reader Minimal admin interface to access site emails; formatted similarly to issue page. --- mail/index.html | 3 ++ mail/index.php | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 mail/index.html create mode 100644 mail/index.php diff --git a/mail/index.html b/mail/index.html new file mode 100644 index 0000000..58e128c --- /dev/null +++ b/mail/index.html @@ -0,0 +1,3 @@ +

E-mails

+ +[[maillist]] diff --git a/mail/index.php b/mail/index.php new file mode 100644 index 0000000..76ec033 --- /dev/null +++ b/mail/index.php @@ -0,0 +1,75 @@ +title = 'Mailbericht ' . $head['date']->format('Y-m-d H:i'); + printf("

%s

\n", htmlspecialchars($head['Subject'] ?? 'Mailbericht zonder onderwerp')); + + print '
'; + printf('
Ontvangen:
%s
', $head['date']->format('c')); + printf('
Verzender:
%s
', htmlspecialchars($head['from'][0]['display'])); + print '
'; + + if (preg_match('{^text/plain}', $head['Content-Type'] ?? 'text/plain')) { + $body = $rawbody; + if (($head['Content-Transfer-Encoding'] ?? '') === 'quoted-printable') { + $body = quoted_printable_decode($body); + } + printf('
%s
', htmlspecialchars($body)); + } + else { + printf('

Geen ondersteuning voor %s.

', htmlspecialchars($head['Content-Type'])); + + /* TODO + $mime = mailparse_msg_parse_file($filename); + $part = mailparse_msg_get_part($mime, '1'); + mailparse_msg_extract_part_file($part, $filename); + */ + } + return; +} + +if (!$User->admin('user')) { + http_response_code(403); + $Place['warn'] = "Geen gebruikersrechten om e-mails in te zien."; + $Place['maillist'] = ''; + return TRUE; +} + +$rows = glob("$mailbox/*"); +if (!$rows) { + throw new Exception('Kon inbox niet openen.'); +} +array_splice($rows, 0, -50); + +ob_start(); +print '\n"; +$Place['maillist'] = ob_get_clean(); -- 2.30.0