X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/1900f80a9ab5fe401d6901b8e17ee82131b1170d..49b0543cfc5d8efe1a7d97181c500aef8aa488dd:/mail/index.php diff --git a/mail/index.php b/mail/index.php index b4846cc..ee7365a 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('

%s %s

'."\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 ($Page->api) { + 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 '\n"; + +print $Page->widget('nav', $nav); + $Page->place['maillist'] = ob_get_clean();