404 error if file not found or no title provided

This commit is contained in:
quenousimporte 2024-10-07 16:45:49 +02:00
parent 40a0a574a9
commit 2ba071e361
1 changed files with 7 additions and 1 deletions

View File

@ -48,7 +48,7 @@
// main
$title = '';
$content = '';
$content = false;
if (isset($_GET['new']))
{
$now = date("Y-m-d H.i.s", time());
@ -62,6 +62,12 @@
$content = file_get_contents($dir . '/' . $title . '.md');
}
if (!$content)
{
http_response_code(404);
die();
}
clearstatcache();
$lastchanged = filemtime($dir . '/' . $title . '.md');
$lines = substr_count($content, "\r\n");