You are here

function ip_login_match_quad in IP Login 7.2

Same name and namespace in other branches
  1. 6.2 ip_login.module \ip_login_match_quad()

Compares a single IP quadrant to a matching quadrant.

The matching quad can contain wildcards (*), ranges (10-12) or exact numbers

Parameters

$find_value: A string containing the quadrant value being looked for

$in_range: String with a quadrant value, range or wildcard to compare to

Return value

TRUE If $find_value matches an IP address $in_range

1 call to ip_login_match_quad()
ip_login_check in ./ip_login.module
Compares the current request's IP address to the ip_login_user table and then does a proper match for each match on exact, ranges and wildcards

File

./ip_login.module, line 587
Allow user login by IP addresses, ranges or wildcards.

Code

function ip_login_match_quad($find_value, $in_range) {

  // if we've got a wildcard just return TRUE
  if ($in_range == '*') {
    return TRUE;
  }

  // check if this quad contains the range character '-'
  $range = explode('-', $in_range);
  if (isset($range[1])) {

    // we've got a range, test upper and lower bounds
    if ($find_value >= $range[0] && $find_value <= $range[1]) {
      return TRUE;
    }
  }
  else {

    // no range, just do normal match
    return $range[0] == $find_value;
  }
  return FALSE;
}