|
Posted by Bernie Woodham on 02/07/06 01:55
"J.O. Aho" <user@example.net> wrote in message
news:44q4mcF3559eU1@individual.net...
> Bernie Woodham wrote:
>> Hello I am using a piece of code to divert certain IP addresses away from
>> my website. I've used this code for a couple of years with great success
>> on one site, but cannot get it to work on another site I've decided to
>> place it on?
>>
>> Whey would this be?
> compare PHP versions and the output from phpinfo() on both servers, and
> you should see what is different when it comes to compile options and from
> the Changelog you see what is different with the different versions of
> PHP.
>
>
> //Aho
Yes, there are quite a bit of differences and I'm pretty much a novice at
php. Here is the code; I include all the author's statements since he does
have a copyright on it. But what should I be looking for?
=================code==============================
<?
/*
Copyright (C) 2002 Andrew Wilkes andy@urgentclick.com
IP address blocker. Uses a list of full or partial IP addresses.
This code lets you display an alternative web page if an unwanted visitor
looks at your web page.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
http://www.gnu.org/licenses/gpl.html
Modify the list of banned IP addresses to suit your needs.
Include all or some of the IP address from the leftmost digit.
Replace ip1 etc. with a number such as: 198 or 198.201.01.02
Add as many to the list as you like.
Be careful not to exclude everyone from your site!
*/
$iplist = array("234.765.123.0" , "62.00" , "539.765" ); // the list of
banned IPs
$ip = getenv("REMOTE_ADDR"); // get the visitors IP address
// echo "$ip";
$found = false;
foreach ($iplist as $value) { // scan the list
if (strpos($ip, $value) === 0){
$found = true;
}
}
if ($found == true) {
echo "top.location = \"http://www.google.com\";\n"; // page to divert to
}
?>
==================end code===========================
Navigation:
[Reply to this message]
|