Forum Moderators: coopster

Message Too Old, No Replies

checkip help

php ip restriction

         

ksugam

9:06 am on Aug 5, 2008 (gmt 0)

10+ Year Member



hello all,
Currently i am using a function CheckAccess to restrict my website to a specific IP address.Here is the function:

function CheckAccess()
{

$allowedip = '123.123.123.123';

$ip = $_SERVER['REMOTE_ADDR'];
return ($ip == $allowedip);
}

if (!CheckAccess()){
echo "Not for you!";
}

My problem is, how do i add more than 1 IP address?

Little_G

9:25 am on Aug 5, 2008 (gmt 0)

10+ Year Member



Hi,

If you put all the allowed IP addresses in an array you can check it using in_array [php.net].

Andrew