Bugfix: the number of successful passes for an anti-spam "hash" was often incorrectly incremented

This commit is contained in:
Michael Save 2012-05-07 23:51:15 +10:00
parent cf801586f7
commit 9058d202ed
2 changed files with 19 additions and 10 deletions

View file

@ -243,22 +243,24 @@ function checkSpam(array $extra_salt = array()) {
if ($hash != $_hash)
return true;
$query = prepare('UPDATE `antispam` SET `passed` = `passed` + 1 WHERE `hash` = :hash');
$query = prepare('SELECT `passed` FROM `antispam` WHERE `hash` = :hash');
$query->bindValue(':hash', $hash);
$query->execute() or error(db_error($query));
if ($query->rowCount() == 0) {
if (($passed = $query->fetchColumn(0)) === false) {
// there was no database entry for this hash. most likely expired.
return true;
}
$query = prepare('SELECT `passed` FROM `antispam` WHERE `hash` = :hash');
$query->bindValue(':hash', $hash);
$query->execute() or error(db_error($query));
$passed = $query->fetchColumn(0);
if ($passed > $config['spam']['hidden_inputs_max_pass'])
return true;
return false;
return $hash;
}
function incrementSpamHash($hash) {
$query = prepare('UPDATE `antispam` SET `passed` = `passed` + 1 WHERE `hash` = :hash');
$query->bindValue(':hash', $hash);
$query->execute() or error(db_error($query));
}