Webcards 1.3 captcha integration

Tor 08 Nov, 2011 07:50

Some good guy integrate a captcha into webcards, because some sapmmers use my webcards to sends out spam with a script.

Here is how you do it...

First you must get here public and private key
http://www.google.com/recaptcha

after that


open language fila and add captcha text
/lang/english/index.php
$lang['captcha_error'] = "wrong captcha, check again";
$lang['captcha_text'] = "please type in captcha words";


open and add after
/templates/preview_card.html :
find

{{render}}

add after

<br>
<br>
{{recaptcha_note}}
{{recaptcha}}


open and add after (change public and private key with your keys)
index.php

find

require "./source/functions.php";

add after

require_once('recaptchalib.php');
define('RECAPTCHA_PUBLIC_KEY', '6Lf23348kSAAwwAABK5w54err6Jjb4......');
define('RECAPTCHA_PRIVATE_KEY', '6Lf23568kSAAAAAI95khgjpsrpyMJ......');


find

$output = preg_replace("/{{date}}/i", date($conf['date_format']), $output);

add after

$note = isset($GLOBALS['recaptcha_note']) ? $GLOBALS['recaptcha_note'] : $lang['captcha_text'];
$output = preg_replace("/{{recaptcha_note}}/", $note, $output);
$output = preg_replace("/{{recaptcha}}/", recaptcha_get_html(RECAPTCHA_PUBLIC_KEY), $output);


find

global $conf, $DB, $lang;

add after

$resp = recaptcha_check_answer (RECAPTCHA_PRIVATE_KEY,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (! $resp->is_valid) {
$GLOBALS['recaptcha_note'] = $lang['captcha_error'];

//izpisi preview, ki spet izpise captcho, a v tem primeru izpise napako namest samo 'prepisi captcho..'
return preview();
}


This works on my webcards, so it should work on yours too

The Trackback URL for this entry is:

http://www.povej.net/forum/trackback.php?e=1030

Avtor Objave
There are no replies for this entry.
Pokaži sporočila: