X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/1900f80a9ab5fe401d6901b8e17ee82131b1170d..8f4f651e106516ebc1b67e820da748de8311f8d8:/mail/index.php
diff --git a/mail/index.php b/mail/index.php
index b4846cc..2b6e600 100644
--- a/mail/index.php
+++ b/mail/index.php
@@ -2,6 +2,7 @@
$mailbox = 'mail/inbox';
@list ($msgid) = explode('/', ltrim($Page->path, '/'));
+if (!function_exists('parsemailhead')) {
function parsemailhead($headerdata)
{
$headlist = iconv_mime_decode_headers($headerdata, ICONV_MIME_DECODE_CONTINUE_ON_ERROR);
@@ -12,18 +13,27 @@ function parsemailhead($headerdata)
});
return $headlist;
}
+}
if ($msgid) {
$filename = "$mailbox/$msgid";
+ if (!is_readable($filename)) {
+ return TRUE;
+ }
+
list ($headerdata, $rawbody) = explode("\n\n", file_get_contents($filename), 2);
$head = parsemailhead($headerdata);
+ $head['date']->setTimezone(new DateTimeZone(date_default_timezone_get()));
$Page->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']));
+ printf(''."\n",
+ htmlspecialchars($head['From']),
+ htmlspecialchars(implode(', ', array_column($head['from'], 'display'))),
+ htmlspecialchars($head['Date']),
+ showdate(preg_split('/\D/', $head['date']->format('c')))
+ );
print '
';
if (preg_match('{^text/plain}', $head['Content-Type'] ?? 'text/plain')) {
@@ -45,6 +55,9 @@ if ($msgid) {
return;
}
+if (!$User) {
+ return;
+}
if (!$User->admin('user')) {
http_response_code(403);
$Page->place['warn'] = "Geen gebruikersrechten om e-mails in te zien.";
@@ -56,7 +69,13 @@ $rows = glob("$mailbox/*");
if (!$rows) {
throw new Exception('Kon inbox niet openen.');
}
-array_splice($rows, 0, -50);
+
+$nav = [
+ 'start' => $_GET['start'] ?? 0,
+ 'n' => $_GET['n'] ?? 10,
+ 'total' => count($rows),
+];
+$rows = array_slice(array_reverse($rows), $nav['start'], $nav['n']);
ob_start();
print '';
@@ -71,13 +90,18 @@ foreach (array_reverse($rows) as $filename) {
$head = parsemailhead($headerdata);
print $head['Subject'];
- printf(' %s',
+ printf(' %s',
+ htmlspecialchars($head['Date']),
showdate(explode('-', $head['date']->format('Y-m-d')))
);
- printf(' %s',
+ printf(' %s',
+ htmlspecialchars($head['From']),
htmlspecialchars(implode(', ', array_column($head['from'], 'display')))
);
print "\n";
}
print "
\n";
+
+print $Page->widget('nav', $nav);
+
$Page->place['maillist'] = ob_get_clean();