init app
This commit is contained in:
commit
100ba92888
|
@ -0,0 +1,4 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
|
||||
</IfModule>
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
$password = '';
|
||||
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;
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>bnn</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: monospace;
|
||||
}
|
||||
textarea {
|
||||
height: 500px;
|
||||
width: 100%;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
outline: none;
|
||||
border: none;
|
||||
}
|
||||
input {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div><a href="bbn.php">View list</a> <a href="bbn.php?create=true">New note</a> | bbn</div>
|
||||
<br>
|
||||
<?php
|
||||
|
||||
$dir = '../data';
|
||||
|
||||
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'];
|
||||
unlink($dir . '/' . $title);
|
||||
}
|
||||
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);
|
||||
|
||||
echo '<form action="bbn.php" method="POST">
|
||||
<div>
|
||||
<input name="title" value="' . $title . '">
|
||||
<!--<input type="submit" name="deletebutton" value="delete">-->
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<textarea autofocus name="content" spellcheck="false">' . $content . '</textarea>
|
||||
</div>
|
||||
<input type="submit" name="savebutton" value="save" accesskey="s">
|
||||
</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($dh = opendir($dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if (str_ends_with($file, '.md'))
|
||||
{
|
||||
echo '<div><a href=bbn.php?open=' . urlencode($file) . '>' . $file .'</a></div>';
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue