Use reCaptcha in phpBB3 tutorial protect automatic registration

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>

Part code of File ucp_register.html will look like

Part code of File ucp_register.html will look like

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.

Edited code of ucp_register.php file

Edited code of ucp_register.php file

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; }

Next step replace code in Visual confirmation handling

Next step replace code in Visual confirmation handling

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&amp;id=’ . $confirm_id . ‘&amp;type=’ . CONFIRM_REG . $str) . ‘” alt=”" title=”" />’;“with the following line of code: $confirm_image = recaptcha_get_html($publickey, $error);

Last changes of code in ucp_register.php

Last changes of code in ucp_register.php

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.

Tags: , , , , ,

6 Responses to “Use reCaptcha in phpBB3 tutorial protect automatic registration”

  1. Media Fire Brand Logo Design says:

    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.

  2. best travel money says:

    reCaptcha in phpBB3 is so easy as you discussed above.

  3. New Jersey Movers says:

    Wow, I didn’t know adding reCaptcha would be so easy. Thanks for this, it should definitely keep the spammers away.

  4. Betty Units says:

    Thanks for the code, I’m gonna give it a try now and i’ll let you know how i got on

  5. Moneymen says:

    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.

  6. kete says:

    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

Leave a Reply