diff --git a/index.php b/index.php index d53cce9..09505a9 100644 --- a/index.php +++ b/index.php @@ -117,12 +117,74 @@ download(); } + $preview = ''; + if (isset($_GET['clip']) && $_GET['param']) + { + $content = $_GET['param'] . "\r\n" . file_get_contents($dir . '/todo.md'); + savenote('todo', $content); + $_GET['param'] = ''; + } + else if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['links']) || isset($_POST['stats'])) + { + $title = $_POST['title']; + $content = $_POST['content']; + savenote($title, $content); + + $previoustitle = $_POST['previoustitle']; + if ($title != $previoustitle) + { + rename($dir . '/' . $previoustitle . '.md', $dir . '/' . $previoustitle . '.md.del'); + removefromindex($previoustitle); + } + + if (!isset($_POST['home'])) + { + $nextpage = 'note'; + } + } + else if (isset($_POST['delete'])) + { + $title = $_POST['title']; + rename($dir . '/' . $title . '.md', $dir . '/' . $title . '.md.del'); + removefromindex($title); + } + else if (isset($_POST['preview'])) + { + require 'libs/Parsedown.php'; + $title = $_POST['title']; + $content = $_POST['content']; + $pos = 0; + if (str_starts_with($content, '---')) + { + $pos = strpos($content, '---', 3) + 3; + } + $Parsedown = new Parsedown(); + $Parsedown->setBreaksEnabled(true); + $preview = $Parsedown->text('# ' . $title . "\r\n" . substr($content, $pos)); + $nextpage = 'preview'; + } + else if (isset($_GET['open'])) + { + $nextpage = 'note'; + $title = $_GET['param']; + } ?>
-