From 93bb05abaf1c55a92f9fb1bceeb655834269b765 Mon Sep 17 00:00:00 2001 From: shish Date: Mon, 28 May 2007 23:22:37 +0000 Subject: [PATCH] IP ban expiry times git-svn-id: file:///home/shish/svn/shimmie2/trunk@140 7f39781d-f577-437e-ae19-be835c7a54ca --- ext/ipban/main.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ext/ipban/main.php b/ext/ipban/main.php index fea5e05f..ebc3eb36 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -13,10 +13,12 @@ class RemoveIPBanEvent extends Event { class AddIPBanEvent extends Event { var $ip; var $reason; + var $end; - public function AddIPBanEvent($ip, $reason) { + public function AddIPBanEvent($ip, $reason, $end) { $this->ip = $ip; $this->reason = $reason; + $this->end = $end; } } // }}} @@ -37,8 +39,8 @@ class IPBan extends Extension { global $user; if($user->is_admin()) { if($event->get_arg(0) == "add") { - if(isset($_POST['ip']) && isset($_POST['reason'])) { - send_event(new AddIPBanEvent($_POST['ip'], $_POST['reason'])); + if(isset($_POST['ip']) && isset($_POST['reason']) && isset($_POST['end'])) { + send_event(new AddIPBanEvent($_POST['ip'], $_POST['reason'], $_POST['end'])); global $page; $page->set_mode("redirect"); @@ -58,7 +60,7 @@ class IPBan extends Extension { } if(is_a($event, 'AddIPBanEvent')) { - $this->add_ip_ban($event->ip, $event->reason); + $this->add_ip_ban($event->ip, $event->reason, $event->end); } if(is_a($event, 'RemoveIPBanEvent')) { @@ -114,14 +116,14 @@ class IPBan extends Extension { public function get_ip_ban($ip) { global $database; // yes, this is "? LIKE var", because ? is the thing with matching tokens - return $database->db->GetRow("SELECT * FROM bans WHERE ? LIKE ip", array($ip)); + return $database->db->GetRow("SELECT * FROM bans WHERE ? LIKE ip AND date < now() AND (end > now() OR isnull(end))", array($ip)); } - public function add_ip_ban($ip, $reason) { + public function add_ip_ban($ip, $reason, $end) { global $database; $database->Execute( - "INSERT INTO bans (ip, reason, date) VALUES (?, ?, now())", - array($ip, $reason)); + "INSERT INTO bans (ip, reason, date, end) VALUES (?, ?, now(), ?)", + array($ip, $reason, $end)); } public function remove_ip_ban($ip) { @@ -139,6 +141,7 @@ class IPBan extends Extension { {$ban['ip']} {$ban['reason']} + {$ban['end']}
@@ -150,12 +153,13 @@ class IPBan extends Extension { } $html = " - + $h_bans +
IPReasonAction
IPReasonUntilAction