Part 0: get a key set https://www.google.com/recaptcha/admin/create
Part 1: install reCAPTCHA
Code: Select all
cpan Captcha::reCAPTCHA
Part 2: add to CustomerLogin.dtl (hopefully in your own theme). Additional lines are shown for position purposes
Code: Select all
# <tr>
# <td>$Text{"CustomerID"}: </td>
# <td> <input type="text" name="CustomerID" value="$QData{"UserCustomerID"}" size="25" maxlength="50"/></td>
# </tr>
# begin recaptcha
<tr>
<td> </td>
<td>$Data{"reCAPTCHA"}</td>
</tr>
#end recaptcha
</table>
<input class="button" type="submit" value="$Text{"Create"}"/>
Part 3: modify Kernel/Output/HTML/Layout.pm (after backing it up) to show the code
in the top where the use section is, add
Code: Select all
use Captcha::reCAPTCHA;
Code: Select all
if (
$Self->{ConfigObject}->Get('CustomerPanelCreateAccount')
&& $Self->{ConfigObject}->Get('Customer::AuthModule') eq
'Kernel::System::CustomerAuth::DB'
)
{
#begin recaptcha
my $rc = Captcha::reCAPTCHA->new;
my $rccustom = "<script type= \"text/javascript\">\n
var RecaptchaOptions = {\n
lang : 'en',
};\n
</script>\n";
$Param{reCAPTCHA} = $rccustom . $rc->get_html("your_recaptcha_public_key");
#end recaptcha
$Self->Block(
Name => 'CreateAccount',
Data => \%Param,
);
}
near the top of the file where the use lines are, again add:
Code: Select all
use Captcha::reCAPTCHA;
Code: Select all
# check needed params
if ( !$GetParams{UserCustomerID} ) {
$GetParams{UserCustomerID} = $GetParams{UserEmail};
}
if ( !$GetParams{UserLogin} ) {
$GetParams{UserLogin} = $GetParams{UserEmail};
}
# check reCAPTCHA
my $rc = Captcha::reCAPTCHA->new;
my $challenge = $Self->{ParamObject}->GetParam( Param => 'recaptcha_challenge_field' ) || '';
my $response = $Self->{ParamObject}->GetParam( Param => 'recaptcha_response_field' ) || '';
my $result = $rc->check_answer("your_private_recaptcha_key", $ENV{'REMOTE_ADDR'},
$challenge, $response
);
if ( !$result->{is_valid} ) {
my $Output = $Self->{LayoutObject}->CustomerHeader( Area => 'Core', Title => 'Error' );
$Output .= $Self->{LayoutObject}->CustomerWarning(
Message => 'reCAPTCHA entry failed.',
Comment => 'Please press Back and try again.'
);
$Output .= $Self->{LayoutObject}->CustomerFooter();
$Self->{LayoutObject}->Print( Output => \$Output );
exit 0;
}
#end recaptcha
Edit: Added the customization javascript to the Layout.pm so anyone can change the language that the reCAPTCHA shows. The following languages are supported:
Language Code
English en
Dutch nl
French fr
German de
Portuguese pt
Russian ru
Spanish es
Turkish tr
http://code.google.com/apis/recaptcha/d ... .html#i18n