\SimpleQuestionSpamProtector
A spam protector that prompts the user with a simple question to which any human should know the answer.
- Author: Aaron Carlino <aaron@bluehousegroup.com>
Synopsis
class SimpleQuestionSpamProtector
extends ContactFormSpamProtector
{
- // members
- private static boolean $forgiving = true;
- protected array $questions = ;
- protected string $heading = "";
- protected $questionGiven;
- protected $answerReceived;
- // Inherited members from ContactFormSpamProtector
- protected static boolean $log_spam_failures;
- protected static integer $spam_failure_limit;
- // methods
- public string getMessage()
- public SimpleQuestionSpamProtector addQuestion()
- public SimpleQuestionSpamProtector setHeading()
- public void initialize()
- public boolean isSpam()
- public void logSpamAttempt()
- // Inherited methods from ContactFormSpamProtector
- public static void set_log_spam_failures()
- public static void set_spam_failure_limit()
- public static boolean ip_is_locked()
- public boolean isSpam()
- public string getMessage()
- public void initialize()
- public ContactFormSpamAttempt createSpamAttempt()
- public void logSpamAttempt()
Hierarchy
Extends
Members
private
- $forgiving — boolean
protected
- $answerReceived — string
- $heading — string
- $log_spam_failures — boolean
- $questionGiven — string
- $questions — array
- $spam_failure_limit — int
Methods
public
- addQuestion() — Adds a new question to the list of possible questions to ask on the form
- getMessage() — Gets the message to put on the form when the answer is incorrect
- initialize() — Sets up the spam question. Chooses a question at random and adds it to the form
- isSpam() — Determines if the form is spammy. Checks the answer to the random question
- logSpamAttempt() — Logs a failed spam attempt. Records the question and the user's answer in the Notes field
- setHeading() — Sets the intro text for the spam question
Inherited from ContactFormSpamProtector
public
- createSpamAttempt() — Creates a failed spam attempt object witht the user's info
- getMessage() — Gets the message to return to the form when the spam question is failed
- initialize() — Initialize the spam protector, e.g. add fields to the form, load any requirements
- ip_is_locked() — Determine if an IP address is blocked by looking it up in the database and comparing to $spam_failure_limit
- isSpam() — Determine if the form data is spammy
- logSpamAttempt() — Logs a spam attempt to the database
- set_log_spam_failures() — If true, log the spam failures to the database
- set_spam_failure_limit() — Sets the number of tolerable spam failures before the form stops being rendered