The extension Really Simple CAPTCHA is a special module to install the captcha, which is designed to help eliminate spam on the website that is created for other useful extensions WordPress called Contact Form 7. This solution does not work in single player mode requiring another plugin. Although it was originally created for the above module, you will be able to use it with another plugin.
Примечание: это расширение действительно очень простое, поэтому для полноценной защиты собственного блога используйте иные решения.
Note: this extension is really very simple, so to protect your own blog and use other solutions.
How it works?
Component absolutely does not use PHP session to maintain state, like many other such solutions, but stores them as temporary files. This allows you to place the plugin in WordPress without fear of possible conflicts.
At that time, when generating the captcha, the plugin creates 2 files for it – one for image and one for the text file that stores the correct answer.
2 files have the same prefix in their names, e.g. “df78hfjf.png”, df78hfjf.txt. If the Respondent answers incorrectly to a question captcha, then it calculates the hash again and testing data saved in a text file. At coincidence of names of the response is confirmed.
How to use with the plugin
Note: the following instructions are for implementing captcha for developers.
First we need to create content ReallySimpleCaptcha class:
$captcha_instance = new ReallySimpleCaptcha();
You can change the variables on their own.
// Change the background color for captcha image on black $captcha_instance->bg = array( 0, 0, 0 );
See a file called really-simple-captcha.php if you want to change the variables.
Generating random words in the captcha
$word = $captcha_instance->generate_random_word();
Produces a file with the image and relates it to the text in the temp directory.
$prefix = mt_rand(); $captcha_instance->generate_image( $prefix, $word );
Then shows a picture and receives a response from the user.
Checking the correctness of the answer
$correct = $captcha_instance->check( $prefix, $the_answer_from_respondent );
If $correct is true value, then continue. Otherwise, the Respondent’s block – so how can it be a robot.
Finally, remove the temporary image and text files, as they are no longer needed.
$captcha_instance->remove( $prefix );
The test plugin.