summaryrefslogtreecommitdiff
path: root/inc/anti-bot.php
diff options
context:
space:
mode:
authorYousha <Yousha.A@Hotmail.com>2012-08-30 20:05:27 +0430
committerYousha <Yousha.A@Hotmail.com>2012-08-30 20:05:27 +0430
commit55470a7ac82c49e30c5439344379e877ab1e7898 (patch)
tree373654355f5045acebdbe549417f277663c774d8 /inc/anti-bot.php
parentfb4e28c7b86c8e8b1716eea38ad7c6d39172a2c9 (diff)
Improved.
Diffstat (limited to 'inc/anti-bot.php')
-rw-r--r--inc/anti-bot.php35
1 files changed, 15 insertions, 20 deletions
diff --git a/inc/anti-bot.php b/inc/anti-bot.php
index 81afca1b..dbf66fc1 100644
--- a/inc/anti-bot.php
+++ b/inc/anti-bot.php
@@ -201,59 +201,56 @@ function _create_antibot($board, $thread) {
function checkSpam(array $extra_salt = array()) {
global $config, $pdo;
-
+
if (!isset($_POST['hash']))
return true;
-
+
$hash = $_POST['hash'];
-
+
if (!empty($extra_salt)) {
// create a salted hash of the "extra salt"
$extra_salt = implode(':', $extra_salt);
} else {
$extra_salt = '';
}
-
+
// Reconsturct the $inputs array
$inputs = array();
-
+
foreach ($_POST as $name => $value) {
if (in_array($name, $config['spam']['valid_inputs']))
continue;
-
+
$inputs[$name] = $value;
}
-
+
// Sort the inputs in alphabetical order (A-Z)
ksort($inputs);
-
+
$_hash = '';
-
+
// Iterate through each input
foreach ($inputs as $name => $value) {
$_hash .= $name . '=' . $value;
}
-
+
// Add a salt to the hash
$_hash .= $config['cookies']['salt'];
-
+
// Use SHA1 for the hash
$_hash = sha1($_hash . $extra_salt);
-
+
if ($hash != $_hash)
return true;
-
+
$query = prepare('SELECT `passed` FROM `antispam` WHERE `hash` = :hash');
$query->bindValue(':hash', $hash);
$query->execute() or error(db_error($query));
- if (($passed = $query->fetchColumn(0)) === false) {
+ if ((($passed = $query->fetchColumn(0)) === false) || ($passed > $config['spam']['hidden_inputs_max_pass'])) {
// there was no database entry for this hash. most likely expired.
return true;
}
-
- if ($passed > $config['spam']['hidden_inputs_max_pass'])
- return true;
-
+
return $hash;
}
@@ -262,5 +259,3 @@ function incrementSpamHash($hash) {
$query->bindValue(':hash', $hash);
$query->execute() or error(db_error($query));
}
-
-