IPB 1.3.1: reCAPTCHA on registration
Notice: If you are uncomfortable installing modifications to your board like these, I am also available to install them for you. Depending on the complexity of the modification, my prices vary. However if you’re interested, feel free to contact me for a quote. I work very quickly. :) I am also available to write custom scripts for forums such as IBP and phpBB (as well as many others).
Sick of spam bots, but don’t feel like inconveniencing your users (and not too fond of IPB’s built in CAPTCHA, for that matter)? Try using reCAPTCHA. This modification will put a reCAPTCHA field on your registration page. This modification will add a new option to your AdminCP (under Security & Privacy -> Enable Script/Bot Flood Control?), which will allow you to specify the usage of reCAPTCHA upon registration.
IPB Version: 1.3.1 Final
Difficulty: Medium
File Version: v1.0.2
Affected Files
/sources/Register.php
/sources/Admin/ad_settings.php
/Skin/*/skin_register.php
1. Register and get API Keys
- In order to use this modification, you must first register an account at reCAPTCHA.net
- Once logged in, add a new site to your account.
- Make sure to copy down the Public Key and Private Key that are given to you, as you will need these later.
2. Download source files
Download the latest reCAPTCHA PHP Library and extract its contents.
3. Upload recaptchalib.php
From the file you just downloaded, upload recaptchalib.php to /sources/recaptchalib.php
4. open /sources/Register.php
IMPORTANT: Make sure to replace publickey and privatekey with the API keys that you obtained during registration.
FIND:
[php]function show_reg_form($errors = "") {
global $ibforums, $DB, $std;[/php]
* INSERT AFTER:
[php]require_once(‘recaptchalib.php’);
$publickey = "…"; // you got this from the reCAPTCHA site[/php]
FIND:
[php]if ($ibforums->vars['bot_antispam'] == ‘gd’)
{
$this->output = str_replace( "<!–{REG.ANTISPAM}–>", $this->html->bot_antispam_gd( $regid ), $this->output );
}
else if ($ibforums->vars['bot_antispam'] == ‘gif’)
{
$this->output = str_replace( "<!–{REG.ANTISPAM}–>", $this->html->bot_antispam( $regid ), $this->output );
}[/php]
* INSERT AFTER:
[sourcecode language="php"]else if ($ibforums->vars['bot_antispam'] == ‘rec’)
{
$this->output = str_replace( "<!–{REG.RECAPTCHA}–>", recaptcha_get_html($publickey), $this->output );
}[/sourcecode]
Now we need to validate the CAPTCHA code that gets entered upon registration.
FIND:
[sourcecode language="php"]function create_account()
{
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;[/sourcecode]
* INSERT AFTER:
[sourcecode language="php"]require_once(‘recaptchalib.php’);
$privatekey = "…"; // you got this from the reCAPTCHA site
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);[/sourcecode]
FIND:
[sourcecode language="php"] //+——————————————–
//| Check the reg_code
//+——————————————–
if ($ibforums->vars['bot_antispam'])
{
if ($ibforums->input['regid'] == "")
{
$this->show_reg_form(‘err_reg_code’);
return;
}
$DB->query("SELECT * FROM ibf_reg_antispam WHERE regid=’".trim(addslashes($ibforums->input['regid']))."’");
if ( ! $row = $DB->fetch_row() )
{
$this->show_reg_form(‘err_reg_code’);
return;
}
if ( trim( intval($ibforums->input['reg_code']) ) != $row['regcode'] )
{
$this->show_reg_form(‘err_reg_code’);
return;
}
$DB->query("DELETE FROM ibf_reg_antispam WHERE regid=’".trim(addslashes($ibforums->input['regid']))."’");
}[/sourcecode]
REPLACE WITH:
[sourcecode language="php"]//+——————————————–
//| Check the reg_code
//+——————————————–
if ($ibforums->vars['bot_antispam'])
{
if ($ibforums->vars['bot_antispam'] == ‘rec’)
{
if (!$resp->is_valid)
{
$this->show_reg_form(‘err_reg_code’);
return;
}
}
else
{
if ($ibforums->input['regid'] == "")
{
$this->show_reg_form(‘err_reg_code’);
return;
}
$DB->query("SELECT * FROM ibf_reg_antispam WHERE regid=’".trim(addslashes($ibforums->input['regid']))."’");
if ( ! $row = $DB->fetch_row() )
{
$this->show_reg_form(‘err_reg_code’);
return;
}
if ( trim( intval($ibforums->input['reg_code']) ) != $row['regcode'] )
{
$this->show_reg_form(‘err_reg_code’);
return;
}
$DB->query("DELETE FROM ibf_reg_antispam WHERE regid=’".trim(addslashes($ibforums->input['regid']))."’");
}
}[/sourcecode]
5. open /sources/Admin/ad_settings.php
FIND:
[sourcecode language="php"]$SKIN->form_dropdown( "bot_antispam",
array(
0 => array( ’0′ , ‘None’ ),
1 => array( ‘gd’ , ‘Advanced (Requires GD Library)’ ),
2 => array( ‘gif’ , ‘Normal (No special requirements)’ ),
),
$INFO['bot_antispam']
)[/sourcecode]
REPLACE WITH:
[sourcecode language="php"]$SKIN->form_dropdown( "bot_antispam",
array(
0 => array( ’0′ , ‘None’ ),
1 => array( ‘gd’ , ‘Advanced (Requires GD Library)’ ),
2 => array( ‘gif’ , ‘Normal (No special requirements)’ ),
3 => array( ‘rec’ , ‘Use reCAPTCHA’ ),
),
$INFO['bot_antispam']
)[/sourcecode]
6. open /Skin/*/skin_register.php
FIND:
[sourcecode language="php"]<!–{REG.ANTISPAM}–>[/sourcecode]
* INSERT AFTER:
[sourcecode language="php"]<!–{REG.RECAPTCHA}–>[/sourcecode]
SAVE & UPLOAD
7. Enable reCAPTCHA
Installing this modification adds a new security option for you to use upon new user registration. To enable reCAPTCHA, log into your AdminCP. The option that you need to change is under System Settings -> Security & Privacy. Once there, change the option “Enable Script/Bot Flood Control?” to “Use reCAPTCHA”.

Make sure to log into your AdminCP and enable the reCAPTCHA IPB setting.
Additional Notes
- Depending on your setup, you may have to resyncronize your skin template in order to view the new reCAPTCHA image upon registration. To do this, first log into your AdminCP. From there go to Skins & Templates -> HTML Templates -> Template Tools. Then run the tool on your selected skin in order to resynchronize it with the template in your database.
Related posts:
- IPB 1.3.1: Force guests to enter a name
- IPB 1.3.1: Make warnings public
- IPB 1.3.1: Change member user titles in Mod CP
- IPB 1.3.1: Uncheck save copy message by default
- IPB 1.3.1: Show pinned prefix in topic view







Got it!
Jodie, I suggest that you add one line for newbies.
After uploading three files, log in to admin panel – skin & templates – html templates, then in the 3rd group, choose “run tool”. Then, reCAPTCHA UI will appear in the registration form.
I’m glad you got it to work, Hyson. :) I’d forgotten that some people may need to resynchronize their templates, so I’ll be sure to make a note of it.
Génial, excellent, tout fonctionne parfaitement.
Un grand merci ! :)
You’re welcome. :)
Thanks. ^^
tks for the effort you put in here I appreciate it!
Thank you so much for all your help Jodie! :) I’m glad I got this working now, and couldn’t have done it without you! <3
You’re welcome! Glad you ended up getting it to work.
Nicely done.. bots have gotten wise to my existing captcha and I am seeing more registrations. I know recaptcha should cure it. Will try installing this later today.
Jodie, would you please mod more so that it/reCPATCHA can be used in IPBv1.31′s password recovery function and email change function?
Yes, it is possible to do. Unfortunately due to the nature of IPB 1.3 and the fact that it’s a very outdated piece of code, I am no longer supporting the modification of it. Sorry.
Thank you Jodie. Works like a charm!