path, '/')); function parsemailhead($headerdata) { $headlist = iconv_mime_decode_headers($headerdata, ICONV_MIME_DECODE_CONTINUE_ON_ERROR); $headlist['date'] = DateTime::createFromFormat(DateTimeInterface::RFC2822.'+', $headlist['Date']); $headlist['from'] = mailparse_rfc822_parse_addresses($headlist['From']); //TODO: imap_rfc822_parse_adrlist() alternative return $headlist; } if ($msgid) { $filename = "$mailbox/$msgid"; list ($headerdata, $rawbody) = explode("\n\n", file_get_contents($filename), 2); $head = parsemailhead($headerdata); $Page->title = 'Mailbericht ' . $head['date']->format('Y-m-d H:i'); 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); $Page->place['warn'] = "Geen gebruikersrechten om e-mails in te zien."; $Page->place['maillist'] = ''; return TRUE; } $rows = glob("$mailbox/*"); if (!$rows) { throw new Exception('Kon inbox niet openen.'); } array_splice($rows, 0, -50); ob_start(); print '