Tutorial Center
On this page, we will try to explain how the anti spam system works and integrates with your site to stop spam signups and submissions.
In essense, after adding some code to your site signup and/or submission page, every signup/submission will ask our site to check for a pre-existing spammer's record (Like $_POST / $_GET methods), and responding back if there is one. If there is no response back from our site, it means there is no matching record.
NOTE: It's best to ask you hosting provider if your account can use "file_get_contents" or "cURL" before trying to check or send data to us.
Checking Our Records
Any php compatible code to check for a matching response returned from our site will work. The response returned from our site will always be a simple "Yes" if the record is found that you are checking for. Nothing is returned if not found. The arguments you can check for are:
- username
- ip
You can check for a spammer record using all, a couple or just one of those search terms (all of course is best!). The default form for checking all the search terms above is like this:
http://www.spambusted.com/api.php?email=xxxx&username=xxxx&ip=xxxx
Of course, you'd replace the "xxxx" with your own variables from your site, and each variable your site sends should be urlencode encoded. Below is an example of how to add urlencode to each variable:
// Put your site's email/IP/username variables into the variables to send...
$email = urlencode($scripts_email_variable);
$ip = urlencode($_SERVER['REMOTE_ADDR']);
$user = urlencode($scripts_username_variable);
$url = 'http://www.spambusted.com/api.php?email='.$email.'&ip='.$ip.'&username='.$user;
// Or, directly into the url to send to us:
$url = 'http://www.spambusted.com/api.php?email='.urlencode($scripts_email_variable).'&ip='.urlencode($ip);
// line above should be one line
The following file_get_contents & cURL examples are about the simplest way to go. They just check if there is a "Yes" from our site, and if not, they let the user continue on with their signup. If a "Yes" IS returned ( the 'if(!empty($Contents)' part of the code ), then you can send the spammer (as shown in the examples) to another page, or whatever you wish.
Example file_get_contents Code
// Put the stop article spam URL into a variable...
$SAS_url = "http://www.spambusted.com/api.php";
// Check a couple things to see if we can use file_get_contents
$wrap = ini_get('allow_url_fopen');
if(function_exists('file_get_contents') && $wrap == '1')
{
// Yes, using file_get_contents is good so urlencode and send the variables!
$email = urlencode($varEmail);
$ip = urlencode($varLogginIP);
$Contents = @file_get_contents($SAS_url.'?email='.$email.'&ip='.$ip);
if(!empty($Contents) && $Contents == 'Yes')
{
// A 'Yes' was returned by spambusted.com, which means one of the submitted variables was
// found in the database!
// You can send rejected signups to a custom ban.php page to let them know they were denied
// and why, Or you can do anything you want if the signup is denied from right here!
header("location:ban.php"); // custom rejection page
die();
}
}
cURL Code Example
Some shared hosting services have file_get_contents turned off, so you can try using curl instead.
//setup new variables to using your existing script's variables
$email = urlencode($VarEmail);
$ip = urlencode($posted_ip);
$username = urlencode($VarUsername);
// check if we can use curl
if(function_exists('curl_init'))
{
// yep, we are good to go!
$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='.$email.'&ip='.$ip.'&username='.$username);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$Contents = curl_exec($ch);
curl_close($ch);
if(!empty($Contents) && $Contents == 'Yes')
{
// A 'Yes' was returned by spambusted.com, which means one of the submitted variables was
// found in the database!
// You can send rejected signups to a custom ban.php page to let them know they were denied
// and why, Or you can do anything you want if the signup is denied from right here!
header("location:ban.php");
die();
}
}
You could combine the two examples by adding an 'else' (after the last closing bracket) to the end of the file_get_contents example, and another closing bracket at the end of the cURL example.
Sending Us Banned Users
We encourage everyone that uses this service to please give back by sending us the people's info that you ban from your site. This will help us, and those others using our service to also stop spammer signups. We can only grow with your help!
Please don't send just one variable like the email. Send at least AT LEAST the following three variables ( email, ip number, & username).
Why? Because spammers user multiple emails, ip and usernames, and we track them to match the same spammer using multiple emails, ip's and usernames. If you only send the username or email, and the spammer uses 25 different usernames (or different variations of the same email address) and the same IP number, we won't know it's the same guy! Plus, your incomplete submission will not be indexed quickly (and others doing a search for the spammer won't find the info) from our index page as we don't show the incomplete submissions without the ip and email addresses.
Before sending info, you will need an API Key number, and if you haven't gotten one yet, Click Here to get one now!
Once you have your API Key, you can use any of the code examples above for submitting to our site, but you will add an &api= to the end of the variables:
http://www.spambusted.com/api.php?email=xxxx&username=xxxx&ip=xxxx&api=xxxx
Again, you'd replace the "xxxx" with your actual API Key variable or string (like this api=myactualapikeynumberhere).
cURL Send Data To Us Example
You wouldn't have to use the check for content returned, and be sure to add an $api_key variable as shown below:
//setup variables to using our existing script's variables and send after url encoding
$email = $VarEmail;
$ip = urlencode($posted_ip);
$username = urlencode($VarUsername);
// ADDED THE API_KEY VARIABLE BELOW TO HOLD MY API KEY NUMBER!;
$api_key = urlencode("myactualapikeynumberhere");
// check if we can use curl
if(function_exists('curl_init'))
{
// yep, we are good to go!
$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);
// ADDED THE API VARIABLE AT THE END OF THE STRING BELOW!;
curl_setopt($ch, CURLOPT_POSTFIELDS, '?email='.$email.'&ip='.$ip.'&username='.$username.'&api='.$api_key);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$Contents = curl_exec($ch);
curl_close($ch);
}
fsockopen POST Example
This code may not work if you are on a shared hosting server, so be sure to verify (as with all the code examples) whether it works or not!
function PostIt($data)
{
$fp = fsockopen("www.spambusted.com",80);
fputs($fp, "POST /api.php HTTP/1.1\n" );
fputs($fp, "Host: www.spambusted.com\n" );
fputs($fp, "Content-type: application/x-www-form-urlencoded\n" );
fputs($fp, "Content-length: ".strlen($data)."\n" );
fputs($fp, "Connection: close\n\n" );
fputs($fp, $data);
fclose($fp);
}
// TO USE THIS FUNCTION TO POST DATA, SEND IT THIS DATA
// USING YOUR SCRIPT'S VARIABLES TO REPLACE THE XXXX'S!
// Be sure to urlencode the data before sending though.
PostIt(email=xxxx&ip=xxxx&username=xxxx&api=xxxx);
file_get_contents Example
// Put the stop article spam URL into a variable...
$SAS_url = "http://www.spambusted.com/api.php";
// Check a couple things to see if we can use file_get_contents
$wrap = ini_get('allow_url_fopen');
if(function_exists('file_get_contents') && $wrap == '1')
{
// Yes, using file_get_contents is good so urlencode and send the variables!
$email = urlencode($varEmail);
$ip = urlencode($varLogginIP);
$api_key = urlencode("myactualapikeynumberhere");
$Contents = @file_get_contents($SAS_url.'?email='.$email.'&ip='.$ip.'&api='.$api_key);
// The line above would normally be one line instead of two as shown!
}

