summaryrefslogtreecommitdiff
path: root/public/edit/index.php
diff options
context:
space:
mode:
authorDavid T. Sadler <davidtsadler@googlemail.com>2021-10-13 21:51:07 +0100
committerDavid T. Sadler <davidtsadler@googlemail.com>2021-10-13 21:51:07 +0100
commitcbaedbc5251f3b127bd81242d1344c0cd3e56e0c (patch)
treef76273742992d8f06983fd5d6fef37efc85a2c07 /public/edit/index.php
parent2ab5661583d74b03c86bb4f437616bb634d9c4fc (diff)
Implemente redirects
Diffstat (limited to 'public/edit/index.php')
-rw-r--r--public/edit/index.php16
1 files changed, 8 insertions, 8 deletions
diff --git a/public/edit/index.php b/public/edit/index.php
index 65b3fa5..9d3d4c0 100644
--- a/public/edit/index.php
+++ b/public/edit/index.php
@@ -10,20 +10,20 @@ require_once(__DIR__.'/../../autoload.php');
$config = require_once(__DIR__.'/../../config.php');
+if (filter_input(INPUT_SERVER, 'REQUEST_METHOD') !== 'GET') {
+ respondAndExit(405, 'Method Not Allowed');
+}
+
+$id = filter_input(INPUT_GET, 'id');
+
$bookmarks = new BookmarkRepository($config['path_to_repository']);
$template = new Template($config['path_to_templates']);
-$id = filter_input(INPUT_GET, 'id') ?? filter_input(INPUT_POST, 'id') ?? null;
-
$bookmark = $bookmarks->find($id);
-if ('POST' === filter_input(INPUT_SERVER, 'REQUEST_METHOD')) {
- $bookmark->url = $_POST['url'];
- $bookmark->title = $_POST['title'];
- $bookmark->tag = $_POST['tag'];
-
- $bookmarks->update($bookmark);
+if ($bookmark === null) {
+ respondAndExit(404, 'Not Found');
}
$html = $template->render('edit', compact('bookmark'));