You are here

function _autoban_range_match in Automatic IP ban (Autoban) 7

Is IP address in subnet?

Parameters

string $ip: IP address for match check.

string $ip_begin: IP adress - begin of the IP range.

string $ip_end: IP adress - end of the IP range.

Return value

bool IP mathes for range or wrong arguments.

1 call to _autoban_range_match()
autoban_whitelist_ip in ./autoban.module
Is IP address in whitelist

File

./autoban.module, line 817
Main file for autoban module.

Code

function _autoban_range_match($ip, $ip_begin, $ip_end) {
  $ipBegin = ip2long(trim($ip_begin));
  $ipEnd = ip2long(trim($ip_end));
  if (empty($ipBegin) || empty($ipEnd)) {
    return FALSE;
  }
  $ipLong = ip2long($ip);
  return $ipLong >= $ipBegin && $ipLong <= $ipEnd;
}