From 43486ab5fa7bb995c2ac5ed1cf536cf99428f47f Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 2 Feb 2010 11:32:05 +0000 Subject: [PATCH] make IP bans work better --- contrib/ipban/main.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contrib/ipban/main.php b/contrib/ipban/main.php index a7474b38..561d225d 100644 --- a/contrib/ipban/main.php +++ b/contrib/ipban/main.php @@ -207,8 +207,11 @@ class IPBan implements Extension { if($cached) return $cached; $bans = $database->get_all(" - SELECT * FROM bans + SELECT bans.*, users.name as banner_name + FROM bans + JOIN users ON banner_id = users.id WHERE (end_timestamp > ?) OR (end_timestamp IS NULL) + ORDER BY end_timestamp, bans.id ", array(time())); $database->cache->set("ip_bans", $bans, 600); @@ -221,7 +224,7 @@ class IPBan implements Extension { global $database; $sql = "INSERT INTO bans (ip, reason, end_timestamp, banner_id) VALUES (?, ?, ?, ?)"; $database->Execute($sql, array($ip, $reason, strtotime($end), $user->id)); - $database->cache->delete("bans"); + $database->cache->delete("ip_bans"); } // }}} }