From ee40b9b06c611ef0e69bec6f70ea024d7c0a2663 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Thu, 31 Mar 2011 00:15:26 +1100 Subject: [PATCH] Remove expired IP range bans properly --- inc/functions.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index e2a2454b..c8239785 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -211,6 +211,13 @@ $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':expires', $ban['expires'], PDO::PARAM_INT); $query->execute() or error(db_error($query)); + + if($config['ban_range']) { + $query = prepare("DELETE FROM `bans` WHERE :ip REGEXP CONCAT('^', REPLACE(REPLACE(`ip`, '.', '\\.'), '*', '[0-9]*'), '$') AND `expires` = :expires LIMIT 1"); + $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); + $query->bindValue(':expires', $ban['expires'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + } return; } $body = '