|
Posted by Bernie Woodham on 02/07/06 03:54
"J.O. Aho" <user@example.net> wrote in message
news:44qahaF3ghusU1@individual.net...
> Bernie Woodham wrote:
>
>> 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?
>
> The code is quite old and I guess the new site is using a lot newer
> version of PHP.
>
>
>> =================code==============================
>
>> $iplist = array("234.765.123.0" , "62.00" , "539.765" ); // the list of
>> banned IPs
>>
>> // $ip = getenv("REMOTE_ADDR"); // get the visitors IP address
> $ip=$_SERVER['REMOTE_ADDR']; // current way to get visitors IP
>> // 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
>> }
>
> This seems to be part of a javascript, you could replace that with a usage
> of header(). http://www.php.net/manual/en/function.header.php
>
> If you use full ip's in the $iplist (xxx.yyy.zzz.qqq) then you could use
>
> if(in_array($_SERVER['REMOTE_ADDR'],$iplist)) {
> header("Location: http://www.google.com");
> }
>
> This is quite a lot shorter code to write and you don't have to mess with
> javascript, which don't necessarily work the same way on all browsers.
>
>
> //Aho
Hi again. Yes, I used $ip=$_SERVER['REMOTE_ADDR']; // current way to get
visitors IP
and now the thing works great. Thanks much, you're a life saver.
I am hoping to get some time so I can actually sit and study up on PHP, a
lot of rich things there.
Thanks again.
Navigation:
[Reply to this message]
|