PHP Classes
elePHPant
Icontem

Spam blocker: Check visitor IP address in Project Honey Pot RBL

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   Screenshots Screenshots   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2009-02-19 (6 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 616 All time: 4,765 This week: 1,259Up
Version License PHP version Categories  
spam_blocker 1.5BSD License5.0Networking, PHP 5, Security
Description Author  

This class can be used to check spamming and other malicious and undesirable visitors' IP addresses in Project Honey Pot RBL (Realtime Black List).

It can perform a query to the Project Honey Pot RBL DNS server for a given IP address using your RBL API key.

The class analyzes the RBL response and sets a session variable if the current user IP address is of a spammer that should be blocked.

The blocked and allowed addresses are logged to a file or to tables of a mysql database.

Innovation Award  
PHP Programming Innovation award nominee
February 2009
Number 5


Prize: One downloadable copy of PhpED Professional
Every day attempts to spamming sites grows, causing excessive load to site servers, not to mention when spam robots infiltrate unwanted content.

This class provides a solution to help PHP sites quickly block spam robots IP addresses using the Project Honey Pot black list.

Manuel Lemos
Picture of Alec Scaresbrook
Name: Alec Scaresbrook <contact>
Classes: 1 package by
Country: United Kingdom United Kingdom
Age: ???
All time rank: 2754125 in United Kingdom United Kingdom
Week rank: 1577 Up75 in United Kingdom United Kingdom Up
Innovation award
Innovation award
Nominee: 1x

Details provided by the author  
***************************************************************************
Copyright (c) 2009, Alec Scaresbrook All rights reserved.
***************************************************************************
To use spam blocker:

Note: Your server has to be running PHP 5, unless you change the spam blocker class code to run on PHP 4.

1 Join Project Honey Pot (http://www.projecthoneypot.org) and contribute to the project. Obtain an API key for querying the Project Honey Pot database. 
Find var $apikey = 'abc'; in the spam blocker class code.
Replace 'abc' with the Project Honey Pot API key.

2. Put the spam_blocker_class.php in a folder in the root of your web files.

3. Put the following code at the beginning (above the header) of each web page to be protected. I've put it on every page.

<?php 
    session_start();
    include( "class/spam_blocker_class.php");
    $ip->spam_blocker_control("");
?>
Change the folder name 'class/' if required. 
Within the two double quotes of the spam_blocker_control("") code you can specify a path to the folder where the visitor files are to be written.  Example: $ip->spam_blocker_control("visitor_files/"); 

Make that folder on the development computer (if required) and the server, and make sure that write permissions are set.  If the two double quotes are left empty, then the visitor files are written in your web page root.

4. The file 'spam_blocker_connection.php' is for connecting into your mysql database. Tables are automatically created in the database you specify. By default the server connection variables are empty which means files are written by default. 

Put the 'spam_blocker_connection.php' file in the root of your web files, unless you want it in a folder, then change the path for 'include ("spam_blocker_connection.php");' in the 'spam_blocker_class.php' file code.

Notes:
It is easy to forget that spam blocker is working in the background all the time, which means that a large amount of visitor data accumulates, so I've added a switch so that the writing of data can be disabled. 

Just under 'var $apikey = 'abc';' is 'var $write_data = true;'.  Change the '$write_data' value 'true' to false, to disabled the writing of data.
      
Screenshots  
  • readme_file.jpg
  • programming.jpg
  • example_filelist.gif
  Files folder image Files  
File Role Description
Plain text file 00_search_engine.dat Output Typical search engine visits
Plain text file 05_allowed_suspici...comment_spammer.dat Output Access allowed - suspicious comment spammert
Plain text file 05_blocked_suspici...comment_spammer.dat Output Access blocked - suspicious comment spammer
Image file filelist.gif Screen Typical activity file list after a few hours
Accessible without login Plain text file readme.txt Doc. Readme file for spam blocker
Plain text file spam_blocker_class.php Class Main class for spam blocker
Plain text file spam_blocker_connection.php Conf. mysql connection file

 Version Control Unique User Downloads Download Rankings  
 0%Total:616All time:4,765
 This week:0This week:1,259Up