Topic: stop forum spammer signups
Hopefully I'm posting this in the right place and that it helps someone!
This addition to your signup page uses the stoparticlespam site for blocking previously reported (387K) spammer signups. It sends the signups ip, email and username for checking and if any are found, returns a "Yes" so you can send them to a custom denied page or wherever you wish.
Open register.php and find this code:
if (empty($errors))
{
$username = forum_trim($_POST['req_username']);
$email1 = strtolower(forum_trim($_POST['req_email1']));
Right under the $email1 line, copy/paste this code:
//////////////////////////////////////////////////////////////////////////////////////////////
// stoparticlespam code start
$ip_check = "";
$ip_check = $_SERVER['REMOTE_ADDR'];
$SAS_url = "";
$SAS_url = "http://www.stoparticlespam.info/api.php";
// CHECK STOPARTICLESPAM FOR SPAMMER
$wrap = ini_get('allow_url_fopen');
if(function_exists('file_get_contents') && $wrap == '1')
{
$Contents = @file_get_contents($SAS_url.'?email='.urlencode($email1).'&ip='.urlencode($ip_check).'&username='.urlencode($username));
if(!empty($Contents) && $Contents == 'Yes')
{
// Your custom message
header('HTTP/1.1 400 Bad Request');
die("<br><br><h3 style='color:red;text-align:center;'>Sorry, but you have been listed for spamming at stoparticlespam.</h3><p style='text-align:center;'>If you feel this is an error, please contact us!</p>");
}
}else{
// file_get_contents won't work so we'll try cURL instead!
if(function_exists('curl_init'))
{
$ch = curl_init();
$timeout = 6; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $SAS_url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '?email='.urlencode($email1).'&ip='.urlencode($ip_check).'&username='.urlencode($username));
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$Contents = curl_exec($ch);
curl_close($ch);
if(!empty($Contents) && $Contents == 'Yes')
{
///// A 'Yes' was returned by stoparticlespam, which means one of the submitted variables was found in their database!
// Your custom message
header('HTTP/1.1 400 Bad Request');
die("<br><br><h3 style='color:red;text-align:center;'>Sorry, but you have been listed for spamming at stoparticlespam.</h3><p style='text-align:center;'>If you feel this is an error, please contact us!</p>");
}
}
}
// end stoprarticlespam code
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The code above will try using file_get_contents and if it's not enabled, try checking with cURL instead. The
// Your custom message
header('HTTP/1.1 400 Bad Request');
die("<br><br><h3 style='color:red;text-align:center;'>Sorry, but you have been listed for spamming at stoparticlespam.</h3><p style='text-align:center;'>If you feel this is an error, please contact us!</p>");
part is what sends the denied person to wherever you wish them to go or see if denied. You can also change that part to send them to a custom page if you wish.
best,
Jan