EQdkp Plus Navigation:   Home  |   Forum  |   Wiki  |   Translate  |   Bugtracker  |   WebSVN  |  USVN

Recaptcha

From EQdkp Plus Wiki

Information
min. EQDKP-PLUS Version 0.7.0.0




To provent SPAM, you can use the Recaptcha-library.

Displaying the challenge

In order to implement a table with the captcha-image and submit-button, use the following function:

$captcha = new recaptcha;
 
$tpl->assign_vars(array(								
	'CAPTCHA' => $captcha->GenerateCaptcha(),				
));

You have to embedd the {CAPTCHA}-Template-Variable into a form-tag:

<form>
{CAPTCHA}
</form>

If you just want to use the challenge-image, use this function:

$captcha = new recaptcha;
 
$tpl->assign_vars(array(								
	'CAPTCHA'  => $captcha->recaptcha_get_html($conf_plus['lib_recaptcha_okey']),				
));

$conf_plus['lib_recaptcha_okey'] is the public recaptcha-key from the settings.

Make shure that you've an div with the id "recaptcha_image" where the image will be shown in:

<form>
{CAPTCHA}
<div id="recaptcha_image"></div>
<input type="text" id="recaptcha_response_field" name="recaptcha_response_field"/>
<input type="submit" value="Submit" name="captcha_submit" />
</form>

Validating the challenge

Here's an example of prooving if the challenge-code is valid:

$captcha = new recaptcha;
$response = $captcha -> recaptcha_check_answer ($conf_plus['lib_recaptcha_pkey'], $_SERVER["REMOTE_ADDR"], $in->get('recaptcha_challenge_field'), $in->get('recaptcha_response_field'));
 
if ($response->is_valid) {
...
}