You are here

function services_ipauth_ip_quad_matches in Services IP Authentication 6

Same name and namespace in other branches
  1. 7 services_ipauth.module \services_ipauth_ip_quad_matches()

Check if a IP quadrant matches.

Parameters

string $quad The quadrant of the ip address.:

string $to_match The pattern to match.:

Return value

boolean TRUE if the quandrant matches, FALSE otherwise.

1 call to services_ipauth_ip_quad_matches()
services_ipauth_ip_is_in_range in ./services_ipauth.module
Check if an IP address is in a certain range.

File

./services_ipauth.module, line 104
Hook implementations and general API function for the IP Authentication module.

Code

function services_ipauth_ip_quad_matches($quad, $to_match) {

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

  // If $to_match contains '-', we have a range, else we have a fixed value.
  $range = explode('-', $to_match);
  return isset($range[1]) ? $quad >= $range[0] && $quad <= $range[1] : $range[0] == $quad;
}