code cleanup
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* Copyright (c) 2010-2012 Tinyboard Development Group
|
||||
*/
|
||||
|
||||
if(realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) {
|
||||
if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) {
|
||||
// You cannot request this file directly.
|
||||
exit;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ class Filter {
|
||||
private $condition;
|
||||
|
||||
public function __construct(array $arr) {
|
||||
foreach($arr as $key => $value)
|
||||
foreach ($arr as $key => $value)
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class Filter {
|
||||
|
||||
switch($condition) {
|
||||
case 'custom':
|
||||
if(!is_callable($match))
|
||||
if (!is_callable($match))
|
||||
error('Custom condition for filter is not callable!');
|
||||
return $match($post);
|
||||
case 'name':
|
||||
@@ -36,11 +36,11 @@ class Filter {
|
||||
case 'body':
|
||||
return preg_match($match, $post['body']);
|
||||
case 'filename':
|
||||
if(!$post['has_file'])
|
||||
if (!$post['has_file'])
|
||||
return false;
|
||||
return preg_match($match, $post['filename']);
|
||||
case 'extension':
|
||||
if(!$post['has_file'])
|
||||
if (!$post['has_file'])
|
||||
return false;
|
||||
return preg_match($match, $post['body']);
|
||||
case 'ip':
|
||||
@@ -61,22 +61,22 @@ class Filter {
|
||||
case 'reject':
|
||||
error(isset($this->message) ? $this->message : 'Posting throttled by flood filter.');
|
||||
case 'ban':
|
||||
if(!isset($this->reason))
|
||||
if (!isset($this->reason))
|
||||
error('The ban action requires a reason.');
|
||||
|
||||
$reason = $this->reason;
|
||||
|
||||
if(isset($this->expires))
|
||||
if (isset($this->expires))
|
||||
$expires = time() + $this->expires;
|
||||
else
|
||||
$expires = 0; // Ban indefinitely
|
||||
|
||||
if(isset($this->reject))
|
||||
if (isset($this->reject))
|
||||
$reject = $this->reject;
|
||||
else
|
||||
$reject = true;
|
||||
|
||||
if(isset($this->all_boards))
|
||||
if (isset($this->all_boards))
|
||||
$all_boards = $this->all_boards;
|
||||
else
|
||||
$all_boards = false;
|
||||
@@ -86,26 +86,26 @@ class Filter {
|
||||
$query->bindValue(':mod', -1);
|
||||
$query->bindValue(':set', time());
|
||||
|
||||
if($expires)
|
||||
if ($expires)
|
||||
$query->bindValue(':expires', $expires);
|
||||
else
|
||||
$query->bindValue(':expires', null, PDO::PARAM_NULL);
|
||||
|
||||
if($reason)
|
||||
if ($reason)
|
||||
$query->bindValue(':reason', $reason);
|
||||
else
|
||||
$query->bindValue(':reason', null, PDO::PARAM_NULL);
|
||||
|
||||
|
||||
if($all_boards)
|
||||
if ($all_boards)
|
||||
$query->bindValue(':board', null, PDO::PARAM_NULL);
|
||||
else
|
||||
$query->bindValue(':board', $board['uri']);
|
||||
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
if($reject) {
|
||||
if(isset($this->message))
|
||||
if ($reject) {
|
||||
if (isset($this->message))
|
||||
error($message);
|
||||
|
||||
checkBan($board['uri']);
|
||||
@@ -119,8 +119,8 @@ class Filter {
|
||||
}
|
||||
|
||||
public function check(array $post) {
|
||||
foreach($this->condition as $condition => $value) {
|
||||
if(!$this->match($post, $condition, $value))
|
||||
foreach ($this->condition as $condition => $value) {
|
||||
if (!$this->match($post, $condition, $value))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -132,12 +132,12 @@ class Filter {
|
||||
function do_filters(array $post) {
|
||||
global $config;
|
||||
|
||||
if(!isset($config['flood_filters']))
|
||||
if (!isset($config['flood_filters']))
|
||||
return;
|
||||
|
||||
foreach($config['flood_filters'] as $arr) {
|
||||
foreach ($config['flood_filters'] as $arr) {
|
||||
$filter = new Filter($arr);
|
||||
if($filter->check($post))
|
||||
if ($filter->check($post))
|
||||
$filter->action();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user