From 40a0a574a9afe55bca6e566f16b7fc2e957c3cef Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Mon, 7 Oct 2024 16:26:16 +0200 Subject: [PATCH] various fix --- common.php | 16 +++++----------- index.php | 1 + note.php | 14 +++++++------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/common.php b/common.php index b8c41b1..9eede57 100644 --- a/common.php +++ b/common.php @@ -21,10 +21,6 @@ { $zip->addFile($path, basename($path)); } - else - { - echo"file does not exist"; - } } } $zip->close(); @@ -34,24 +30,22 @@ readfile($zip_name); unlink($zip_name); - exit; } function savenote($title, $content) { global $dir; $path = $dir . '/' . $title; - $lastchanged = filemtime($path); + $lastchanged = filemtime($path . '.md'); $previous = $_POST['lastchanged']; if ((int)$lastchanged > (int)$previous) { $tempcontent = file_get_contents($path . '.md'); if ($tempcontent != $content) { - $temptitle = $title . '_' . $lastchanged; + $temptitle = $title . '_conflict_' . $lastchanged; file_put_contents($dir . '/' . $temptitle . '.md', $tempcontent); array_unshift($_SESSION['index'], $dir . '/' . $temptitle); - echo '
Conflict detected. See backup: ' . $temptitle . '
'; } } file_put_contents($path . '.md', $content); @@ -74,7 +68,6 @@ header('Content-disposition: attachment; filename=' . basename($path)); header('Content-type: text/markdown'); readfile($path); - exit; } function linksdiv($content) @@ -118,8 +111,9 @@ return $preview; } - // Main - if ($password && (!isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != $password)) { + // authent + 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.

'; diff --git a/index.php b/index.php index 9b137ad..af615b2 100644 --- a/index.php +++ b/index.php @@ -4,6 +4,7 @@ if (isset($_GET['download'])) { downloadall(); + exit; } $filter = ''; diff --git a/note.php b/note.php index da6de10..de79d5e 100644 --- a/note.php +++ b/note.php @@ -4,8 +4,7 @@ // handle save actions $title = $_POST['title']; $content = $_POST['content']; - - if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['download'])) + if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['download']) || isset($_POST['preview'])) { savenote($title, $content); @@ -19,12 +18,18 @@ if (isset($_POST['download'])) { downloadnote($dir . '/' . $title . '.md'); + exit; } else if (isset($_POST['home'])) { header("Location: index.php"); exit; } + else if (isset($_POST['preview'])) + { + header("Location: note.php?preview=1&title=" . $title); + exit; + } else { header("Location: note.php?title=" . $title); @@ -39,11 +44,6 @@ header("Location: index.php"); exit; } - else if (isset($_POST['preview'])) - { - header("Location: note.php?preview=1&title=" . $title); - exit; - } // main