Whenever we display an image for any reason, show the admin block, fixes #621

This commit is contained in:
Shish 2020-03-23 00:06:43 +00:00
parent bfcefb97e7
commit 1fc75c0b18
7 changed files with 19 additions and 15 deletions

View file

@ -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");

View file

@ -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));

View file

@ -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);

View file

@ -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"]),

View file

@ -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];

View file

@ -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);
}
}

View file

@ -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)