Forum Moderators: DixonJones
$iplist = array("IP1","IP2","IP3"); // 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 = \"not_wanted.html\";\n"; // page to divert to
}
Thats all,but now.....as you can see it asks for ip,ip,ip....but can this be changed so it works like a ip range...?
I dont have the time to put 100.000 ip's in that file.
So can i get some help on this please.
Thank you,
janice
Welcome to WebmasterWorld [webmasterworld.com]!
This is a big can of worms...
Your script can undoubtedly be modified to parse out the 'classes' of IP addresses, leaving off the last one, two or three digit groups for comparison purposes.
But the problem is larger than that; The internet numbering system does not comprehend national boundaries, and number ranges are allocated as requested. So for example, Australia, New Zealand, and parts of India are mixed in with the large blocks allocated to China.
Any solution is necessarily huge and maintenance-intensive. It takes a staff.
As a result, the best solutions are pay-for-play. You pay them to provide an up-to-the minute translation of IP addresses to countries. When IPv64 rolls out, this will make the number of available IP addresses larger by a factor of 4,294,967,296!
Doing a search for geo-targeting and IP will turn up some solutions.
Jim
<edit> previous thread on IP vs. location: [webmasterworld.com...] </edit>