bbn/index.php

67 lines
1.7 KiB
PHP

<?php
require('common.php');
if (isset($_GET['download']))
{
downloadall();
exit;
}
$filter = '';
if (isset($_GET['filter']))
{
$filter = $_GET['filter'];
}
?>
<!DOCTYPE html>
<html>
<head>
<title>bbn</title>
<link rel="manifest" href="manifest.json" />
<meta name="theme-color" content="white" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div>
<a href="note.php?new" class="grey" accesskey="n">new</a>
<a href="index.php?download" class="grey" accesskey="d">download</a>
<form action="index.php" method="GET" id="home">
<input hidden type="submit">
<input placeholder="filter..." autofocus autocomplete="off" class="title" name="filter" value="<?php echo $filter; ?>" form="home">
</form>
</div>
<div>
<?php
foreach($_SESSION['index'] as $path)
{
$name = basename($path);
if (str_ends_with($name, '.del'))
{
continue;
}
if ($filter)
{
$content = file_get_contents($path . '.md');
if (!str_contains(cleanstring($content), cleanstring($filter)) && !str_contains(cleanstring($name), cleanstring($filter)))
{
continue;
}
}
echo '<div><a href=note.php?title=' . urlencode($name) . '>' . $name .'</a>';
if ($filter && str_contains(cleanstring($content), cleanstring($filter)))
{
$pos = strpos(cleanstring($content), cleanstring($$filter));
echo '<span class="grey"> ' . $filter . substr($content, $pos + strlen($filter), 42) . '</span>';
}
echo'</div>';
}
?>
</div>
</body>
</html>