change merge filter and search

This commit is contained in:
quenousimporte 2024-03-06 12:14:08 +01:00
parent cc57cbfab1
commit d31f834a1d
2 changed files with 5 additions and 10 deletions

View File

@ -2,7 +2,6 @@
<div>
<input type="submit" name="home" value="home" accesskey="h">
<input type="submit" name="open" value="open">
<input type="submit" name="filter" value="filter">
<input type="submit" name="search" value="search">
<input type="submit" name="tags" value="tags">
<input type="submit" name="clip" value="clip">

View File

@ -25,10 +25,6 @@
{
$action = 'open';
}
else if (isset($_GET['filter']))
{
$action = 'filter';
}
else if (isset($_GET['search']))
{
$action = 'search';
@ -181,14 +177,14 @@
{
$tags = '';
$name = basename($path);
if (!str_ends_with($name, '.del') && ($action != 'filter' || str_contains(strtolower($name), strtolower($param))))
if (!str_ends_with($name, '.del'))
{
if ($action == 'search' || $action == 'tags')
{
$content = file_get_contents($path);
if (($action == 'search' && !str_contains(strtolower($content), strtolower($param))) ||
($action == 'tags' && !preg_match('/tags:.*' . $param . '/i', $content)))
if (($action == 'search' && !str_contains(strtolower($content), strtolower($param)) && !str_contains(strtolower($name), strtolower($param)))
|| ($action == 'tags' && !preg_match('/tags:.*' . $param . '/i', $content)))
{
continue;
}
@ -210,10 +206,10 @@
echo '</span>';
}
}
else if ($action == 'search')
else if ($action == 'search' && str_contains(strtolower($content), strtolower($param)))
{
$pos = strpos(strtolower($content), strtolower($param));
echo '<span class="grey"> <b>' . $param . '</b>' . substr($content, $pos + strlen($param), 42) . '</span>';
echo '<span class="grey"> ' . $param . substr($content, $pos + strlen($param), 42) . '</span>';
}
echo'</div>';
}