You are here

function _hosting_valid_ip in Hosting 5

Same name and namespace in other branches
  1. 6.2 hosting.inc \_hosting_valid_ip()
  2. 7.4 hosting.inc \_hosting_valid_ip()
  3. 7.3 hosting.inc \_hosting_valid_ip()

Check if a hostname provided is an ip address

2 calls to _hosting_valid_ip()
hosting_get_db_server in db_server/hosting_db_server.module
hosting_web_server_validate in web_server/hosting_web_server.module
Implementation of hook_validate().

File

./hosting.module, line 314
Hosting module

Code

function _hosting_valid_ip($hostname) {

  //TODO : provide IPv6 support
  $parts = explode('.', $hostname);
  if (sizeof($parts) != 4) {
    return false;
  }
  foreach ($parts as $part) {
    if ((int) $part < 0 || (int) $part > 255) {
      return false;
    }
  }
  return true;
}