Re: set multiple variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 1 Oct 2004 17:38:31 -0400, Joe Szilagyi <js@xxxxxxxx> wrote:
> Hi, I have this working:
> 
> if ($REMOTE_ADDR == "212.3.54.65")  {
>         header("Location: http://www.google.com/search?&q=huzzah";);
> Redirect browser
>         exit;
>         }
> 
> But I want to specify multiple IPs. What's the best recommended way for
> doing that?
> 

Build an array and use in_array():

$redirect_me = array ('212.3.54.65', '127.0.0.1', '192'168.0.1');
if (in_array ($_SERVER['REMOTE_ADDR'], $redirect_me))
    {
    header ("Location: ...");
    exit;
    }

If the addresses you are targeting are ranges in CIDR format (e.g.
192.168.0.0/24), take a look at the PEAR package Net_IPv4.

pb

-- 
paul bissex, e-scribe.com -- database-driven web development
413.585.8095
69.55.225.29
01061-0847
72°39'71"W 42°19'42"N

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux