28Jul/100
Check IP range
I needed a little something to check if one of my files was called from an internal IP, and for this I made this little function.
<?php
function validIp($IP)
{
$IP = ip2long($IP);
$StartIP = ip2long("10.0.0.100");
$EndIP = ip2long("10.0.0.150");
if ($IP >= $StartIP && $IP <= $EndIP)
{
return TRUE;
break;
}
return FALSE;
}
$ip = $_SERVER['REMOTE_ADDR'];
if (validIp($ip))
{
echo "Granted";
}
else
{
echo "Denied";
}
?>