diff options
Diffstat (limited to 'public/edit')
| -rw-r--r-- | public/edit/index.php | 16 | 
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'));  | 
