function shurly_host_is_private in ShURLy 6
Same name and namespace in other branches
- 8 shurly.module \shurly_host_is_private()
 - 7 shurly.module \shurly_host_is_private()
 
Check whether the given hostname matches a private IP address.
Parameters
string $hostname: Hostname to check.
Return value
bool TRUE if the given $hostname matches a private IP address; otherwise FALSE.
1 call to shurly_host_is_private()
- shurly_validate_long in ./
shurly.module  - Validate a long URL
 
File
- ./
shurly.module, line 1107  - description http://www.youtube.com/watch?v=Qo7qoonzTCE
 
Code
function shurly_host_is_private($hostname) {
  $resolved_hostname = _shurly_gethostbyname($hostname);
  $private_ip_address_pattern = '/^(10\\.|172\\.(1[6-9]|2[0-9]|3[0-1])\\.|192\\.168\\.)/';
  if (preg_match($private_ip_address_pattern, $resolved_hostname)) {
    return TRUE;
  }
  return FALSE;
}