From 51675e7a9bf4d5055ed45b37bac964f788800399 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Fri, 13 Apr 2012 00:18:19 +1000 Subject: code cleanup --- inc/anti-bot.php | 66 ++++---- inc/cache.php | 24 +-- inc/config.php | 8 +- inc/database.php | 20 +-- inc/display.php | 114 ++++++------- inc/events.php | 12 +- inc/filters.php | 38 ++--- inc/functions.php | 466 +++++++++++++++++++++++++++--------------------------- inc/image.php | 58 +++---- inc/mod.php | 34 ++-- inc/remote.php | 18 +-- inc/template.php | 14 +- 12 files changed, 436 insertions(+), 436 deletions(-) (limited to 'inc') diff --git a/inc/anti-bot.php b/inc/anti-bot.php index 131a643c..b5fcf2a1 100644 --- a/inc/anti-bot.php +++ b/inc/anti-bot.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; } @@ -16,9 +16,9 @@ class AntiBot { public static function randomString($length, $uppercase = false, $special_chars = false) { $chars = 'abcdefghijklmnopqrstuvwxyz0123456789'; - if($uppercase) + if ($uppercase) $chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - if($special_chars) + if ($special_chars) $chars .= ' ~!@#$%^&*()_+,./;\'[]\\{}|:"<>?=-` '; $chars = str_split($chars); @@ -26,15 +26,15 @@ class AntiBot { $ch = array(); // fill up $ch until we reach $length - while(count($ch) < $length) { + while (count($ch) < $length) { $n = $length - count($ch); $keys = array_rand($chars, $n > count($chars) ? count($chars) : $n); - if($n == 1) { + if ($n == 1) { $ch[] = $chars[$keys]; break; } shuffle($keys); - foreach($keys as $key) + foreach ($keys as $key) $ch[] = $chars[$key]; } @@ -46,8 +46,8 @@ class AntiBot { public static function make_confusing($string) { $chars = str_split($string); - foreach($chars as &$c) { - if(rand(0, 2) != 0) + foreach ($chars as &$c) { + if (rand(0, 2) != 0) continue; $c = mb_encode_numericentity($c, array(0, 0xffff, 0, 0xffff), 'UTF-8'); } @@ -58,7 +58,7 @@ class AntiBot { public function __construct(array $salt = array()) { global $config; - if(!empty($salt)) { + if (!empty($salt)) { // create a salted hash of the "extra salt" $this->salt = implode(':', $salt); } else { @@ -70,21 +70,21 @@ class AntiBot { $input_count = rand($config['spam']['hidden_inputs_min'], $config['spam']['hidden_inputs_max']); $hidden_input_names_x = 0; - for($x = 0; $x < $input_count ; $x++) { - if($hidden_input_names_x === false || rand(0, 2) == 0) { + for ($x = 0; $x < $input_count ; $x++) { + if ($hidden_input_names_x === false || rand(0, 2) == 0) { // Use an obscure name $name = $this->randomString(rand(10, 40)); } else { // Use a pre-defined confusing name $name = $config['spam']['hidden_input_names'][$hidden_input_names_x++]; - if($hidden_input_names_x >= count($config['spam']['hidden_input_names'])) + if ($hidden_input_names_x >= count($config['spam']['hidden_input_names'])) $hidden_input_names_x = false; } - if(rand(0, 2) == 0) { + if (rand(0, 2) == 0) { // Value must be null $this->inputs[$name] = ''; - } elseif(rand(0, 4) == 0) { + } elseif (rand(0, 4) == 0) { // Numeric value $this->inputs[$name] = (string)rand(0, 100); } else { @@ -111,11 +111,11 @@ class AntiBot { $html = ''; - if($count === false) { + if ($count === false) { $count = rand(1, count($this->inputs) / 15); } - if($count === true) { + if ($count === true) { // all elements $inputs = array_slice($this->inputs, $this->index); } else { @@ -123,11 +123,11 @@ class AntiBot { } $this->index += count($inputs); - foreach($inputs as $name => $value) { + foreach ($inputs as $name => $value) { $element = false; - while(!$element) { + while (!$element) { $element = $elements[array_rand($elements)]; - if(strpos($element, 'textarea') !== false && $value == '') { + if (strpos($element, 'textarea') !== false && $value == '') { // There have been some issues with mobile web browsers and empty