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";

Add a Comment

Your email address will not be published. Required fields are marked *