Browse Source

Do noip stuff before other stuff (idk)

pull/40/head
towards-a-new-leftypol 3 years ago
parent
commit
7937a702e3
  1. 22
      inc/config.php
  2. 16
      inc/filters.php

22
inc/config.php

@ -349,6 +349,17 @@
// Same as above but by a different IP address. (Same content, not necessarily same IP address.) // Same as above but by a different IP address. (Same content, not necessarily same IP address.)
$config['flood_time_same'] = 30; $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). // Minimum time between posts by the same IP address (all boards).
$config['filters'][] = array( $config['filters'][] = array(
'condition' => array( 'condition' => array(
@ -380,17 +391,6 @@
'message' => &$config['error']['flood'] '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. // Example: Minimum time between posts with the same file hash.
// $config['filters'][] = array( // $config['filters'][] = array(
// 'condition' => array( // 'condition' => array(

16
inc/filters.php

@ -72,14 +72,14 @@ class Filter {
$this->flood_check = $flood_check_matched; $this->flood_check = $flood_check_matched;
return !empty($this->flood_check); return !empty($this->flood_check);
case 'flood-time': case 'flood-time-any':
foreach ($this->flood_check as $flood_post) { foreach ($this->flood_check as $flood_post) {
if (time() - $flood_post['time'] <= $match) { if (time() - $flood_post['time'] <= $match) {
return true; return true;
} }
} }
return false; return false;
case 'flood-time-any': case 'flood-time':
foreach ($this->flood_check as $flood_post) { foreach ($this->flood_check as $flood_post) {
if (time() - $flood_post['time'] <= $match) { if (time() - $flood_post['time'] <= $match) {
return true; 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']) { if ($post['has_file']) {
$query = prepare("SELECT * FROM ``flood`` WHERE `ip` = :ip OR `posthash` = :posthash OR `filehash` = :filehash"); $query = prepare("SELECT * FROM ``flood`` WHERE `ip` = :ip OR `posthash` = :posthash OR `filehash` = :filehash");
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
@ -253,11 +258,6 @@ function do_filters(array $post) {
} }
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
$flood_check = $query->fetchAll(PDO::FETCH_ASSOC); $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 { } else {
$flood_check = false; $flood_check = false;
} }

Loading…
Cancel
Save