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
|