public static function onEditFilterMerged($editPage, $text, &$hookError) { if (!function_exists('apache_request_headers')) { return true; } $headers = apache_request_headers(); if (isset($headers['Content-Type']) && $headers['Content-Type'] == 'application/x-www-form-urlencoded') { if (AntiBot::trigger(__CLASS__) == 'fail') { return false; } } return true; }
function _create_antibot($board, $thread) { global $config; $antibot = new AntiBot(array($board, $thread)); query('DELETE FROM `antispam` WHERE `expires` < UNIX_TIMESTAMP()') or error(db_error()); if ($thread) { $query = prepare('UPDATE `antispam` SET `expires` = UNIX_TIMESTAMP() + :expires WHERE `board` = :board AND `thread` = :thread AND `expires` IS NULL'); } else { $query = prepare('UPDATE `antispam` SET `expires` = UNIX_TIMESTAMP() + :expires WHERE `board` = :board AND `thread` IS NULL AND `expires` IS NULL'); } $query->bindValue(':board', $board); if ($thread) { $query->bindValue(':thread', $thread); } $query->bindValue(':expires', $config['spam']['hidden_inputs_expire']); $query->execute() or error(db_error($query)); $query = prepare('INSERT INTO `antispam` VALUES (:board, :thread, :hash, UNIX_TIMESTAMP(), NULL, 0)'); $query->bindValue(':board', $board); $query->bindValue(':thread', $thread); $query->bindValue(':hash', $antibot->hash()); $query->execute() or error(db_error($query)); return $antibot; }