Bugfix: the number of successful passes for an anti-spam "hash" was often incorrectly incremented
This commit is contained in:
parent
cf801586f7
commit
9058d202ed
@ -243,22 +243,24 @@ function checkSpam(array $extra_salt = array()) {
|
|||||||
if ($hash != $_hash)
|
if ($hash != $_hash)
|
||||||
return true;
|
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->bindValue(':hash', $hash);
|
||||||
$query->execute() or error(db_error($query));
|
$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.
|
// there was no database entry for this hash. most likely expired.
|
||||||
return true;
|
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'])
|
if ($passed > $config['spam']['hidden_inputs_max_pass'])
|
||||||
return true;
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
9
post.php
9
post.php
@ -212,8 +212,11 @@ if (isset($_POST['delete'])) {
|
|||||||
error($config['error']['noaccess']);
|
error($config['error']['noaccess']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$post['mod'] && checkSpam(array($board['uri'], isset($post['thread']) && !($config['quick_reply'] && isset($_POST['quick-reply'])) ? $post['thread'] : null)))
|
if (!$post['mod']) {
|
||||||
|
$post['antispam_hash'] = checkSpam(array($board['uri'], isset($post['thread']) && !($config['quick_reply'] && isset($_POST['quick-reply'])) ? $post['thread'] : null));
|
||||||
|
if ($post['antispam_hash'] === true)
|
||||||
error($config['error']['spam']);
|
error($config['error']['spam']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($config['robot_enable'] && $config['robot_mute']) {
|
if ($config['robot_enable'] && $config['robot_mute']) {
|
||||||
checkMute();
|
checkMute();
|
||||||
@ -536,6 +539,10 @@ if (isset($_POST['delete'])) {
|
|||||||
|
|
||||||
$id = post($post);
|
$id = post($post);
|
||||||
|
|
||||||
|
if (isset($post['antispam_hash'])) {
|
||||||
|
incrementSpamHash($post['antispam_hash']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($post['tracked_cites'])) {
|
if (isset($post['tracked_cites'])) {
|
||||||
foreach ($post['tracked_cites'] as $cite) {
|
foreach ($post['tracked_cites'] as $cite) {
|
||||||
$query = prepare('INSERT INTO `cites` VALUES (:board, :post, :target_board, :target)');
|
$query = prepare('INSERT INTO `cites` VALUES (:board, :post, :target_board, :target)');
|
||||||
|
Loading…
Reference in New Issue
Block a user