I have completed your requested script. You can download the file at:
There are two versions of the script, one for a unix server and one
for a windows server. The reason for this is that the windows port of
php does not have one of the required functions. If you are unsure of
which your webserver is running, use the unix version
(dnsblquery_unix.php) first. If you recieve an error ("Fatal error:
Call to undefined function: checkdnsrr()"), then switch to the windows
To use the script, simply insert the line:
<? include("dnsblquery_unix.php"); ?>
<? include("dnsblquery_win.php"); ?>
at the top of your scripts, modifying the include path according to
your directory structure.
The script currently uses the sbl-xbl.spamhaus.org database (which is
the sbl and xbl database combined). This can be easily changed if you
have another preference. I have also designed the script so that you
can check multiple block lists. To do so, simply modify the $dnsbllist
array (the line that currently looks like "$dnsbllist =
array("sbl-xbl.spamhaus.org");") in the dnsblquery function. Remember
to keep the following format:
$dnsbllist = array("sbl-xbl.spamhaus.org", "blocklist2", "blocklist3");
You can also change the behaviour of the script for when an IP is
found on the block list. Currently, it displays the line:
"Your IP, xxx.xxx.xxx.xxx, has been blacklisted by sbl-xbl.spamhaus.org"
Possible other behaviours would be a redirection (replace the echo
line with "header('location: new_page_name.html');"), nothing (remove
the echo line), or a script of your own.
A working example of the script can be found at:
A known blacklisted IP is 126.96.36.199 (for your testing purposes).
If you have any questions, please do not hesitate to ask for
clarification. I am willing to work until you are completely satisfied
with the answer.