RE: How do I ban an ip address please!
| From: | Nold, Mark | Date: | Fri, 24 Nov 2000 02:32:30 +0000 |
| Subject: | RE: How do I ban an ip address please! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-26894@lists.php.net to get a copy of this message | ||
----------------------------------------------------------------------------
-----------------
Disclaimer: The information contained in this email is intended only for the
use of the person(s) to whom it is addressed and may be confidential or
contain legally privileged information. If you are not the intended
recipient you are hereby notified that any perusal, use, distribution,
copying or disclosure is strictly prohibited. If you have received this
email in error please immediately advise us by return email at
postmaster@normandy.com.au and delete the email document without making a
copy.
----------------------------------------------------------------------------
-----------------
I'm sure there are better ways of doing this via your web server, but if you
want to embed it in PHP code try something like:
$banlist["10.10.1.123"] = true;
$banlist["10.192.1.13"] = true;
$banlist["192.10.1.13"] = true;
$banlist["10.10.1.12"] = true;
$banlist["10.10.1.23"] = true;
$banlist["10.10.100.13"] = true;
$ip = $GLOBALS["REMOTE_ADDR"];
if($banlist[$ip] == true){
echo "You have been banned";
exit();
}
Of course this doesnt allow for patterns like banning a whole subnet etc...
also see how you server returns REMOTE_ADDR in phpinfo()
Also remember that users may use DHCP which means they have changing IP's...
mn
Mark Nold
markn@enspace.com <mailto:markn@enspace.com>
Senior Consultant
Change is inevitable, except from vending machines.
-----Original Message-----
From: Sandeep Hundal [mailto:sandeep_wde@yahoo.com]
Sent: Friday, November 24, 2000 10:24 AM
To: php-general@lists.php.net
Subject: How do I ban an ip address please!
Hi all,
I'm using Bare Bones bulletin board, and making something akin my own
version of a message board for articles. I'm tracking all IP
addresses in a mysql column, but would now also like to add in the
ability to ban ip address.
Any pointers, pieces of code, help etc??
thanks!
/sunny
__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/