change no authent if no password
change create note if not exists change labels
This commit is contained in:
parent
a1d7e8ffc1
commit
ee9428a6fe
21
index.php
21
index.php
|
@ -34,18 +34,18 @@
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<a accesskey="l" href="index.php">View list</a> <a accesskey="n" href="index.php?create=true">New note</a>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require 'settings.php';
|
require 'settings.php';
|
||||||
|
|
||||||
if (!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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo '<a accesskey="l" href="index.php">List</a> <a accesskey="n" href="index.php?open=' . time() . '.md">New</a>';
|
||||||
|
|
||||||
if (isset($_POST['savebutton']))
|
if (isset($_POST['savebutton']))
|
||||||
{
|
{
|
||||||
$title = $_POST['title'];
|
$title = $_POST['title'];
|
||||||
|
@ -58,17 +58,20 @@
|
||||||
$title = $_POST['title'];
|
$title = $_POST['title'];
|
||||||
rename($dir . '/' . $title, $dir . '/' . $title . '.del');
|
rename($dir . '/' . $title, $dir . '/' . $title . '.del');
|
||||||
}
|
}
|
||||||
else if (isset($_GET['create']))
|
|
||||||
{
|
|
||||||
$title = time() . '.md';
|
|
||||||
file_put_contents($dir . '/' . $title, '');
|
|
||||||
$_GET['open'] = $title;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_GET['open']))
|
if (isset($_GET['open']))
|
||||||
{
|
{
|
||||||
$title = $_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 = file_get_contents($dir . '/' . $title);
|
||||||
|
}
|
||||||
|
|
||||||
echo '<form action="index.php" method="POST">
|
echo '<form action="index.php" method="POST">
|
||||||
<br><div><input name="title" value="' . $title . '"></div><br>
|
<br><div><input name="title" value="' . $title . '"></div><br>
|
||||||
|
|
Loading…
Reference in New Issue