Access denied.';
exit;
}
echo '
';
$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')
{
$title = $_POST['title'];
$content = $_POST['content'];
file_put_contents($dir . '/' . $title, $content);
$action = 'open';
$param = $title;
}
else if ($action == 'delete')
{
$title = $_POST['title'];
rename($dir . '/' . $title, $dir . '/' . $title . '.del');
}
if ($action == 'open')
{
$title = $param;
$content = '';
if (!file_exists($dir . '/' . $title))
{
file_put_contents($dir . '/' . $title, $content);
}
else
{
$content = file_get_contents($dir . '/' . $title);
}
$nblines = max(20, substr_count($content, "\r\n") + 1) * 2;
echo '';
}
else
{
$defaulttitle = date("Y-m-d H.i.s", time());
if ($param)
{
$defaulttitle = $param;
}
echo '';
echo '
';
$files = glob($dir . '/*');
usort($files, function($a, $b)
{
return filemtime($b) - filemtime($a);
});
foreach($files as $path)
{
$name = basename($path);
if (!str_ends_with($name, '.del')
&& ($action != 'filter' || str_contains($name, $param)))
{
if ($action == 'search')
{
$content = file_get_contents($path);
if (!str_contains($content, $param))
{
continue;
}
}
echo '';
}
}
echo '
';
}
?>