From 62d0f3df7c5e6dee62dc6deff0d20589001a5914 Mon Sep 17 00:00:00 2001 From: shish Date: Fri, 11 Apr 2008 06:26:13 +0000 Subject: [PATCH] allow ban for '1 week' etc instead of specifying end time git-svn-id: file:///home/shish/svn/shimmie2/trunk@812 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/ipban/main.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/contrib/ipban/main.php b/contrib/ipban/main.php index df42b5b3..58e624bd 100644 --- a/contrib/ipban/main.php +++ b/contrib/ipban/main.php @@ -55,7 +55,7 @@ class IPBan extends Extension { global $page; $page->set_mode("redirect"); - $page->set_redirect(make_link("admin")); + $page->set_redirect(make_link("ip_ban/list")); } } else if($event->get_arg(0) == "remove") { @@ -64,7 +64,7 @@ class IPBan extends Extension { global $page; $page->set_mode("redirect"); - $page->set_redirect(make_link("admin")); + $page->set_redirect(make_link("ip_ban/list")); } } else if($event->get_arg(0) == "list") { @@ -146,9 +146,16 @@ class IPBan extends Extension { private function add_ip_ban($ip, $reason, $end, $user) { global $database; - $database->Execute( - "INSERT INTO bans (ip, reason, date, end, banner_id) VALUES (?, ?, now(), ?, ?)", - array($ip, $reason, $end, $user->id)); + if(preg_match("/^\d+ (day|week|month)$/i", $end)) { + $sql = "INSERT INTO bans (ip, reason, date, end, banner_id) + VALUES (?, ?, now(), now() + interval $end, ?)"; + $database->Execute($sql, array($ip, $reason, $user->id)); + } + else { + $sql = "INSERT INTO bans (ip, reason, date, end, banner_id) + VALUES (?, ?, now(), ?, ?)"; + $database->Execute($sql, array($ip, $reason, $end, $user->id)); + } } private function remove_ip_ban($id) {