diff --git a/index.php b/index.php index cfd3a28..dd4b8e4 100644 --- a/index.php +++ b/index.php @@ -1,114 +1,114 @@ - - - <?php - echo 'bbn'; - if (isset($_GET['open'])) - { - echo ' | ' . $_GET['open']; - } - ?> - - - - - - - + + <?php + echo 'bbn'; + if (isset($_GET['open'])) + { + echo ' | ' . $_GET['open']; + } + ?> + + + + + + + Access denied.

'; - exit; - } + 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 '

Access denied.

'; + exit; + } - 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']; - rename($dir . '/' . $title, $dir . '/' . $title . '.del'); - } + 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']; + rename($dir . '/' . $title, $dir . '/' . $title . '.del'); + } - if (isset($_GET['open'])) - { - $title = $_GET['open']; + if (isset($_GET['open'])) + { + $title = $_GET['open']; - $content = ''; - if (!file_exists($dir . '/' . $title)) - { - file_put_contents($dir . '/' . $title, $content); - } - else - { - $content = file_get_contents($dir . '/' . $title); - } + $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); + $nblines = max(20, substr_count($content, "\r\n") + 1); - echo '
+ echo '

-

-
- -
-
'; - } - else - { +

+
+ +
+ '; + } + else + { echo '
'; - echo '
'; + echo '
'; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { - if (!str_ends_with($file, '.del') && $file != '.' && $file != '..') - { - $mod = date("F d Y H:i:s", filemtime($dir . '/' . $file)); - echo '
' . $mod . ' ' . $file .'
'; - } - } - closedir($dh); - } + if (!str_ends_with($file, '.del') && $file != '.' && $file != '..') + { + $mod = date("F d Y H:i:s", filemtime($dir . '/' . $file)); + echo '
' . $mod . ' ' . $file .'
'; + } + } + closedir($dh); + } echo '
'; - } + } - ?> - + ?> +