Skip to content

Commit 5402f59

Browse files
committed
clear output buffer before echoing err msg, write error to log with a timestamp
1 parent 3d0142a commit 5402f59

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
* @license MIT public license
77
*/
88

9-
set_exception_handler(fn() => exit('<style>body{font-family:monospace;color:#fff;font-size:2em;background:#444;padding:5em;text-align:center}</style>
10-
<p>⚠<br>Something went wrong while showing this page<br>Contact the site admin for assistance</p>'));
9+
set_exception_handler(function (Throwable $ex) {
10+
ob_clean();
11+
error_log("[" . date('r') . "] {$ex->getMessage()}: {$ex->getTraceAsString()}");
12+
exit('<style>body{font-family:monospace;color:#fff;font-size:2em;background:#444;padding:5em;text-align:center}</style>
13+
<p>⚠<br>Something went wrong while showing this page<br>Contact the site admin for assistance</p>');
14+
});
1115
require 'config.php';
1216
date_default_timezone_set($timezone ?? 'America/New_York');
1317
$uri = parse_url(rtrim($_SERVER['REQUEST_URI'], '/') ?: '/', PHP_URL_PATH);

0 commit comments

Comments
 (0)