From f033efd456da0cd104ff02c14cef7d9b52f3290c Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 14 Feb 2024 12:44:19 +0000 Subject: [PATCH] [replace] if replace gets a POST with no replacement, show the ask-for-a-replacement page, see #1034 --- ext/replace_file/main.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ext/replace_file/main.php b/ext/replace_file/main.php index 860c40df..d29be4d7 100644 --- a/ext/replace_file/main.php +++ b/ext/replace_file/main.php @@ -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);