Difference between revisions of "FormMail Captcha"
From KOP KB
(→Referrers and Recipients) |
(→Calling the Check Captcha) |
||
Line 19: | Line 19: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Calling the Check Captcha == | == Calling the Check Captcha == | ||
+ | You can add this anywhere near &check lines | ||
<syntaxhighlight lang="perl"> | <syntaxhighlight lang="perl"> | ||
# Check the captcha challenge and response. | # Check the captcha challenge and response. | ||
&check_captcha; | &check_captcha; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
== Checking the Captcha == | == Checking the Captcha == | ||
<syntaxhighlight lang="perl"> | <syntaxhighlight lang="perl"> |
Revision as of 00:00, 29 October 2014
Referrers and Recipients
Make sure the customer has this set up properly as well
#whatever domains they decided to use should go in referrers.
@referers = ('www.domain.com','domain.com');
# @recipients defines the e-mail addresses or domain names that e-mail can #
# be sent to. This must be filled in correctly to prevent SPAM and allow #
# valid addresses to receive e-mail. Read the documentation to find out how #
# this variable works!!! It is EXTREMELY IMPORTANT. #
# If we are troubleshooting the receiving make sure this has a string of the email and not a variable #
@recipients = '[email protected]';
Use LWP
This will need to be put just before it shows all the &check's down the page
use LWP::UserAgent;
Calling the Check Captcha
You can add this anywhere near &check lines
# Check the captcha challenge and response.
&check_captcha;
Checking the Captcha
##############################################################################
# Check the CAPTCHA response via the reCAPTCHA service.
sub check_captcha {
my $ua = LWP::UserAgent->new();
my $result=$ua->post(
'http://www.google.com/recaptcha/api/verify',
{
privatekey => '6LfMzPwSAAAAAL8zk68BvstQisi_AIhhCc3hnmTN',
remoteip => $ENV{'REMOTE_ADDR'},
challenge => $Form{'recaptcha_challenge_field'},
response => $Form{'recaptcha_response_field'}
});
if ( $result->is_success && $result->content =~ /^true/) {
return;
} else {
&error('captcha_failed');
}
}