private static function getServerHost()
{
if (array_key_exists('HTTP_HOST', $_SERVER)) {
$current = $_SERVER['HTTP_HOST'];
} elseif (array_key_exists('SERVER_NAME', $_SERVER)) {
$current = $_SERVER['SERVER_NAME'];
} else {
// almost certainly not what you want, but...
$current = 'localhost';
}
if (strstr($current, ":")) {
$decomposed = explode(":", $current);
$port = array_pop($decomposed);
if (!is_numeric($port)) {
array_push($decomposed, $port);
}
$current = implode($decomposed, ":");
}
return $current;
}