Don't Fight Spammers... Make Them Earn For You!
If you came across this article thinking that it is some type of method to make money by committing spam, I am happy to burst your bubble and inform you that this is totally the opposite. I do not condone spam, nor do I appreciate spam being sent through my website(s). To put a fine point on this topic, we will be discussing how to make spam sent through contact and comment forms work in the favor of website owners by generating a passive income.
Waging War Against Spammers
A Never Ending Struggle Without A Cease Fire In Sight
We have all seen it before on websites and blogs across the web. Absolutely irrelevant comments usually promoting the latest drug for male enhancement, knock off designer clothes, affiliate links, and more. These spam comments add no value to the content of a website, offer no useful information to other visitors, waste website resources in the processing and storing of these useless messages, and most importantly this spam makes it more difficult to find actual useful information within the relevant comments.
I thought of myself as a diligent webmaster that did an adequate job of filtering out spam from my site's 'contact us' form and in most cases my spam filtering was just adequate. In the beginning when I added a contact form, I set up an array of spam terms and spam text that I would check every message against the spam array before the message was sent. This message checking was in addition to my captcha challenge and IP address logging, all of which significantly reduced the amount of spam received by email through the contact form. However this was just a reduction and spammers tend to be a moving target that continue to test my spam filters and my patience.
One day I had an epiphany about spammers and what they are at the most basic level. Most would consider them a nuisance, some consider them over aggressive internet marketers, but I realized that even though being an undesirable visitor to my site, they are still a website visitor. Now my wheels are turning, because I just found a source of website visitors that are ordinarily a nuisance that I can feel free to make money from without regard to their user experience. As a best practice, I take the user experience into consideration with any advertisement on my site and never use pop ups, pop unders, or other intrusive advertising. That is what I do for visitors that I want to visit my site. Spammers will get a different user experience than the welcomed visitor going forward.
The Internals Of A Spammer Trap
What we will need to create and set a suitable trap for spammers are the following:
- Web hosting equipped with PHP and MySQL.
- A database table to store spammer information.
- A list of spam terms and text to check against
Web Hosting
I'm going to assume that you have your web hosting in place already. If not you can find economical webhosting that will suit your needs by performing a search on your favorite search engine.
Database Table To Store Spammer Info
The file ip_log.sql is included in the source code download and you will just need to import the table into your sites database. The ip_log table consists of these fields:
id int(14) NOT NULL auto_increment,
ip varchar(32) NOT NULL default '',
message text NOT NULL,
banned int(1) NOT NULL default '0',
times_blocked int(11) NOT NULL default '0',
times_accessed int(11) NOT NULL default '0',
date varchar(32) NOT NULL,
With this table we will log IP addresses, the most recent message that a spammer attempts to send, set banned status, and track spammer activity as well as the effectiveness of our efforts.
SPAM Filtering
Here is a sample of the the Anti-SPAM filter that I use. It gets triggered whenever any item in the array is detected within the message text and is inclusive of html tags, meta characters, some known spam words, and a couple of terms that I have seen in spam messages from my logs.
array("spam ", "[url=http", "[link=http", "[/url]", "[/link]", ".com", "~", "`", ";", ":", "!", "@", "#", "&", "^", "*", "(", ")", "_", "-", "+", "=", "{", "}", "|", '"', "]", "[", "<", ">", "%", "<", ">", "img", ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".mp4", ".net", ".org", ".info", ".biz", ".us", ".co.uk", ".ru", "sex", "viag", "vigra", "/", " porn", "nice site", "Ã", "ð", "è", "â", "ò", "ä", "î", "ø", "ì", "ñ", "ü");
This will be a part of the source code download and you will be able to remove or add to the array to make your spam filter as passive or aggressive as you see fit. Just keep with the array format as shown above for example: array("badword", "anotherbadword", "lastbadword");. And don't forget that the last item in an array is not followed by a comma.
Setting The Spammer Trap
You will need to download the monetize_spammers.zip file that contains the 2 scripts that I have written for you, contact.php and comment.php. Theses scripts do most of the heavy lifting for us.
The Monetize Spammers PHP Script can be downloaded from http://www.bigdogapk.com/downloads/monetize_spammers-download.htm
Open contact.php or comment.php and edit the following lines of code:
//Database Settings
define ('DB_HOST',"localhost");
define ('DB_USER',"username_here");
define ('DB_PASSWORD',"password_here");
define ('DB_NAME',"database_name_here");
// Other Settings
$redirect = "http :// adf.ly/633923/pasted.co/5dae60cd"; //Send Spammer Here
$email = "your_email_address_here"; (this is only available in contact.php)
If you are using the contact form, you can save the file contact.php and upload to your server. It is now fully functional.
If you are using the comment form, you will need to edit some more to allow storage of comments in your existing database in order to display comments on tour site. In comment.php go to line 62 where you will find the following commented code:
//Put Your Code Here To Post Comment, Insert Comment into database, etc.
This is where you will put your code that processes comments that are successfully posted. Here is an example of what you might include:
mysqli_query($conn, "INSERT INTO comments (commenter, comment, time) VALUES ('".mysqli_real_escape_string($conn, $_POST[commenter])."', '".mysqli_real_escape_string($conn, $_POST[comment])."', 'time()')");
This is a very simple example where the commenter's name or email is stored, the comment made is stored, and the time that the comment was posted is stored. Once this is done, save your comment.php file and upload to your server.
We Caught A Spammer. Now What?
Let's Monetize The Spammer
There are 3 things that are a certainty in life. Death, Taxes, and Spam. You will get some spam sooner or later (I'd bet money that it will be sooner), so let's discuss how you will profit from these spammers.
In both the contact.php and comment.php files, there is the line:
$redirect = "http :// adf.ly/633923/pasted.co/5dae60cd";
This is where you send the spammer. Hopefully you are sending the spammer to your landing page that pays you for every impression or interstitial advertising of some sort. I use Adf.ly for interstitial ads and it allows for easy integration with needing a special shortened URL. Sign up for Adf.ly here http://bit.ly/adfly_join
Okay now that you have Adf.ly, we are going to get a little more income while giving the spammer a message about being caught sending spam. Using Pasted or any other similar service, we will create a custom message to our spammer. See my example message to spammers here --> http://pasted.co/5dae60cd.
I use Pasted because it pays $2.00 for every 1,000 views. At this point you can send the spammer to Adf.ly or send the spammer to your Pasted, but I prefer to send the spammer to Pasted by way of Ad.fly by simply combining the URL like so: http :// adf.ly/633923/pasted.co/5dae60cd. I must mention that when adding the destination URL to your Adf.ly URL, remove the 'http://' from your destination URL before appending to your Adf.ly URL.
Example: http :// adf.ly/633923/http :// pasted.co/5dae60cd <-- Incorrect!
Example: http :// adf.ly/633923/pasted.co/5dae60cd <-- Correct!
Now we will get revenue from Adf.ly and Pasted, give spammers a written notice that we have caught them in the act, and protect our site from spam. You won't get rich monetizing spammers but you will earn passive income from them.
The Admin Control Panel
With the included Admin Control Panel you will be able to see your spammers activity in real time and exactly how our script is handling the spammers interaction with our contact and comment forms. The included admin.php file retrieves the IP log and allows for manual banning/un-banning, logging of messages attempted and sent, time stamp of the most recent activity for users from each IP address, and the ability to search the IP log for specific IP addresses.
Open admin.php and edit the following lines:
define ('DB_HOST',"localhost");
define ('DB_USER',"username_here");
define ('DB_PASSWORD',"password_here");
define ('DB_NAME',"database_name_here");
define ('ADMIN_USERNAME',"admin_username_here");
define ('ADMIN_PASSWORD',"admin_password_here");
define('TIMEOUT_MINUTES', 0); //timeout after NN minutes of inactivity. Set to 0 to not timeout (log out automatically)
Save the admin.php file and upload to your admin folder (or where ever you would like to access the control panel from). You will need to login to the admin panel using the admin username and admin password that you set in the admin.php file.
Source Code Download & Examples
Monetize Spammers PHP Script - http://www.bigdogapk.com/downloads/monetize_spammers-download.htm
[Source code download]
Sign Up For Ad.fly - http://bit.ly/adfly_join
[Income source for monetizing your spammers]
Sign Up For Pasted - http://pasted.co
[Another source for monetizing your spammers]
Example Message To Spammers - http://pasted.co/5dae60cd
[You can copy this message into your own Pasted]
Example Redirect Link - http://adf.ly/633923/pasted.co/5dae60cd
[How We Redirect & Monetize Our Spammers]