PDA

View Full Version : reCaptcha support?


Zachary8222
04-03-2008, 02:30 PM
Would it be difficult for me to make the captcha image from recaptcha instead of using the thing we need now?

Derek
04-05-2008, 02:53 AM
Will be adding it to 2.0.0. I'll try and make you a patch tomorrow so you can start using it in 1.0.0...

Derek

Derek
04-08-2008, 06:52 PM
Hey,

Sorry for the late reply. Here are the instructions to do it. Let me know if you have any problems. You will have to signup at recaptcha's site and get your public and private keys. Also, upload the attached file to the nbs directory.

Open nbs/templates/default/new_forum.tpl

Find & Delete:

{if $S_captcha == 1}{literal}&& new_forum.captcha_code.value != ''{/literal}{/if}Find:

<a href="#" onclick="refresh_image();"><img style="border: 2px solid #000000" src="nbs/captcha.php?template={$S_template}" name="captcha" /></a><br /><br /><input type="text" name="captcha_code" size="31" onkeydown="enable();" onkeyup="enable();" tabindex="9" />Replace With:

{$captcha}Close & Save nbs/templates/default/new_forum.tpl

Open new_forum.php

Find:

define('PHRASE_TYPE', 4);Add Under (Make sure you put your public and private keys in the quotes below!!!):

define('RECAPTCHA_PUBLIC_KEY', 'PUT YOUR RECAPTCHA PUBLIC KEY HERE');
define('RECAPTCHA_PRIVATE_KEY', 'PUT YOUR RECAPTCHA PRIVATE KEY HERE');Find:

require_once('nbs/global.php');Add Under:

require_once('nbs/recaptchalib.php');Find & Delete:

OR ($nbs->setting['captcha'] AND empty($_POST['captcha_code']))Find:


// include captcha class
require('nbs/php-captcha.inc.php');

if (!PhpCaptcha::Validate($_POST['captcha_code']))
{
print_error_message($nbs->phrase['image_verification_code_incorrect_error']);
}
Replace With:


$resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);

if (!$resp->is_valid)
{
print_error_message($nbs->phrase['image_verification_code_incorrect_error']);
}
Find:


if ($nbs->setting['captcha'])
{
$tpl->assign('L_image_verification', $nbs->phrase['image_verification']);
$tpl->assign('L_new', $nbs->phrase['new']);
}
Add Under:

$tpl->assign('captcha', recaptcha_get_html(RECAPTCHA_PUBLIC_KEY));Close & Save new_forum.php