From 6d87adb4d5414a0df0892d9599e9ceda405a189e Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Tue, 1 Oct 2024 09:21:11 +0200 Subject: [PATCH] open note if search is a perfect match on title --- index.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 3ab71dd..d53cce9 100644 --- a/index.php +++ b/index.php @@ -231,12 +231,20 @@ if (($_GET['param'] && isset($_GET['search'])) || isset($_GET['tags'])) { $content = file_get_contents($path . '.md'); - - if ((isset($_GET['search']) && !str_contains(strtolower($content), strtolower($param)) && !str_contains(strtolower($name), strtolower($param))) - || (isset($_GET['tags']) && !preg_match('/tags:.*' . $param . '/i', $content))) + if ( + // param does not match content or title + (isset($_GET['search']) && !str_contains(strtolower($content), strtolower($param)) && !str_contains(strtolower($name), strtolower($param))) || + // param does not match tags + (isset($_GET['tags']) && !preg_match('/tags:.*' . $param . '/i', $content)) + ) { continue; } + else if (isset($_GET['search']) && $param == $name) + { + header('Location: index.php?open=true¶m=' . urlencode($name)); + die(); + } } echo '
' . $name .''; if (isset($content) && isset($_GET['tags']))