';
$files = glob($dir . '/*');
usort($files, function($a, $b)
{
return filemtime($b) - filemtime($a);
});
foreach($files as $path)
{
$tags = '';
$name = basename($path);
if (!str_ends_with($name, '.del') && ($action != 'filter' || str_contains(strtolower($name), strtolower($param))))
{
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)))
{
continue;
}
}
echo '
' . $name .'';
if ($action == 'tags')
{
$tags = array();
$hastags = preg_match_all('/tags:(.*)/i', $content, $tags, PREG_SET_ORDER);
if ($hastags)
{
$tagslist = explode(',', $tags[0][1]);
echo '
';
foreach ($tagslist as $tag)
{
$tag = trim($tag);
echo('' . $tag . ' ');
}
echo '';
}
}
else if ($action == 'search')
{
$pos = strpos(strtolower($content), strtolower($param));
echo '
' . $param . '' . substr($content, $pos + strlen($param), 42) . '';
}
echo'
';
}
}
echo '
';
}
?>