Hi,
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:
http://code.google.com/p/recaptcha/downloads/list
Extract the file 'recaptchalib.php' and place it in:
%phpbb_root_path%/includes/captcha
Files that will be modified in your phpBB3 directory:
%phpbb_root_path%/styles/prosilver/template/ucp_register.html
%phpbb_root_path%/includes/ucp/ucp_register.php
Code to modify:
In ucp_register.html, locate:
<dd>{CONFIRM_IMG}</dd>
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>
<dd>{L_CONFIRM_CODE_EXPLAIN}</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.' .
$phpEx);
/*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,
$_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. 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
$db->sql_query($sql);
/*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.