[replace] if replace gets a POST with no replacement, show the ask-for-a-replacement page, see #1034

This commit is contained in:
Shish 2024-02-14 12:44:19 +00:00
parent 4e362d816f
commit f033efd456

View file

@ -22,6 +22,7 @@ class ReplaceFile extends Extension
$this->theme->display_replace_page($page, $image_id);
}
if ($event->page_matches("replace/{image_id}", method: "POST", permission: Permissions::REPLACE_IMAGE)) {
$image_id = $event->get_iarg('image_id');
$image = Image::by_id($image_id);
@ -29,6 +30,12 @@ class ReplaceFile extends Extension
throw new UploadException("Can not replace Post: No post with ID $image_id");
}
if(empty($event->get_POST("url")) && count($_FILES) == 0) {
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("replace/$image_id"));
return;
}
if (!empty($event->get_POST("url"))) {
$tmp_filename = shm_tempnam("transload");
fetch_url($event->req_POST("url"), $tmp_filename);