bbn/index.php

68 lines
1.7 KiB
PHP
Raw Normal View History

2024-09-30 10:09:49 +02:00
<?php
2024-10-07 16:06:35 +02:00
require('common.php');
2024-09-30 10:09:49 +02:00
if (isset($_GET['download']))
{
2024-10-02 11:49:15 +02:00
downloadall();
2024-10-07 16:26:16 +02:00
exit;
2024-09-30 10:09:49 +02:00
}
2024-10-01 10:51:28 +02:00
2024-10-07 16:06:35 +02:00
$filter = '';
if (isset($_GET['filter']))
2024-10-01 10:51:28 +02:00
{
2024-10-07 16:06:35 +02:00
$filter = $_GET['filter'];
2024-10-07 09:08:38 +02:00
}
2024-09-30 10:09:49 +02:00
?>
<!DOCTYPE html>
<html>
<head>
2024-10-07 16:06:35 +02:00
<title>bbn</title>
2024-09-30 10:09:49 +02:00
<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>
2024-10-07 16:06:35 +02:00
<div>
2024-10-08 13:11:32 +02:00
<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>
2024-10-07 16:06:35 +02:00
</div>
<div>
2024-09-30 10:09:49 +02:00
<?php
2024-10-07 16:06:35 +02:00
foreach($_SESSION['index'] as $path)
{
2024-10-07 16:06:35 +02:00
$name = basename($path);
2024-10-10 10:22:32 +02:00
if (str_ends_with($name, '.del'))
{
continue;
}
2024-10-07 16:06:35 +02:00
if ($filter)
2024-03-06 11:53:57 +01:00
{
2024-10-07 16:06:35 +02:00
$content = file_get_contents($path . '.md');
if (!str_contains(cleanstring($content), cleanstring($filter)) && !str_contains(cleanstring($name), cleanstring($filter)))
2024-03-06 11:53:57 +01:00
{
2024-10-07 16:06:35 +02:00
continue;
2024-03-06 11:53:57 +01:00
}
}
2024-10-07 16:06:35 +02:00
echo '<div><a href=note.php?title=' . urlencode($name) . '>' . $name .'</a>';
if ($filter && str_contains(cleanstring($content), cleanstring($filter)))
{
2024-10-10 10:47:54 +02:00
$pos = strpos(cleanstring($content), cleanstring($filter));
2024-10-07 16:06:35 +02:00
echo '<span class="grey"> ' . $filter . substr($content, $pos + strlen($filter), 42) . '</span>';
}
echo'</div>';
2024-02-14 14:23:25 +01:00
}
?>
2024-10-07 16:06:35 +02:00
</div>
2024-02-14 14:23:25 +01:00
</body>
2024-10-10 10:47:54 +02:00
</html>