BANGALORE, INDIA: Recently while upgrading our PCQuest online forums to phpBB3, we managed to integrate reCAPTCHA. Implementing reCAPTCHA in this environment was a bit difficult because there is no official module for reCAPTCHA available for phpBB3.
For those who don't know what is reCAPTCHA, it's a program used to distinguish between a human and a bot through images that cannot be read by computers and can only be deciphered by humans. If your website receives a lot of spams, you can put reCAPTCHA on your site to make sure bots and computer programs don't enter your forums and blogs.
Implementing reCAPTCHA
To begin with, you have to create a pair of private and public keys which will be needed later for authenticating your reCAPTCHA installation. For this, you need an account at reCAPTCHA's website http://recap tcha.net/plugins/phpbb/. Sign up on this site and place the path for your domain in the file. Just click on 'Create Key' and note down the keys which appear.
Changes in template file Find the following old code in the ucp_register.html file (template file) and replace it
Old code...
{L_CONFIRM_CODE_EXPLAIN} {L_VC_REFRESH_EXPLAIN}
New Code...
The above code will help you in getting the reCAPTCHA image on your registration page.
Changes in configuration file
Copy recaptchalib.php from the recaptcha download into the /includes/ucp directory
Find this code in ucp_register.php:
}
$confirm_image = '';
$s_hidden_fields .= '
';
}
Unlike phpBB3 Captcha, reCAPTCHA does not require any extra authentication box. |
...and add this directly underneath:
include_once('recaptchalib.php');
$publickey = '6LcKEggAAAAAAIjIdnGkyP7xrex_DPK-UCITnft4';
$confirm_image = recaptcha_get_html($publickey);
Find this code ...in ucp_register.php
else
{
$error<> = $user->lang<'CONFIRM_CODE_WRONG'};
$wrong_confirm = true;
}
}
else
{
$error<> = $user->lang<'CONFIRM_CODE_WRONG'>;
$wrong_confirm = true;
}
}
}
*/
...and then add the following code just below the previous code. This does reCAPTCHA authentication.
require_once('recaptchalib.php');
$privatekey = '6LcKEggAAAAAAEYH6L6FWP1LnZY27t5X5CTFD779';
$resp = recaptcha_check_answer ($privatekey,
$_SERVER<"REMOTE_ADDR">,
$_POST<"recaptcha_challenge_field">,
$_POST<"recaptcha_response_field">);
if (!$resp->is_valid)
{
//die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." ."(reCAPTCHA said: " . $resp->error . ")");
$error<> = $user->lang<'CONFIRM_CODE_WRONG'>;
wrong_confirm = true; }
Lastly comment the following
//'confirm_code' => array('string', !$config<'enable_confirm'>, CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS),
This will help you in installing reCAPTCHA easily.
To understand how reCAPTCHA works, please register with http://forums.pcquest.com