This code prevents known spammers (checked against the stopforumspam.com email database) from registering.
I’ve used it in core/modules/Registration/Registration.php within the ProcessRegistration function, as so:
// Check email for known spammer
$url = 'http://www.stopforumspam.com/api?email='.$data['email'];
$file = new CodonWebService();
$contents = $file->get($url);
$response = simplexml_load_string($contents);
if($response->appears == 'yes'){
$spammer = true;
} else {
$spammer = false;
}
if($spammer){
$this->set('message', 'Your email appears on our spam database, we therefore assume you are a spammer and are rejecting your registration request. If you feel this is incorrect please contact us.');
$this->render('core_error.tpl');
return false;
}
It could be condensed a little, but I feel this makes it easier to understand.
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 6: parser error : Opening and ending tag mismatch: hr line 5 and body in /home/flyeurop/public_html/core/modules/Registration/Registration.php on line 89
Warning: simplexml_load_string() [function.simplexml-load-string]: </body> in /home/flyeurop/public_html/core/modules/Registration/Registration.php on line 89
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/flyeurop/public_html/core/modules/Registration/Registration.php on line 89
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 7: parser error : Opening and ending tag mismatch: body line 3 and html in /home/flyeurop/public_html/core/modules/Registration/Registration.php on line 89
Warning: simplexml_load_string() [function.simplexml-load-string]: </html> in /home/flyeurop/public_html/core/modules/Registration/Registration.php on line 89
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/flyeurop/public_html/core/modules/Registration/Registration.php on line 89
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 8: parser error : Premature end of data in tag html line 1 in /home/flyeurop/public_html/core/modules/Registration/Registration.php on line 89
Warning: simplexml_load_string() [function.simplexml-load-string]: in /home/flyeurop/public_html/core/modules/Registration/Registration.php on line 89
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/flyeurop/public_html/core/modules/Registration/Registration.php on line 89
I have a feeling they may have blocked the fivedev server IP. I wouldn’t know why seeing as we’d only be using it for registrations which is ok (they block if you use it too regularly - every visit to your site).
Either that or for some reason it’s a problem with our end?
A more effective solution is to check BOTH email and IP:
// Check email & IP for known spammer
$url = 'http://www.stopforumspam.com/api?email='.$data['email'].'&ip='.$_SERVER['REMOTE_ADDR'];
$file = new CodonWebService();
$contents = $file->get($url);
$response = simplexml_load_string($contents);
$spammer = false;
foreach($response->appears as $appears){
if($appears == 'yes'){
$spammer = true;
}
}
if($spammer){
$this->set('message', 'Your email address or IP appears on our spam database, we therefore assume you are a spammer and are rejecting your registration request. If you feel this is incorrect please contact us.');
$this->render('core_error.tpl');
return false;
}
I have added this script to my VA as well as I was getting the same problem with the roster filling up with spam accounts and have not had a real issue since. I also added a quick email function to send me an email each time a registration is rejected just to see if it was working and it is rejecting on average 10 a day from my site. No matter how detailed you get there will always be something that gets through but that is what website management is all about.
The code I am using including the email function
// Check email for known spammer
$url = 'http://www.stopforumspam.com/api?email='.$data['email'].'&ip='.$_SERVER['REMOTE_ADDR'];
$file = new CodonWebService();
$contents = $file->get($url);
$response = simplexml_load_string($contents);
if($response->email == 'yes' || $response->ip == 'yes'){
$this->set('message', 'Your email or IP address appears on our spam database, we therefore assume
you are a spammer and are rejecting your registration request. If you feel this is incorrect please contact us.');
$this->render('core_error.tpl');
//send email that spam registration rejected
$email = 'your email address';
$sub = 'Spam Registration Rejected';
$message = 'Spam pilot registration rejected using email '.$data['email'].' and
IP address '.$_SERVER['REMOTE_ADDR'].' on '.date('m/d/Y', time()).' at '.date('g:ia', time());
Util::SendEmail($email, $sub, $message);
return false;
}
//end spam check
I tried your code but it does not work, I tried to register with an email to my site taken from "http://www.stopforumspam.com" and the registration is successful