';
				if (!isset($_SESSION['index']) || isset($_GET['reindex']))
				{
					$files = glob($dir . '/*');
					usort($files, function($a, $b)
					{
						return filemtime($b) - filemtime($a);
					});
					$_SESSION['index'] = $files;
				}
				foreach($_SESSION['index'] as $path)
				{
					$tags = '';
					$name = basename($path);
					if (!str_ends_with($name, '.del'))
					{
						if ($_GET['param'] && (isset($_GET['search']) || isset($_GET['tags'])))
						{
							$content = file_get_contents($path);
							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)))
							{
								continue;
							}
						}
						echo '
' . $name .'';
						if (isset($content) && isset($_GET['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 (isset($_GET['search']) && str_contains(strtolower($content), strtolower($param)))
						{
							$pos = strpos(strtolower($content), strtolower($param));
							echo '
 ' . $param . substr($content, $pos + strlen($param), 42) . '';
						}
						echo'
 ';
					}
				}
				echo '
 ';
			}
		?>