Advertisment

Stop Spam Posts on Your phpBB3 Forum

author-image
PCQ Bureau
New Update

Recently while upgrading our PCQuest online forums to phpBB3, we managed to

integrate reCAPTCHA. Implementing reCAPTCHA in this environment was a bit

difficult because there is no official module for reCAPTCHA available for

phpBB3. For those who don't know what is reCAPTCHA, it's a program used to

distinguish between a human and a bot through images that cannot be read by

computers and can only be deciphered by humans. If  your  website

receives a lot of spams, you can put reCAPTCHA on your site to make sure bots

and computer programs don't enter your forums and blogs.

Advertisment

Implementing reCAPTCHA



To begin with, you have to create a pair of private and public keys which

will be needed later for authenticating your reCAPTCHA installation. For this,

you need an account at reCAPTCHA's website http://recap tcha.net/plugins/phpbb/.

Sign up on this site and place the path for your domain in the file. Just click

on 'Create Key' and note down the keys which appear.

Direct Hit!

Applies To: phpBB3 Developers



USP: Implementing reCAPTCHA in phpBB3
environment



Primary Link: http://recaptcha.net /whyrecaptcha.html


Search Engine Keywords: phpbb3, recaptcha

Now modify some of the phpBB3 files so that you can integrate reCAPTCHA with

your registration page. The phpBB3 files which you will need to modify

are:template file (ucp_register.html) and configuration file (ucp_register.php).

Advertisment

Changes in template file Find the following old code in the ucp_register.html

file (template file) and replace it

Old code...



Advertisment


colspan="2" valign="middle">{L_CONFIRMATION}







{L_CONFIRM_EXPLAIN}



Advertisment





{CONFIRM_IMG}





Advertisment


{L_CONFIRM_CODE}:

{L_CONFIRM_CODE_EXPLAIN}

{L_VC_REFRESH_EXPLAIN}



maxlength="8" /> 

class="btnlite" />







New Code...

Advertisment



{CONFIRM_IMG}





Advertisment

The above code will help you in getting the reCAPTCHA image on your

registration page.

Changes in configuration file



Copy recaptchalib.php from the recaptcha download into the /includes/ucp

directory

Find this code in ucp_register.php:

}



$confirm_image = ' 'mode=confirm&id=' . $confirm_id . '&type=' . CONFIRM_REG . $str) . '"

alt="publive-image" title="publive-image" title="" />';


$s_hidden_fields .= '

';


}

Unlike phpBB3 Captcha, reCAPTCHA does not require any extra

authentication box.

...and add this directly underneath:

include_once('recaptchalib.php');



     $publickey = '6LcKEggAAAAAAIjIdnGkyP7xrex_DPK-UCITnft4';


     $confirm_image = recaptcha_get_html($publickey);


 Find this code ...in ucp_register.php


else


{


$error<> = $user->lang<'CONFIRM_CODE_WRONG'};


$wrong_confirm = true;


}


}


else


{


$error<> = $user->lang<'CONFIRM_CODE_WRONG'>;


$wrong_confirm = true;


}


}


}


*/



















...and then add the following code just below the previous code. This does

reCAPTCHA authentication.

         require_once('recaptchalib.php');



             $privatekey = '6LcKEggAAAAAAEYH6L6FWP1LnZY27t5X5CTFD779';


             $resp = recaptcha_check_answer ($privatekey,


             $_SERVER<"REMOTE_ADDR">,


             $_POST<"recaptcha_challenge_field">,


             $_POST<"recaptcha_response_field">);


  if (!$resp->is_valid)


{


//die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." ."(reCAPTCHA

said: " . $resp->error . ")");






$error<> = $user->lang<'CONFIRM_CODE_WRONG'>;

  wrong_confirm = true;   }

Lastly comment the following

//'confirm_code' => array('string', !$config<'enable_confirm'>,

CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS),

This will help you in installing reCAPTCHA easily.

To understand how reCAPTCHA works, please register with

http://forums.pcquest.com

Advertisment