From 1fc75c0b18baa096c79a656b42a4c86ed43f40d2 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 23 Mar 2020 00:06:43 +0000 Subject: [PATCH] Whenever we display an image for any reason, show the admin block, fixes #621 --- core/imageboard/tag.php | 4 +++- core/install.php | 3 ++- core/userclass.php | 2 +- ext/et_server/main.php | 8 +++----- ext/ipban/main.php | 4 +++- ext/view/main.php | 12 +++++++----- themes/rule34v2/user.theme.php | 1 - 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/core/imageboard/tag.php b/core/imageboard/tag.php index 5db83ffd..6b10de46 100644 --- a/core/imageboard/tag.php +++ b/core/imageboard/tag.php @@ -93,7 +93,9 @@ class Tag $tag = preg_replace("/^(\.+[\/\\\\])+/", "", $tag); # trailing slashes? $tag = trim($tag, ", \t\n\r\0\x0B"); - if($tag == ".") $tag = ""; // hard-code one bad case... + if ($tag == ".") { + $tag = ""; + } // hard-code one bad case... if (mb_strlen($tag, 'UTF-8') > 255) { throw new ScoreException("The tag below is longer than 255 characters, please use a shorter tag.\n$tag\n"); diff --git a/core/install.php b/core/install.php index 66668bba..4175e305 100644 --- a/core/install.php +++ b/core/install.php @@ -59,7 +59,8 @@ function install() function get_dsn() { if (getenv("INSTALL_DSN")) { - $dsn = getenv("INSTALL_DSN");; + $dsn = getenv("INSTALL_DSN"); + ; } elseif (@$_POST["database_type"] == DatabaseDriver::SQLITE) { /** @noinspection PhpUnhandledExceptionInspection */ $id = bin2hex(random_bytes(5)); diff --git a/core/userclass.php b/core/userclass.php index d2bd6ed9..4c9c4e0f 100644 --- a/core/userclass.php +++ b/core/userclass.php @@ -68,7 +68,7 @@ class UserClass } $_all_false = []; -foreach((new ReflectionClass('Permissions'))->getConstants() as $k => $v) { +foreach ((new ReflectionClass('Permissions'))->getConstants() as $k => $v) { $_all_false[$v] = false; } new UserClass("base", null, $_all_false); diff --git a/ext/et_server/main.php b/ext/et_server/main.php index 08afefde..97c2726b 100644 --- a/ext/et_server/main.php +++ b/ext/et_server/main.php @@ -9,7 +9,7 @@ class ETServer extends Extension global $database, $page, $user; if ($event->page_matches("register.php")) { error_log("register.php"); - if(isset($_POST["data"])) { + if (isset($_POST["data"])) { $database->execute( "INSERT INTO registration(data) VALUES(:data)", ["data"=>$_POST["data"]] @@ -17,13 +17,11 @@ class ETServer extends Extension $page->set_title("Thanks!"); $page->set_heading("Thanks!"); $page->add_block(new Block("Thanks!", "Your data has been recorded~")); - - } - elseif ($user->can(Permissions::VIEW_REGISTRATIONS)) { + } elseif ($user->can(Permissions::VIEW_REGISTRATIONS)) { $page->set_title("Registrations"); $page->set_heading("Registrations"); $n = 0; - foreach($database->get_all("SELECT responded, data FROM registration ORDER BY responded DESC") as $row) { + foreach ($database->get_all("SELECT responded, data FROM registration ORDER BY responded DESC") as $row) { $page->add_block(new Block( $row["responded"], (string)PRE(["style"=>"text-align: left; overflow: scroll;"], $row["data"]), diff --git a/ext/ipban/main.php b/ext/ipban/main.php index c1f35060..7dd8c337 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -353,7 +353,9 @@ class IPBan extends Extension public function find_active_ban($ips, $remote, $networks) { - if(!$remote) return null; + if (!$remote) { + return null; + } $active_ban_id = null; if (isset($ips[$remote])) { $active_ban_id = $ips[$remote]; diff --git a/ext/view/main.php b/ext/view/main.php index 99cf5c89..baad6c2e 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -61,10 +61,6 @@ class ViewImage extends Extension if (!is_null($image)) { send_event(new DisplayingImageEvent($image)); - $iabbe = new ImageAdminBlockBuildingEvent($image, $user); - send_event($iabbe); - ksort($iabbe->parts); - $this->theme->display_admin_block($page, $iabbe->parts); } else { $this->theme->display_error(404, "Image not found", "No image in the database has the ID #$image_id"); } @@ -88,10 +84,16 @@ class ViewImage extends Extension public function onDisplayingImage(DisplayingImageEvent $event) { global $user; + $this->theme->display_meta_headers($event->get_image()); + $iibbe = new ImageInfoBoxBuildingEvent($event->get_image(), $user); send_event($iibbe); ksort($iibbe->parts); - $this->theme->display_meta_headers($event->get_image()); $this->theme->display_page($event->get_image(), $iibbe->parts); + + $iabbe = new ImageAdminBlockBuildingEvent($image, $user); + send_event($iabbe); + ksort($iabbe->parts); + $this->theme->display_admin_block($page, $iabbe->parts); } } diff --git a/themes/rule34v2/user.theme.php b/themes/rule34v2/user.theme.php index 14b2e9b9..e3e85bb3 100644 --- a/themes/rule34v2/user.theme.php +++ b/themes/rule34v2/user.theme.php @@ -16,7 +16,6 @@ use function \MicroHTML\P; use function \MicroHTML\SELECT; use function \MicroHTML\OPTION; - class CustomUserPageTheme extends UserPageTheme { public function display_user_block(Page $page, User $user, $parts)