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.

function validIp($IP)
		$IP = ip2long($IP);
		$StartIP = ip2long("");
		$EndIP   = ip2long("");
		if ($IP >= $StartIP && $IP <= $EndIP)
			return TRUE;
		return FALSE;


if (validIp($ip))
		echo "Granted";
		echo "Denied";

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.