Some of my customers use phpBB3 forum and they started to get automated logins and their forums were hacked and some posts were written. I found interesting webpage about how to use reCaptcha with phpBB3 so i wrote this tutorial. It works with template prosilver and example pictures are also in prosilver.
At first you will need FREE reCAPTCHA PHP plugin /(recaptcha-php-1.10.zip – reCAPTCHA Library for PHP – v1.10), available at Google download reCAPTCHA Library for PHP. After that you will have to get public and private key for use with reCaptcha. Link: http://recaptcha.net/api/getkey
Extract the file ‘recaptchalib.php’ and place it in:
%phpbb_root_path%/includes/captcha
First we must modify code in template file (%phpbb_root_path%/styles/prosilver/template/ucp_register.html)
Locate code <dd>{CONFIRM_IMG}</dd> and delete the following lines of code or comment them out:
<dd><input type=”text” name=”confirm_code” id=”confirm_code” size=”8″
maxlength=”8″ class=”inputbox narrow” title=”{L_CONFIRM_CODE}” /></dd>
<dd>{L_CONFIRM_CODE_EXPLAIN}</dd>
In file %phpbb_root_path%/includes/ucp/ucp_register.php there will be more changes so lets get to it.
Step 1. Place (add) code require_once($phpbb_root_path . ‘includes/captcha/recaptchalib.’ .
$phpEx); before the line “class ucp_register,” which is almost on top of ucp_register.php file.
If your phpBB is on unix you should use server include_once(… instead of require_once(… (Typo was so friendly to let me know about errors in his log file when using this tutorial – and a solution to this problem).
Step 2. Place code
$publickey = ”;
$privatekey = ”;
$resp = null;
$error = null;
after the line “global $config, $db, $user,
$auth, $template, $phpbb_root_path, $phpEx;”
Step 3. Place code $confirm_id = (isset($_POST['recaptcha_response_field'])); on the line “$confirm_id = request_var(’confirm_id’, ”);“. Simply replace code.
Step 4. Comment out or delete the following line of code ‘confirm_code’ => array(’string’, !$config['enable_confirm'], 5, 8),
Step 5. Go to the section
// Visual Confirmation handling
$wrong_confirm = false;
if (!$confirm_id)
{
$error[] = $user->lang['CONFIRM_CODE_WRONG'];
$wrong_confirm = true;
}
else
{
Delete all code within the first else statement (which has also nested if and else statements within it) and replace with next code:
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid == false) {
$error[] = $user->lang['CONFIRM_CODE_WRONG'];
$wrong_confirm = true; }
Step 6. Comment out or delete everything between the following two
lines of code (including first ans last line (delete approx. 13 linex of php code):
First line of code: $code = gen_rand_string(mt_rand(5, 8));
Last line of code: $db->sql_query($sql);
Step 7. A few lines after the end of Step 6, replace “$confirm_image = ‘<img src=”‘ . append_sid(”{$phpbb_root_path}ucp.$phpEx”, ‘mode=confirm&id=’ . $confirm_id . ‘&type=’ . CONFIRM_REG . $str) . ‘” alt=”" title=”" />’;“with the following line of code: $confirm_image = recaptcha_get_html($publickey, $error);
Step 8. Upload both changed files in appropriate folder over ftp on your web server and don’t forget to flush cache in Administration panel of forum for templates – else it won’t work – something like: Templates – Themes – Refresh action.




This is what I absolutely hate about PHPbb. I have had some many problems with automatic registrations and spam it is not even funny. This looks like it could be very useful so thanks for sharing. Sadly I do not think I will go back to PHPbb in the future. It’s vBulletin from now on for me.
reCaptcha in phpBB3 is so easy as you discussed above.
Wow, I didn’t know adding reCaptcha would be so easy. Thanks for this, it should definitely keep the spammers away.
Thanks for the code, I’m gonna give it a try now and i’ll let you know how i got on
It wont stop them because there is alot of spamming tools for forums that have purchased recaptcha api and they have unlock for that so its still automated process for them. I don’t know if there is any 100% working way to stop them.
in web directory reCaptcha in phpBB3 tutorial protect automatic registration is good things.This looks like it could be very useful so thanks for sharing