Resolves hostname from $_SERVER['HTTP_HOST']

@return string|null
@internal
193227
private function resolveDefaultHostName()
    {
        $request = $this->di->get('request');
        $config = $this->di->get('config');
        if (isset($config->application->hostname)) {
            $hostName = $config->application->hostname;
        } else if ($request->getServer('HTTP_HOST')) {
            $hostName = $request->getServer('HTTP_HOST');
        } else {
            $hostName = null;
        }
        if (null !== $hostName) {
            $hostName = '(www\.)?' . $hostName;
        }

        return $hostName;
    }
1328064
public static function getHostUri()
  {
    $sheme = (self::getHostParam("HTTPS") == "on") ? "https" : "http";

    $serverName = new Str(self::getHostParam("HTTP_HOST"));
    $serverPort = self::getHostParam("SERVER_PORT");
    $serverPort = ($serverPort != 80 && $serverPort != 443) ? ":" . $serverPort : "";

    if($serverName->endsWith($serverPort))
    {
      $serverName = $serverName->replace($serverPort, "");
    }

    return new Str($sheme . "://" . $serverName . $serverPort);
  }
871026
public static function currentServerName()
    {
        if (! empty(env('SERVER_NAME'))) {
            $BASE_URL = env('SERVER_NAME');
        } elseif (! empty($_SERVER['SERVER_NAME'])) {
            $BASE_URL = $_SERVER['SERVER_NAME'];
        } elseif (! empty($_SERVER['HTTP_HOST'])) {
            $BASE_URL = $_SERVER['HTTP_HOST'];
        } else {
            $BASE_URL = 'empty';
        }
        return $BASE_URL;
    }
737392
public function resolve()
    {
        $rawParams = $this->getServer();
        if (isset($rawParams[0])) {
            $route = $rawParams[0];
            array_shift($rawParams);
        } else {
            $route = '';
        }

        $params = [];
        foreach ($rawParams as $param) {
            if (preg_match('/^--(\w+)(?:=(.*))?$/', $param, $matches) || preg_match('/^-(\w+)(?:=(.*))?$/', $param, $matches)) {
                $name = $matches[1];
                $params[$name] = isset($matches[2]) ? $matches[2] : true;
            } else {
                $params[] = $param;
            }
        }

        $this->server['path_info'] = $route;
        $this->get                 = $params;
        $this->post                = $params;

        return [$route, $params];
    }
769964
protected function get_current_url()
    {
        // When running from commandline the REQUEST_URI is missing.
        if (!isset($_SERVER['REQUEST_URI'])) {
            return null;
        }

        // HTTP_HOST is a client-supplied header that is optional in HTTP 1.0
        $host = (!empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST']
            : (!empty($_SERVER['LOCAL_ADDR'])  ? $_SERVER['LOCAL_ADDR']
            : (!empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '')));

        $httpS = $this->isHttps() ? 's' : '';
        return "http{$httpS}://{$host}{$_SERVER['REQUEST_URI']}";
    }
1361083
public function getHostName()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Hostname');
        }

        foreach ($this->wmi->ExecQuery('SELECT Name FROM Win32_ComputerSystem') as $cs) {
            return $cs->Name;
        }

        return 'Unknown';
    }
289866
public function getHostName()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Hostname');
        }

        // File containing info
        $file = '/proc/sys/kernel/hostname';

        // Get it
        $hostname = Common::getContents($file, false);

        // Failed?
        if ($hostname === false) {
            Errors::add('Linfo Core', 'Error getting /proc/sys/kernel/hostname');

            return 'Unknown';
        }

        // Didn't fail; return it
        return $this->ensureFQDN($hostname);
    }
930942
public function getHost()
    {
        if ($this->HOST) {

            if (strpos($this->HOST, ':') !== false) {
                $hostParts = explode(':', $this->HOST);

                return $hostParts[0];
            }

            return $this->HOST;
        }

        return $this->SERVER_NAME;
    }
889932
public function getHost()
    {
        if ($this->isUsingTrustedProxy() && $this->header->has(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_HOST])) {
            $hosts = explode(',', $this->header->get(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_HOST]));
            $host = trim(end($hosts));
        } else {
            $host = $this->header->get('X_FORWARDED_FOR');
        }

        $host = $this->getHostIfNull($host);

        // Remove the port number
        $host = strtolower(preg_replace('/:\d+$/', '', trim($host)));

        // Check for forbidden characters
        if (!empty($host) && '' !== preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $host)) {
            throw new \UnexpectedValueException("Invalid host $host");
        }

        return $host;
    }
1154914
public function getIp()
    {
        $keys = ['X_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP', 'REMOTE_ADDR'];

        foreach ($keys as $key) {
            $ip = $this->getServerParam($key);

            if (!$ip) {
                continue;
            }

            $ip = preg_replace('/,.*$/u', '', $ip);
            $ip = trim($ip);

            return $ip;
        }

        return null;
    }
172172
protected function getHost()
    {
        $host = $this->host;
        $scheme = 'http';

        if (preg_match('/:443$/', $this->host)) {
            $scheme = 'https';
            $host = preg_replace('/:443$/', '', $this->host);
        }

        return $scheme.'://'.$host;
    }
120256
private function getFromRemoteHostServer()
    {
        if (empty($remoteHost = $this->request->server('REMOTE_HOST')))
            return null;

        $remoteHost = explode('.', $remoteHost);
        $locale     = strtolower(end($remoteHost));

        return $this->isSupported($locale) ? $locale : null;
    }
1258833
public function resolveHost()
    {
        $host = $this->getHost();

        if ($host == null) {
            //check to see if there is an AuthenticationToken from which to retrieve it:
            $token = $this->getAuthenticationToken();
            //if ($token instanceof $HostAuthenticationToken) {
            if($token)
                $host = 'API Services';
            //}
        }

        if ($host == null) {
            $session = $this->resolveSession();
            if ($session != null) {
                $host = $session->getHost();
            }
        }

        return $host;

    }
1296055
public static function host(): ?string
    {
        $ip = self::ip();

        if (isset(static::$hosts[$ip])) {
            return static::$hosts[$ip];
        }

        $host = gethostbyaddr($ip);
        static::$hosts[$ip] = ($host === '') ? null : $host;
        return static::$hosts[$ip];
    }
915711
public static function getHostname($url)
    {
        if (!isset(self::$cache[$url]['hostname'])) {
            self::$cache[$url]['hostname'] = self::parseUrl($url, PHP_URL_HOST);
        }

        return self::$cache[$url]['hostname'];
    }
160885
public function buildServerString() {
		$serverName = env('SERVER_NAME') ?: gethostname();
		if (!$serverName) {
			$user = env('USER');
			$logName = env('LOGNAME');
			if ($user || $logName) {
				$serverName = $user . '@' . $logName;
			}
		}

		return $serverName ?: null;
	}
598436
protected function getHostname()
    {
        $disabled = explode(',', ini_get('disable_functions'));

        if (function_exists('php_uname') && !in_array('php_uname', $disabled, true)) {
            return ['hostname' => php_uname('n')];
        }

        if (function_exists('gethostname') && !in_array('gethostname', $disabled, true)) {
            return ['hostname' => gethostname()];
        }

        return [];
    }