Files
postfixadmin/public/common.php
T
vibpe 8d83e19773 Send the 419 status with a reason phrase so Apache does not answer 500 (4.0 backport) (#1213)
Backport of #1209 to `postfixadmin_4.0`, as asked for there. Refs #1208.

fix http 419 status header to include reason phrase.

thanks @vibpe
2026-11-20 13:51:54 +00:00

43 lines
1.5 KiB
PHP

<?php
require_once(dirname(__FILE__) . '/../common.php');
function pfa_handle_invalid_token(): void
{
// 419 is not a registered status code: without an explicit reason phrase
// Apache replaces the status line with "500 Internal Server Error".
// Always HTTP/1.1: mod_php only applies a status line starting with "HTTP/1.".
header('HTTP/1.1 419 Page Expired', true, 419);
$returnUrl = 'main.php';
$title = Config::lang('session_expired_title') ?: 'Session expired';
$message = Config::lang('session_expired_message') ?: 'The page token is no longer valid. Please return and try again.';
$button = Config::lang('session_expired_button') ?: 'Continue';
echo <<<HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{$title}</title>
<style>
body { font-family: Arial, sans-serif; margin: 0; background: #f6f7f9; color: #222; }
main { max-width: 520px; margin: 12vh auto; padding: 2rem; background: #fff; border: 1px solid #ddd; border-radius: .5rem; text-align: center; }
h1 { margin-top: 0; font-size: 1.5rem; }
p { line-height: 1.45; }
a { display: inline-block; margin-top: 1rem; padding: .65rem 1rem; background: #337ab7; color: #fff; text-decoration: none; border-radius: 4px; }
</style>
</head>
<body>
<main>
<h1>{$title}</h1>
<p>{$message}</p>
<a href="{$returnUrl}">{$button}</a>
</main>
</body>
</html>
HTML;
exit(0);
}