From ffd5fbb4afa4b8fef4e44122845bbcc6e151c1d8 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 22 Feb 2019 21:24:53 +0000 Subject: [PATCH] fully customisable IP ban --- ext/ipban/main.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/ext/ipban/main.php b/ext/ipban/main.php index 59e53d70..bb95ff98 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -43,7 +43,11 @@ class IPBan extends Extension { if($config->get_int("ext_ipban_version") < 8) { $this->install(); } - $config->set_default_string("ipban_message", "If you couldn't possibly be guilty of what you're banned for, the person we banned probably had a dynamic IP address and so do you. See http://whatismyipaddress.com/dynamic-static for more information.\n"); + $config->set_default_string("ipban_message", +'

IP $IP has been banned until $DATE by $ADMIN because of $REASON +

If you couldn\'t possibly be guilty of what you\'re banned for, the person we banned probably had a dynamic IP address and so do you. +

See http://whatismyipaddress.com/dynamic-static for more information. +

$CONTACT'); $this->check_ip_ban(); } @@ -84,7 +88,7 @@ class IPBan extends Extension { public function onSetupBuilding(SetupBuildingEvent $event) { $sb = new SetupBlock("IP Ban"); - $sb->add_longtext_option("ipban_message", 'Message to show to banned users:'); + $sb->add_longtext_option("ipban_message", 'Message to show to banned users:
(with $IP, $DATE, $ADMIN, $REASON, and $CONTACT)'); $event->panel->add_block($sb); } @@ -226,14 +230,20 @@ class IPBan extends Extension { $admin = User::by_id($row[$prefix.'banner_id']); $date = date("Y-m-d", $row[$prefix.'end_timestamp']); $msg = $config->get_string("ipban_message"); - header("HTTP/1.0 403 Forbidden"); - print "IP $ip has been banned until $date by {$admin->name} because of $reason\n"; - print "

$msg"; - + $msg = str_replace('$IP', $ip, $msg); + $msg = str_replace('$DATE', $date, $msg); + $msg = str_replace('$ADMIN', $admin->name, $msg); + $msg = str_replace('$REASON', $reason, $msg); $contact_link = contact_link(); if(!empty($contact_link)) { - print "

Contact the staff (be sure to include this message)"; + $msg = str_replace('$CONTACT', "Contact the staff (be sure to include this message)", $msg); } + else { + $msg = str_replace('$CONTACT', "", $msg); + } + header("HTTP/1.0 403 Forbidden"); + print "$msg"; + exit; } }