2024-02-13 22:57:28 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2024-02-13 23:43:20 +01:00
|
|
|
<title>
|
|
|
|
<?php
|
|
|
|
echo 'bbn';
|
|
|
|
if (isset($_GET['open']))
|
|
|
|
{
|
|
|
|
echo ' | ' . $_GET['open'];
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</title>
|
2024-02-13 22:57:28 +01:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
2024-02-13 23:38:09 +01:00
|
|
|
<meta charset="UTF-8">
|
2024-02-13 22:57:28 +01:00
|
|
|
<style type="text/css">
|
|
|
|
body {
|
2024-02-13 23:38:09 +01:00
|
|
|
font-family: helvetica;
|
2024-02-13 23:53:22 +01:00
|
|
|
color: rgb(55, 53, 47);
|
2024-02-13 22:57:28 +01:00
|
|
|
}
|
|
|
|
textarea {
|
|
|
|
height: 500px;
|
|
|
|
width: 100%;
|
|
|
|
font-family: inherit;
|
|
|
|
font-size: inherit;
|
|
|
|
outline: none;
|
|
|
|
border: none;
|
2024-02-13 23:53:22 +01:00
|
|
|
color: inherit;
|
2024-02-13 22:57:28 +01:00
|
|
|
}
|
|
|
|
input {
|
|
|
|
font-family: inherit;
|
|
|
|
font-size: inherit;
|
2024-02-13 23:53:22 +01:00
|
|
|
color: inherit;
|
2024-02-13 22:57:28 +01:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
2024-02-13 23:53:22 +01:00
|
|
|
<a accesskey="l" href="index.php">View list</a> <a accesskey="n" href="index.php?create=true">New note</a>
|
2024-02-13 22:57:28 +01:00
|
|
|
<?php
|
2024-02-13 23:38:09 +01:00
|
|
|
|
|
|
|
$password = '';
|
|
|
|
$dir = '../../data/bbn';
|
|
|
|
|
|
|
|
if (!isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != $password) {
|
|
|
|
header('WWW-Authenticate: Basic realm="bbn"');
|
|
|
|
header('HTTP/1.0 401 Unauthorized');
|
|
|
|
echo '<p>Access denied.</p>';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2024-02-13 22:57:28 +01:00
|
|
|
if (isset($_POST['savebutton']))
|
|
|
|
{
|
|
|
|
$title = $_POST['title'];
|
|
|
|
$content = $_POST['content'];
|
|
|
|
file_put_contents($dir . '/' . $title, $content);
|
|
|
|
$_GET['open'] = $title;
|
|
|
|
}
|
|
|
|
else if (isset($_POST['deletebutton']))
|
|
|
|
{
|
|
|
|
$title = $_POST['title'];
|
2024-02-13 23:17:10 +01:00
|
|
|
rename($dir . '/' . $title, $dir . '/' . $title . '.del');
|
2024-02-13 22:57:28 +01:00
|
|
|
}
|
|
|
|
else if (isset($_GET['create']))
|
|
|
|
{
|
|
|
|
$title = time() . '.md';
|
|
|
|
file_put_contents($dir . '/' . $title, '');
|
|
|
|
$_GET['open'] = $title;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_GET['open']))
|
|
|
|
{
|
|
|
|
$title = $_GET['open'];
|
|
|
|
$content = file_get_contents($dir . '/' . $title);
|
|
|
|
|
2024-02-13 23:53:22 +01:00
|
|
|
echo '<input form="note" name="title" value="' . $title . '">
|
|
|
|
<br><br>
|
|
|
|
<form id="note" action="index.php" method="POST">
|
2024-02-13 22:57:28 +01:00
|
|
|
<div>
|
|
|
|
<textarea autofocus name="content" spellcheck="false">' . $content . '</textarea>
|
|
|
|
</div>
|
|
|
|
<input type="submit" name="savebutton" value="save" accesskey="s">
|
2024-02-13 23:17:10 +01:00
|
|
|
<input accesskey="d" type="submit" name="deletebutton" value="delete">
|
2024-02-13 22:57:28 +01:00
|
|
|
</form>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-02-13 23:53:22 +01:00
|
|
|
echo '<br><br>';
|
2024-02-13 22:57:28 +01:00
|
|
|
if ($dh = opendir($dir)) {
|
|
|
|
while (($file = readdir($dh)) !== false) {
|
|
|
|
if (str_ends_with($file, '.md'))
|
|
|
|
{
|
2024-02-13 23:38:09 +01:00
|
|
|
$mod = date("F d Y H:i:s", filemtime($dir . '/' . $file));
|
|
|
|
echo '<div>' . $mod . ' <a href=index.php?open=' . urlencode($file) . '>' . $file .'</a></div>';
|
2024-02-13 22:57:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($dh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
</body>
|
|
|
|
</html>
|