summaryrefslogtreecommitdiff
path: root/inc/filters.php
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-04-13 00:18:19 +1000
committerMichael Save <savetheinternet@tinyboard.org>2012-04-13 00:18:19 +1000
commit51675e7a9bf4d5055ed45b37bac964f788800399 (patch)
tree3df1b07b09315b184556a4418d2102e095c26cdd /inc/filters.php
parentda52307c67818893cb7ee54d8e2d6c93c0e34a02 (diff)
code cleanup
Diffstat (limited to 'inc/filters.php')
-rw-r--r--inc/filters.php38
1 files changed, 19 insertions, 19 deletions
diff --git a/inc/filters.php b/inc/filters.php
index 68e948c9..7204614a 100644
--- a/inc/filters.php
+++ b/inc/filters.php
@@ -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();
}
}