From 2ba071e3616cce7be3dddf9f12cd7875b7d89785 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Mon, 7 Oct 2024 16:45:49 +0200 Subject: [PATCH] 404 error if file not found or no title provided --- note.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/note.php b/note.php index de79d5e..5b7e362 100644 --- a/note.php +++ b/note.php @@ -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");