Google Answers Logo
View Question
 
Q: Custom PHP Script : Simple RBL Check for REMOTE_IP ( Answered,   0 Comments )
Question  
Subject: Custom PHP Script : Simple RBL Check for REMOTE_IP
Category: Computers > Programming
Asked by: captainnemo-ga
List Price: $200.00
Posted: 04 Jul 2004 01:21 PDT
Expires: 03 Aug 2004 01:21 PDT
Question ID: 369452
Hello, 

Im interested in having a very computer savvy individual, code a
somewhat simple (or perhaps not?) PHP script that will check the
incoming REMOTE_IP (I'm not fluent with PHP) IP address in the popular
RBL list and verify whether an entry for that IP exists. I would like
to be able to <? include ?> the provided script on top of every one of
my pages, and then limit access to my site if the remote IP of the
visitor is found in the RBL database.

Please ask any questions you may have. Thank you in advance.
Answer  
Subject: Re: Custom PHP Script : Simple RBL Check for REMOTE_IP
Answered By: tox-ga on 04 Jul 2004 17:20 PDT
 
captainnemo-ga,

I have completed your requested script. You can download the file at:
http://www.maxlin.ca/tos/ga/dnsblquery.zip

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
version (dnsblquery_win.php).

To use the script, simply insert the line:
<? include("dnsblquery_unix.php"); ?>
or
<? 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:
http://www.maxlin.ca/tos/ga/dnsblquery.php
A known blacklisted IP is 64.201.124.0 (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.

Cheers,
Tox-ga
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy