2024-02-13 22:57:28 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
2024-02-14 14:23:25 +01:00
|
|
|
<head>
|
|
|
|
<title>
|
|
|
|
<?php
|
2024-02-15 11:27:45 +01:00
|
|
|
if (isset($_GET['openaction']))
|
2024-02-14 14:23:25 +01:00
|
|
|
{
|
2024-02-15 11:27:45 +01:00
|
|
|
echo $_GET['userdata'];
|
2024-02-14 14:23:25 +01:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</title>
|
2024-02-14 18:22:26 +01:00
|
|
|
<meta name="theme-color" content="white" />
|
2024-02-14 14:23:25 +01:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<style type="text/css">
|
|
|
|
body {
|
|
|
|
font-family: helvetica;
|
|
|
|
}
|
|
|
|
textarea {
|
|
|
|
width: 100%;
|
|
|
|
border: none;
|
|
|
|
outline: none;
|
|
|
|
font-family: inherit;
|
|
|
|
font-size: inherit;
|
|
|
|
}
|
|
|
|
.title {
|
|
|
|
width: 100%;
|
|
|
|
border: none;
|
|
|
|
outline: none;
|
|
|
|
font-family: inherit;
|
|
|
|
font-size: inherit;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<?php
|
|
|
|
require 'settings.php';
|
2024-02-13 23:38:09 +01:00
|
|
|
|
2024-02-14 14:23:25 +01:00
|
|
|
if ($password && (!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 23:38:09 +01:00
|
|
|
|
2024-02-16 16:58:06 +01:00
|
|
|
echo '<div><a accesskey="h" href="' . $root . '">home</a></div><br>';
|
2024-02-15 11:27:45 +01:00
|
|
|
|
2024-02-16 17:35:06 +01:00
|
|
|
$action = '';
|
|
|
|
if (isset($_POST['action'])) $action = $_POST['action'];
|
|
|
|
else if (isset($_GET['action'])) $action = $_GET['action'];
|
|
|
|
|
|
|
|
$param = '';
|
|
|
|
if (isset($_GET['param'])) $param = $_GET['param'];
|
|
|
|
|
|
|
|
if ($action == 'save')
|
2024-02-14 14:23:25 +01:00
|
|
|
{
|
|
|
|
$title = $_POST['title'];
|
|
|
|
$content = $_POST['content'];
|
|
|
|
file_put_contents($dir . '/' . $title, $content);
|
2024-02-16 17:35:06 +01:00
|
|
|
$action = 'open';
|
|
|
|
$param = $title;
|
2024-02-14 14:23:25 +01:00
|
|
|
}
|
2024-02-16 17:35:06 +01:00
|
|
|
else if ($action == 'delete')
|
2024-02-14 14:23:25 +01:00
|
|
|
{
|
|
|
|
$title = $_POST['title'];
|
|
|
|
rename($dir . '/' . $title, $dir . '/' . $title . '.del');
|
|
|
|
}
|
2024-02-13 22:57:28 +01:00
|
|
|
|
2024-02-16 17:35:06 +01:00
|
|
|
if ($action == 'open')
|
2024-02-14 14:23:25 +01:00
|
|
|
{
|
2024-02-16 17:35:06 +01:00
|
|
|
$title = $param;
|
2024-02-14 08:41:48 +01:00
|
|
|
|
2024-02-14 14:23:25 +01:00
|
|
|
$content = '';
|
|
|
|
if (!file_exists($dir . '/' . $title))
|
|
|
|
{
|
|
|
|
file_put_contents($dir . '/' . $title, $content);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$content = file_get_contents($dir . '/' . $title);
|
|
|
|
}
|
2024-02-13 22:57:28 +01:00
|
|
|
|
2024-02-14 16:58:12 +01:00
|
|
|
$nblines = max(20, substr_count($content, "\r\n") + 1) * 2;
|
2024-02-14 08:54:24 +01:00
|
|
|
|
2024-02-14 14:23:25 +01:00
|
|
|
echo '<form action="index.php" method="POST">
|
2024-02-14 14:23:00 +01:00
|
|
|
<div>
|
2024-02-16 17:35:06 +01:00
|
|
|
<select name="action">
|
|
|
|
<option value="save">save</option>
|
|
|
|
<option value="delete">delete</option>
|
|
|
|
</select>
|
2024-02-16 17:55:21 +01:00
|
|
|
<input type="submit" name="go" value="go" accesskey="s">
|
2024-02-14 14:23:00 +01:00
|
|
|
</div>
|
|
|
|
<br>
|
2024-02-14 14:23:25 +01:00
|
|
|
<div><input class="title" name="title" value="' . $title . '"></div><br>
|
|
|
|
<div>
|
|
|
|
<textarea rows="' . $nblines. '" autofocus name="content" spellcheck="false">' . $content . '</textarea>
|
|
|
|
</div>
|
|
|
|
</form>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-02-16 16:58:06 +01:00
|
|
|
$defaulttitle = date("Y-m-d H.i.s", time());
|
2024-02-16 17:35:06 +01:00
|
|
|
if ($param)
|
2024-02-16 16:58:06 +01:00
|
|
|
{
|
2024-02-16 17:35:06 +01:00
|
|
|
$defaulttitle = $param;
|
2024-02-16 16:58:06 +01:00
|
|
|
}
|
2024-02-14 14:23:00 +01:00
|
|
|
echo '<form action="index.php" method="GET">
|
2024-02-16 17:35:06 +01:00
|
|
|
<input name="param" value="' . $defaulttitle . '">
|
|
|
|
<select name="action">
|
|
|
|
<option value="open">open</option>
|
|
|
|
<option value="filter">filter</option>
|
|
|
|
<option value="search">search</option>
|
|
|
|
</select>
|
2024-02-16 17:55:21 +01:00
|
|
|
<input accesskey="s" type="submit" value="go">
|
2024-02-14 14:23:00 +01:00
|
|
|
</form>';
|
2024-02-14 14:23:25 +01:00
|
|
|
echo '<br>';
|
2024-02-14 14:23:00 +01:00
|
|
|
|
2024-02-14 16:59:19 +01:00
|
|
|
$files = glob($dir . '/*');
|
|
|
|
usort($files, function($a, $b)
|
2024-02-14 14:23:00 +01:00
|
|
|
{
|
2024-02-14 16:59:19 +01:00
|
|
|
return filemtime($b) - filemtime($a);
|
|
|
|
});
|
|
|
|
|
|
|
|
foreach($files as $path)
|
|
|
|
{
|
2024-02-14 18:04:29 +01:00
|
|
|
$name = basename($path);
|
2024-02-15 11:27:45 +01:00
|
|
|
if (!str_ends_with($name, '.del')
|
2024-02-16 17:35:06 +01:00
|
|
|
&& ($action != 'filter' || str_contains($name, $param)))
|
2024-02-14 14:23:00 +01:00
|
|
|
{
|
2024-02-16 17:35:06 +01:00
|
|
|
if ($action == 'search')
|
2024-02-16 16:58:06 +01:00
|
|
|
{
|
|
|
|
$content = file_get_contents($path);
|
2024-02-16 17:35:06 +01:00
|
|
|
if (!str_contains($content, $param))
|
2024-02-16 16:58:06 +01:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2024-02-16 17:35:06 +01:00
|
|
|
echo '<div><a href=index.php?action=open¶m=' . urlencode($name) . '>' . $name .'</a></div>';
|
2024-02-14 14:23:25 +01:00
|
|
|
}
|
|
|
|
}
|
2024-02-14 14:23:00 +01:00
|
|
|
echo '<br>';
|
2024-02-14 14:23:25 +01:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</body>
|
2024-02-13 22:57:28 +01:00
|
|
|
</html>
|