diff --git a/inc/config.php b/inc/config.php index adc58733..3f8e597a 100644 --- a/inc/config.php +++ b/inc/config.php @@ -349,6 +349,17 @@ // Same as above but by a different IP address. (Same content, not necessarily same IP address.) $config['flood_time_same'] = 30; + $config['filters'][] = array( + 'condition' => array( + 'OP' => true, + 'flood-time-any' => &$config['flood_time_any'] + ), + 'noip' => true, + 'find-time' => 60 * 60 * 1, + 'action' => 'reject', + 'message' => 'Hmmm' + ); + // Minimum time between posts by the same IP address (all boards). $config['filters'][] = array( 'condition' => array( @@ -380,17 +391,6 @@ 'message' => &$config['error']['flood'] ); - $config['filters'][] = array( - 'condition' => array( - 'OP' => true, - 'flood-time-any' => &$config['flood_time_any'] - ), - 'noip' => true, - 'find-time' => 60 * 60 * 1, - 'action' => 'reject', - 'message' => 'Hmmm' - ); - // Example: Minimum time between posts with the same file hash. // $config['filters'][] = array( // 'condition' => array( diff --git a/inc/filters.php b/inc/filters.php index 4019b9e6..41348ec0 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -72,14 +72,14 @@ class Filter { $this->flood_check = $flood_check_matched; return !empty($this->flood_check); - case 'flood-time': + case 'flood-time-any': foreach ($this->flood_check as $flood_post) { if (time() - $flood_post['time'] <= $match) { return true; } } return false; - case 'flood-time-any': + case 'flood-time': foreach ($this->flood_check as $flood_post) { if (time() - $flood_post['time'] <= $match) { return true; @@ -240,7 +240,12 @@ function do_filters(array $post) { } } - if (isset($has_flood)) { + if ($noip) { + print_err("SELECT * FROM flood WHERE time > " . strval($find_time)); + $query = prepare("SELECT * FROM ``flood`` WHERE `time` > $find_time"); + $query->execute() or error(db_error($query)); + $flood_check = $query->fetchAll(PDO::FETCH_ASSOC); + } else if (isset($has_flood)) { if ($post['has_file']) { $query = prepare("SELECT * FROM ``flood`` WHERE `ip` = :ip OR `posthash` = :posthash OR `filehash` = :filehash"); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); @@ -253,11 +258,6 @@ function do_filters(array $post) { } $query->execute() or error(db_error($query)); $flood_check = $query->fetchAll(PDO::FETCH_ASSOC); - } else if ($noip) { - print_err("SELECT * FROM flood WHERE time > " . strval($find_time)); - $query = prepare("SELECT * FROM ``flood`` WHERE `time` > $find_time"); - $query->execute() or error(db_error($query)); - $flood_check = $query->fetchAll(PDO::FETCH_ASSOC); } else { $flood_check = false; }