From 77b9ec50e9d690dffc3edf4fec956e2f496a88dd Mon Sep 17 00:00:00 2001 From: SteveD <steved@e107.org> Date: Wed, 15 May 2013 22:27:23 +0100 Subject: [PATCH] Issue #308 - changes to mitigate sending of multiple notifies on flood ban --- e107_handlers/iphandler_class.php | 17 +++++++++++++++-- e107_handlers/online_class.php | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/e107_handlers/iphandler_class.php b/e107_handlers/iphandler_class.php index 48dc248e3..f1f0211ed 100644 --- a/e107_handlers/iphandler_class.php +++ b/e107_handlers/iphandler_class.php @@ -912,7 +912,7 @@ class eIPHandler * @param integer $ban_user * @param string $ban_notes * - * @return boolean check result - FALSE if ban rejected. TRUE if ban added. + * @return boolean|integer check result - FALSE if ban rejected. TRUE if ban added. 1 if IP address already banned */ public function add_ban($bantype, $ban_message = '', $ban_ip = '', $ban_user = 0, $ban_notes = '') { @@ -938,12 +938,25 @@ class eIPHandler { return FALSE; } + // See if address already in the banlist + if ($sql->db_Select('banlist', '`banlist_bantype`', "`banlist_ip`='{$ban_ip}'")) + { + list($banType) = $sql->fetch(MYSQL_ASSOC); + + if ($banType >= eIPHandler::BAN_TYPE_WHITELIST) + { // Got a whitelist entry for this + //$admin_log->e_log_event(4, __FILE__."|".__FUNCTION__."@".__LINE__, "BANLIST_11", 'LAN_AL_BANLIST_11', $ban_ip, FALSE, LOG_TO_ROLLING); + return FALSE; + } + return 1; // Already in ban list + } + /* // See if the address is in the whitelist if ($sql->db_Select('banlist', '*', "`banlist_ip`='{$ban_ip}' AND `banlist_bantype` >= ".eIPHandler::BAN_TYPE_WHITELIST)) { // Got a whitelist entry for this //$admin_log->e_log_event(4, __FILE__."|".__FUNCTION__."@".__LINE__, "BANLIST_11", 'LAN_AL_BANLIST_11', $ban_ip, FALSE, LOG_TO_ROLLING); return FALSE; - } + } */ if(varsettrue($pref['enable_rdns_on_ban'])) { $ban_message .= 'Host: '.$this->get_host_name($ban_ip); diff --git a/e107_handlers/online_class.php b/e107_handlers/online_class.php index f383e1c45..f43f07979 100755 --- a/e107_handlers/online_class.php +++ b/e107_handlers/online_class.php @@ -218,7 +218,7 @@ class e_online if ($row['online_pagecount'] > $online_bancount) { include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_banlist.php'); - if (e107::getIPHandler()->add_ban(2,str_replace('--HITS--',$row['online_pagecount'],BANLAN_78),$ip,0)) + if (TRUE === e107::getIPHandler()->add_ban(2,str_replace('--HITS--',$row['online_pagecount'],BANLAN_78),$ip,0)) { e107::getEvent()->trigger('flood', $ip); exit;