From b8300b82ee043a97475e7f7e87fc3e04454f08a8 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sat, 7 Sep 2013 12:58:23 +1000 Subject: [PATCH] Add ! syntax (NOT) to filters. Don't throttle duplicate post bodies when they are empty --- inc/config.php | 7 ++++--- inc/filters.php | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/inc/config.php b/inc/config.php index 43550dc3..9f231e30 100644 --- a/inc/config.php +++ b/inc/config.php @@ -305,7 +305,7 @@ $config['filters'][] = array( 'condition' => array( 'flood-match' => array('ip'), // Only match IP address - 'flood-time' => &$config['flood_time'] // 10 seconds minimum + 'flood-time' => &$config['flood_time'] ), 'action' => 'reject', 'message' => &$config['error']['flood'] @@ -315,7 +315,8 @@ $config['filters'][] = array( 'condition' => array( 'flood-match' => array('ip', 'body'), // Match IP address and post body - 'flood-time' => &$config['flood_time_ip'] // 2 minutes minimum + 'flood-time' => &$config['flood_time_ip'], + '!body' => '/^$/', // Post body is NOT empty ), 'action' => 'reject', 'message' => &$config['error']['flood'] @@ -325,7 +326,7 @@ $config['filters'][] = array( 'condition' => array( 'flood-match' => array('body'), // Match IP address and post body - 'flood-time' => &$config['flood_time_same'] // 30 seconds minimum + 'flood-time' => &$config['flood_time_same'] ), 'action' => 'reject', 'message' => &$config['error']['flood'] diff --git a/inc/filters.php b/inc/filters.php index 27b167ea..5c934532 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -168,11 +168,14 @@ class Filter { public function check(array $post) { foreach ($this->condition as $condition => $value) { - if (!$this->match($post, $condition, $value)) + if ($condition[0] == '!') { + $NOT = true; + $condition = substr($condition, 1); + } else $NOT = false; + + if ($this->match($post, $condition, $value) == $NOT) return false; } - - /* match */ return true; } }