[patch] phpBB3 reCAPTCHA Plugin (working)

Skip to first unread message


Mar 13, 2008, 4:37:05 PM3/13/08

I've "hacked" together a simple phpBB3 reCAPTCHA plugin. It was tested
on a development webserver, so you should use it at your own risk in a
production environment.

Files you will need:
reCAPTCHA PHP plugin, available at:

Extract the file 'recaptchalib.php' and place it in:

Files that will be modified in your phpBB3 directory:

Code to modify:
In ucp_register.html, locate:

Then 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>

In ucp_register.php, there are many changes that you'll have to make,
so I'll have to make the instructions compact.

/*Step 1. Place this code before the line "class ucp_register," which
is near the top of ucp_register.php*/

require_once($phpbb_root_path . 'includes/captcha/recaptchalib.' .

/*Step 2. Place this code after the line "global $config, $db, $user,
$auth, $template, $phpbb_root_path, $phpEx;" which is a few lines
after step 1.*/

// Get a key from http://recaptcha.net/api/getkey
$publickey = '';
$privatekey = '';

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;

/*Step 3. Place this code on the line "$confirm_id =
request_var('confirm_id', '');" in other words, replace the original
code with this new code*/

$confirm_id = (isset($_POST['recaptcha_response_field']));

/*Step 4. Comment out or delete the following line of code.*/

'confirm_code' => array('string', !$config['enable_confirm'], 5, 8),

/*Step 5a. Go to the section:
// Visual Confirmation handling
$wrong_confirm = false;
if ($config['enable_confirm'])*/
if (!$confirm_id) {
else {
/* Comment out or delete all code within the first else statement
(which has nested if...else statements within it) and replace with the
code in Step 5b.*/

/*Step 5b. Place the following code within the first else statement.*/
$resp = recaptcha_check_answer ($privatekey,



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. The two lines themselves are also deleted. In total,
you should be deleting about 13 non-empty lines of code*/
//first line of code.
$code = gen_rand_string(mt_rand(5, 8));

//last line of code

/*Step 7. A few lines after the end of Step 6, replace "$confirm_image
= " and its values with the following line of code. Basically, you're
assigning the variable $confirm_image with a new value.

$confirm_image = recaptcha_get_html($publickey, $error);

Step 8. You should be done. I hope. It works for me on my development
webserver, on a basically vanilla version of phpbb3.


May 6, 2008, 3:41:09 PM5/6/08
I've followed your directions and everything seems to be working fine,
but the old "Confirm Code" input box is still appearing directly below
the reCAPTCHA during registration. It also says "Enter the code
exactly as it appears. All letters are case insensitive, there is no
zero." below the input box. How can I get rid of these old remnants
of the original captcha? I dug through the .php files but I can't
figure out where these are getting included from. Thanks!

On Mar 13, 1:37 pm, "openglobaleconomy.com" <jacksmar...@yahoo.co.uk>
> // Get a key fromhttp://recaptcha.net/api/getkey


May 19, 2008, 8:38:40 PM5/19/08
Ok, so I figured out that phpbb3 seems to cache pages nearly
indefinitely. If you are having problems seeing your changes after
modifying the template files for your style try this:

Go to the "cache" folder in your phpbb3 directory. Find the file that
you are trying to change. Rename the file temporarily (just in case)
and then load up the forum and reload the page you are having problems
with. This will cause phpbb3 to reload that page and your changes
should appear. If everything seems to be working then you can safely
go back and remove the cache file you renamed.
Reply all
Reply to author
0 new messages