Forum Moderators: coopster
Great Forum! I got a hold of this script that checks an IP against blacklisted databases. However, it only displays 1 listing, even if there are multiple. How could I get it to display all of them?
<?php// Retrieves the IP of the client
function getip () {
$ip="192.168.1.0";
return $ip;
}
// Queries multiple block lists
function dnsblquery ($ip) {
$dnsbllist = array(
"spamlist1.example.net",
"spamlist2.example.net",
"spamlist3.example.net",
"spamlist4.example.net",
"spamlist5.example.net" // Keep this one last.
);
if ($ip) {
// Reverses the IP
$ips = explode(".", $ip);
$ipreverse = "$ips[3].$ips[2].$ips[1].$ips[0]";
// Queries the block lists listed in dnsbllist
for ($i=0;$i<count($dnsbllist);$i++) {
if (checkdnsrr("$ipreverse.$dnsbllist[$i]", "A")) {
// Returns the blacklist the queried IP is on
return $dnsbllist[$i];
}
}
}
return FALSE;
}
$blocker = dnsblquery(getip());
if ($blocker) {
// Blocked behaviour
// -----------------
echo "Your IP, ".getip().", has been blacklisted by $blocker";
// -----------------
exit;
}
[edited by: coopster at 10:42 am (utc) on April 8, 2005]
[edit reason] generalized url per TOS [webmasterworld.com] [/edit]
The majority of web users do not have static ip addresses. So, wouldn't you be running the risk of banning someone that has never been to your site?
I guess what I am getting at is, if I were to get blacklisted on your site, could I not simply open a command prompt, ipconfig/release ipconfig/renew? I have a new ip addy so, I'm in. Right? And the next poor sap that gets my "banned" ip cant get in.
Like I said, just curious. Trying to learn like everyone else.
IamStang
In order to return all of them you would need to accumulate the values instead of returning the first one you hit. This part of your code
// Returns the blacklist the queried IP is on
return $dnsbllist[$i];