Message Board

http:BL Use/Development

Older Posts ]   [ Newer Posts ]
 Help with PHP and http:BL
Author: S.Fsdfsd   (25 Jan 11 1:02pm)
I've written down a simple function:

function checkSpam() {
$apikey = 'MYKEY';
$ip = '202.111.175.31';
//$ip = $_SERVER['REMOTE_ADDR'];
$lookup = $apikey.'.'.implode('.', array_reverse(explode('.',$ip))).'.dnsbl.httpbl.org';
$result = explode('.', gethostbyname($lookup));
echo gethostbyname($lookup);
if($result[0] == 127) {
$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, ';
if(($type>= 4 && $threat> 1) || ($type <4 && $threat> 40)) $block = true;
}
if ($block) die();
}

I test is with a "massivly-spamming-ip" (found here). But I've get no result. My var_dump($result) looks like this:

array(8) { [0]=> string(12) "nepbfpiahhuc" [1]=> string(2) "31" [2]=> string(3) "175" [3]=> string(3) "111" [4]=> string(3) "202" [5]=> string(5) "dnsbl" [6]=> string(6) "httpbl" [7]=> string(3) "org" }

It's the "normal" $lookup... If I browser to the url, which is in $lookup, I've get the message, that the url isn't found.

Any idea? :(
 
 Re: Help with PHP and http:BL
Author: P.Martin5   (4 Mar 11 3:53am)
This works for me. First off when testing use a real IP Address, get one from the BL list that way you can see if the result is correct.
The Dig example needs some code to parse & extract the result, the hostbyname returns just the result.

I Hope this helps


function dodig($apikey,$nserv,$ip){
$itman = $nserv . " " . $apikey . "." . $ip . "." . "dnsbl.httpbl.org";
$host = `dig $itman A`;
return ($host);
}

function dolookup($apikey,$ip){
$itman = $apikey . "." . $ip . "." . "dnsbl.httpbl.org";
$host = gethostbyname($itman);
return ($host);
}


$apikey = 'myownapikey'; // your api key
$nserv = 'ns1.MYIPSNAMESERVER.net'; // namesever I used the one holding my domains
$ip = '178.32.81.224'; // best to use a fresh one
$what2lookup = implode('.', array_reverse(explode('.',$ip)));

$result1 = dodig($apikey,$nserv,$what2lookup);
echo "<br><br>dig result = " . $result1;

$result2 = dolookup($apikey,$what2lookup);
echo "<br><br>hostbyname result = " . $result2;



********** output when run ***********

dig result = ; <<>> DiG 9.5.1-P3 <<>> ns1.MYIPSNAMESERVER.net myownapikey.224.81.32.178.dnsbl.httpbl.org A ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61752 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;ns1.MYIPSNAMESERVER.net. IN A ;; ANSWER SECTION: ns1.MYIPSNAMESERVER.net. 83044 IN A 195.166.128.16 ;; Query time: 1 msec ;; SERVER: 212.159.13.49#53(212.159.13.49) ;; WHEN: Fri Mar 4 11:35:40 2011 ;; MSG SIZE rcvd: 48 ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10504 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;myownapikey.224.81.32.178.dnsbl.httpbl.org. IN A ;; ANSWER SECTION: myownapikey.224.81.32.178.dnsbl.httpbl.org. 300 IN A 127.1.49.5 ;; Query time: 134 msec ;; SERVER: 212.159.13.49#53(212.159.13.49) ;; WHEN: Fri Mar 4 11:35:40 2011 ;; MSG SIZE rcvd: 77

hostbyname result = 127.1.49.5



do not follow this link

Privacy Policy | Terms of Use | About Project Honey Pot | FAQ | CloudFlare Site Protection | Contact Us

Copyright © 2004–14, Unspam Technologies, Inc. All rights reserved.

contact | wiki | email