Oct 9th, 2012, 11:17 PM
Hi,
I've been using stopforumspam.com to block automatically spams, without having to use captchas.
It's just a hook that checks if the submitted ip or email address (which is required in all our forms) has already been black listed.
It is not perfect but has been quite efficient, used on top of the honey pot method.
Here is the code I use in the Hook Manager, under the "ft_process_form, start" Code Hook:
Feedback is welcome.
I'd love to see it integrated in a spam module
I've been using stopforumspam.com to block automatically spams, without having to use captchas.
It's just a hook that checks if the submitted ip or email address (which is required in all our forms) has already been black listed.
It is not perfect but has been quite efficient, used on top of the honey pot method.
Here is the code I use in the Hook Manager, under the "ft_process_form, start" Code Hook:
PHP Code:
$spam=0;
$max_frequency = 3;
$email = $_POST['email'];
$ip = $_SERVER['REMOTE_ADDR'];
// Check EMAIL on stopforumspam.com
if(isset($_POST['email'])){
$spam_xml = @file_get_contents("http://www.stopforumspam.com/api?email=$email");
$appears = value_in('appears', $spam_xml);
$frequency = value_in('frequency', $spam_xml);
if($appears=="yes" and $frequency>$max_frequency){
$spam=1;
}
}
// Check IP on stopforumspam.com
if(! $spam and isset($_POST['email'])){
$spam_xml = @file_get_contents("http://www.stopforumspam.com/api?ip=$ip");
$appears = value_in('appears', $spam_xml);
$frequency = value_in('frequency', $spam_xml);
if($appears=="yes" and $frequency>$max_frequency){
$spam=1;
}
}
if($spam==1){
$form_data["form_tools_ignore_submission"] = true;
}
function value_in($element_name, $xml, $content_only = true) {
if ($xml == false) {
return false;
}
$found = preg_match('#<'.$element_name.'(?:\s+[^>]+)?>(.*?)'.
'</'.$element_name.'>#s', $xml, $matches);
if ($found != false) {
if ($content_only) {
return $matches[1]; //ignore the enclosing tags
} else {
return $matches[0]; //return the full pattern match
}
}
// No match found: return false.
return false;
}
Feedback is welcome.
I'd love to see it integrated in a spam module