You are here

function shurly_host_is_local in ShURLy 7

Same name and namespace in other branches
  1. 8 shurly.module \shurly_host_is_local()
  2. 6 shurly.module \shurly_host_is_local()

Check whether the given resolved host is the localhost.

Parameters

string $hostname: Return value of a `gethostbyname()` call.

Return value

bool TRUE if the resolved hostname matches an IPv4 or IPv6 localhost address; otherwise FLASE.

1 call to shurly_host_is_local()
shurly_validate_long in ./shurly.module
Validate a long URL

File

./shurly.module, line 1302
description http://www.youtube.com/watch?v=Qo7qoonzTCE

Code

function shurly_host_is_local($hostname) {
  $resolved_hostname = _shurly_gethostbyname($hostname);
  $local_ip_address_pattern = '/^127(?:\\.[0-9]+){0,2}\\.[0-9]+$|^\\[(?:0*\\:)*?:?0*1\\]$/';
  if (preg_match($local_ip_address_pattern, $resolved_hostname)) {
    return TRUE;
  }
  return FALSE;
}