Skip to content

Instantly share code, notes, and snippets.

@juffee
Created March 12, 2013 06:28
Show Gist options
  • Save juffee/5140768 to your computer and use it in GitHub Desktop.
Save juffee/5140768 to your computer and use it in GitHub Desktop.
<?php
/**
REFERENCE:
http://planetozh.com/blog/my-projects/honey-pot-httpbl-simple-php-script/
https://www.projecthoneypot.org/
**/
function checkIfCleanIp($ipToCheck, $apikey){
// Project Honeypot
// your http:BL key
// sample: $apikey = 'jlonedutoxea';
// build the lookup DNS query
// Example : for '127.9.1.2′ you should query 'abcdefghijkl.2.1.9.127.dnsbl.httpbl.org'
$lookup = $apikey . '.' . implode('.', array_reverse(explode ('.', $ipToCheck ))) . '.dnsbl.httpbl.org';
// check query response
$result = explode( '.', gethostbyname($lookup));
$test = gethostbyname($lookup);
if ($result[0] == 127) {
// query successful !
$activity = $result[1];
$threat = $result[2];
$type = $result[3];
if ($type & 0) $typemeaning .= 'Search Engine, ';
if ($type & 1) $typemeaning .= 'Suspicious, ';
if ($type & 2) $typemeaning .= 'Harvester, ';
if ($type & 4) $typemeaning .= 'Comment Spammer, ';
$typemeaning = trim($typemeaning,', ');
return false;
} else {
return true;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment