space to tab

This commit is contained in:
quenousimporte 2024-02-14 14:23:25 +01:00
parent 32bd95e372
commit 975dd9f38c
1 changed files with 88 additions and 88 deletions

176
index.php
View File

@ -1,114 +1,114 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title> <title>
<?php <?php
echo 'bbn'; echo 'bbn';
if (isset($_GET['open'])) if (isset($_GET['open']))
{ {
echo ' | ' . $_GET['open']; echo ' | ' . $_GET['open'];
} }
?> ?>
</title> </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta charset="UTF-8"> <meta charset="UTF-8">
<style type="text/css"> <style type="text/css">
body { body {
font-family: helvetica; font-family: helvetica;
} }
textarea { textarea {
width: 100%; width: 100%;
border: none; border: none;
outline: none; outline: none;
font-family: inherit; font-family: inherit;
font-size: inherit; font-size: inherit;
} }
.title { .title {
width: 100%; width: 100%;
border: none; border: none;
outline: none; outline: none;
font-family: inherit; font-family: inherit;
font-size: inherit; font-size: inherit;
font-weight: bold; font-weight: bold;
} }
</style> </style>
</head> </head>
<body> <body>
<?php <?php
require 'settings.php'; require 'settings.php';
if ($password && (!isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != $password)) { if ($password && (!isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != $password)) {
header('WWW-Authenticate: Basic realm="bbn"'); header('WWW-Authenticate: Basic realm="bbn"');
header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.0 401 Unauthorized');
echo '<p>Access denied.</p>'; echo '<p>Access denied.</p>';
exit; exit;
} }
if (isset($_POST['savebutton'])) if (isset($_POST['savebutton']))
{ {
$title = $_POST['title']; $title = $_POST['title'];
$content = $_POST['content']; $content = $_POST['content'];
file_put_contents($dir . '/' . $title, $content); file_put_contents($dir . '/' . $title, $content);
$_GET['open'] = $title; $_GET['open'] = $title;
} }
else if (isset($_POST['deletebutton'])) else if (isset($_POST['deletebutton']))
{ {
$title = $_POST['title']; $title = $_POST['title'];
rename($dir . '/' . $title, $dir . '/' . $title . '.del'); rename($dir . '/' . $title, $dir . '/' . $title . '.del');
} }
if (isset($_GET['open'])) if (isset($_GET['open']))
{ {
$title = $_GET['open']; $title = $_GET['open'];
$content = ''; $content = '';
if (!file_exists($dir . '/' . $title)) if (!file_exists($dir . '/' . $title))
{ {
file_put_contents($dir . '/' . $title, $content); file_put_contents($dir . '/' . $title, $content);
} }
else else
{ {
$content = file_get_contents($dir . '/' . $title); $content = file_get_contents($dir . '/' . $title);
} }
$nblines = max(20, substr_count($content, "\r\n") + 1); $nblines = max(20, substr_count($content, "\r\n") + 1);
echo '<form action="index.php" method="POST"> echo '<form action="index.php" method="POST">
<div> <div>
<input accesskey="h" type="submit" name="homebutton" value="home"> <input accesskey="h" type="submit" name="homebutton" value="home">
<input type="submit" name="savebutton" value="save" accesskey="s"> <input type="submit" name="savebutton" value="save" accesskey="s">
<input accesskey="d" type="submit" name="deletebutton" value="delete"> <input accesskey="d" type="submit" name="deletebutton" value="delete">
</div> </div>
<br> <br>
<div><input class="title" name="title" value="' . $title . '"></div><br> <div><input class="title" name="title" value="' . $title . '"></div><br>
<div> <div>
<textarea rows="' . $nblines. '" autofocus name="content" spellcheck="false">' . $content . '</textarea> <textarea rows="' . $nblines. '" autofocus name="content" spellcheck="false">' . $content . '</textarea>
</div> </div>
</form>'; </form>';
} }
else else
{ {
echo '<form action="index.php" method="GET"> echo '<form action="index.php" method="GET">
<input accesskey="n" type="submit" value="create new"> <input accesskey="n" type="submit" value="create new">
<input name="open" value="' . time() . '"> <input name="open" value="' . time() . '">
</form>'; </form>';
echo '<br>'; echo '<br>';
if ($dh = opendir($dir)) if ($dh = opendir($dir))
{ {
while (($file = readdir($dh)) !== false) while (($file = readdir($dh)) !== false)
{ {
if (!str_ends_with($file, '.del') && $file != '.' && $file != '..') if (!str_ends_with($file, '.del') && $file != '.' && $file != '..')
{ {
$mod = date("F d Y H:i:s", filemtime($dir . '/' . $file)); $mod = date("F d Y H:i:s", filemtime($dir . '/' . $file));
echo '<div>' . $mod . '&nbsp;<a href=index.php?open=' . urlencode($file) . '>' . $file .'</a></div>'; echo '<div>' . $mod . '&nbsp;<a href=index.php?open=' . urlencode($file) . '>' . $file .'</a></div>';
} }
} }
closedir($dh); closedir($dh);
} }
echo '<br>'; echo '<br>';
} }
?> ?>
</body> </body>
</html> </html>