Handle 404s on feed edit page (#4)

This commit is contained in:
Daniel J. Summers 2024-04-12 07:27:19 -04:00
parent da9a569e4a
commit 480228013c

View File

@ -25,19 +25,24 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$feedId = $isNew ? $result['ok'] : $_POST['id']; $feedId = $isNew ? $result['ok'] : $_POST['id'];
} else { } else {
add_error($result['error']); add_error($result['error']);
$feedId = 'error';
} }
} }
if ($feedId == 'new') { if ($feedId == 'new') {
$feed = [ 'id' => $_GET['id'], 'url' => '' ];
$title = 'Add RSS Feed'; $title = 'Add RSS Feed';
$feed = [ 'id' => $_GET['id'], 'url' => '' ];
} else { } else {
$feed = Data::retrieveFeedById((int) $feedId, $db);
if (!$feed) {
http_response_code(404);
die();
}
$title = 'Edit RSS Feed'; $title = 'Edit RSS Feed';
if ($feedId == 'error') {
$feed = ['id' => $_POST['id'] ?? '', 'url' => $_POST['url'] ?? ''];
} else {
$feed = Data::retrieveFeedById((int) $feedId, $db);
if (!$feed) {
http_response_code(404);
die();
}
}
} }
page_head($title); ?> page_head($title); ?>