compare strings regardless of accents
This commit is contained in:
parent
630ac914b0
commit
dc9f01ea48
11
index.php
11
index.php
|
@ -21,6 +21,11 @@
|
||||||
$_SESSION['index'] = array_map(fn($value): string => str_replace('.md', '', $value), $files);
|
$_SESSION['index'] = array_map(fn($value): string => str_replace('.md', '', $value), $files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cleanstring($string)
|
||||||
|
{
|
||||||
|
return iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', strtolower($string));
|
||||||
|
}
|
||||||
|
|
||||||
function downloadnote($path)
|
function downloadnote($path)
|
||||||
{
|
{
|
||||||
header('Content-disposition: attachment; filename=' . basename($path));
|
header('Content-disposition: attachment; filename=' . basename($path));
|
||||||
|
@ -259,7 +264,7 @@
|
||||||
$content = file_get_contents($path . '.md');
|
$content = file_get_contents($path . '.md');
|
||||||
if (
|
if (
|
||||||
// param does not match content or title
|
// param does not match content or title
|
||||||
(isset($_GET['search']) && !str_contains(strtolower($content), strtolower($param)) && !str_contains(strtolower($name), strtolower($param))) ||
|
(isset($_GET['search']) && !str_contains(cleanstring($content), cleanstring($param)) && !str_contains(cleanstring($name), cleanstring($param))) ||
|
||||||
// param does not match tags
|
// param does not match tags
|
||||||
(isset($_GET['tags']) && !preg_match('/tags:.*' . $param . '/i', $content))
|
(isset($_GET['tags']) && !preg_match('/tags:.*' . $param . '/i', $content))
|
||||||
)
|
)
|
||||||
|
@ -289,9 +294,9 @@
|
||||||
echo '</span>';
|
echo '</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isset($_GET['search']) && str_contains(strtolower($content), strtolower($param)))
|
else if (isset($_GET['search']) && str_contains(cleanstring($content), cleanstring($param)))
|
||||||
{
|
{
|
||||||
$pos = strpos(strtolower($content), strtolower($param));
|
$pos = strpos(cleanstring($content), cleanstring($param));
|
||||||
echo '<span class="grey"> ' . $param . substr($content, $pos + strlen($param), 42) . '</span>';
|
echo '<span class="grey"> ' . $param . substr($content, $pos + strlen($param), 42) . '</span>';
|
||||||
}
|
}
|
||||||
echo'</div>';
|
echo'</div>';
|
||||||
|
|
Loading…
Reference in New Issue