Skip to content
Snippets Groups Projects
Commit 043cd113 authored by Michael Fairchild's avatar Michael Fairchild
Browse files

use the DNS2 lib to directly query the http:bl name servers so that we are not...

use the DNS2 lib to directly query the http:bl name servers so that we are not served with cached data.
parent 01e8afaa
No related branches found
No related tags found
No related merge requests found
......@@ -77,14 +77,28 @@ $rules['ip'][] = function($spam) {
};
$rules['ip'][] = function($spam) {
//http:BL key
$apikey = 'mbgdkipxwcsn';
//example: for '127.9.1.2' you should query 'apikey.2.1.9.127.dnsbl.httpbl.org'
$lookup = $apikey . '.' . implode('.', array_reverse(explode ('.', $spam ))) . '.dnsbl.httpbl.org';
// check query response
$result = explode( '.', gethostbyname($lookup));
$nameServers = array('209.124.55.46', '66.114.104.118', '81.17.242.92');
//Directly query the http:BL name servers to bypass cached dns results.
$resolver = new Net_DNS2_Resolver(array('nameservers' => $nameServers));
//Query
try {
$result = $resolver->query($lookup, 'a');
} catch(Net_DNS2_Exception $e) {
return;
}
//Loop though answers
foreach($result->answer as $record) {
$result = explode( '.', gethostbyname($record->address));
//Check if the query was successful
if ($result[0] == 127) {
......@@ -103,14 +117,16 @@ $rules['ip'][] = function($spam) {
*/
$type = $result[3];
if ($threat > 10) {
if ($threat >= 1) {
//Log spam so that we can tell how well this is working...
$log = date("Y-m-d H:i:s") . " -- IP: $spam - Result: " . implode('.', $result) . " ---- BLOCKED" . PHP_EOL;
file_put_contents(sys_get_temp_dir() . '/spamHits.log', $log, FILE_APPEND);
//We found some spam!!!
return true;
}
}
}
return false;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment