Protecting web forms from spam without CAPTCHA - 2: Botobor
Three years ago, an article was published on Habr “Form Spam Bot Blocker: Protecting Web forms without CAPTCHA!” , which talks about a fundamentally different solution from CAPTCHA for PHP to protect forms from spambots. This decision is based on the ideas outlined in their articles by Phil Haack - Honeypot Captcha and Ned Batchelder - Stopping spambots with hashes and honeypots . Unfortunately, the class proposed in the article was written for PHP4 and has not been developed since 2007. I want to bring to your attention its counterpart in PHP5.
Botobor - a library written in PHP 5.0, designed to protect against filling web forms with robots. The methods used by her are invisible to human visitors.
To identify robots, Botobor uses the following checks:
By default, all checks are used, but the developer has the ability to disable any of them.
A snippet of code that creates the form:
A snippet of code that processes form data:
A snippet of code that creates the form:
Otherwise, everything is the same as in the first example.
The constructor
Botobor
Botobor - a library written in PHP 5.0, designed to protect against filling web forms with robots. The methods used by her are invisible to human visitors.
To identify robots, Botobor uses the following checks:
- mismatch of the REFERER value with the URL on which the form is located;
- too small a gap between the display of the form and its submission (customizable);
- the gap between showing the form and sending it is too large (customizable);
- filling the bait field.
By default, all checks are used, but the developer has the ability to disable any of them.
Examples
Simple example
A snippet of code that creates the form:
require 'botobor.php';
...
// Get the markup of the form in the way that is provided for in your project, for example:
$ html = $ form-> getHTML ();
// Create a wrapper object:
$ bform = new Botobor_Form ($ html);
// Get the new markup of the form
$ html = $ bform-> getCode ();
A snippet of code that processes form data:
require 'botobor.php';
...
if (Botobor_Keeper :: isHuman ())
{
// The form is submitted by a person, you can process it.
}
Form customization example
A snippet of code that creates the form:
// let $ html contain the form code
$ bform = new Botobor_Form ($ html);
// disable bait fields
$ bform-> setCheck ('honeypots', false);
// set the lower limit for filling out the form in 2 seconds
$ bform-> setDelay (2);
// set the upper limit for filling out the form in 60 minutes
$ bform-> setLifetime (60);
$ html = $ bform-> getCode ();
Otherwise, everything is the same as in the first example.
What is inside her?
What does Botbor do with form code
The constructor
Botobor_Form
accepts the HTML code of the form. In this code, after the opening tag