Returns the actual domain or host-name of the current request.
This can either be 'yourpage.com' or 'server23' in case of a
hostname

@return string domain or host
175155
public static function getDomain()
	{
		if (!isset(self::$RCACHE)) static::cacheReqData();

		//decide if tld needs to be joined
		if (self::$RCACHE['numParts'] > 1) {
			return self::$RCACHE['hostParts'][1] . '.' . static::getTld();
		} else {
			return self::$RCACHE['hostParts'][0];
		}
	}
333095
protected function vhost()
	{
		$host = rtrim($_SERVER['HTTP_HOST']);
		if (empty($host))
		{
			$host = $_SERVER['SERVER_NAME'];
		}
		$host  = preg_replace('/[^A-Za-z0-9\[\]\.:-]/', '', $host);
		
		if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) 
		{
			$xhost = preg_replace('/[^A-Za-z0-9\[\]\.:-]/', '', rtrim($_SERVER['HTTP_X_FORWARDED_HOST'],'/'));
		} 
		else 
		{
			$xhost = '';
		}
		
		return (!empty($xhost) ? $xhost : $host) ;
	}
1339730
public function getDomainName(): string
    {
        return $this->myDomainParts[count($this->myDomainParts) - 1] . ($this->myTld !== null ? '.' . $this->myTld : '');
    }
1294331
private static function guessAbsoluteURL () {
        $scheme = 'http';
        $host = 'localhost';

        if (isset($_SERVER['REQUEST_SCHEME'])) {
            $scheme = $_SERVER['REQUEST_SCHEME'];
        }

        if (isset($_SERVER['HTTP_HOST'])) {
            $host = $_SERVER['HTTP_HOST'];
        }

        return $scheme . '://' . $host . '/';
    }
184368
public function getHost()
    {
        if (isset($this->env['HOST'])) {
            if (strpos($this->env['HOST'], ':') !== false) {
                $hostParts = explode(':', $this->env['HOST']);

                return $hostParts[0];
            }

            return $this->env['HOST'];
        } else {
            return $this->env['SERVER_NAME'];
        }
    }
225182
public function getHost()
    {
        $host = $this->headers->get('HTTP_HOST');
        if ($host) {
            if (strpos($host, ':') !== false) {
                $hostParts = explode(':', $host);

                return $hostParts[0];
            }

            return $host;
        }

        return $this->env->get('SERVER_NAME');
    }
1041685
public function getHostName()
    {
        $possibleHostSources = ['HTTP_X_FORWARDED_HOST', 'HTTP_HOST', 'SERVER_NAME', 'SERVER_ADDR'];
        $sourceTransformations = [
            "HTTP_X_FORWARDED_HOST" => function ($value) {
                $elements = explode(',', $value);
                return trim(end($elements));
            },
        ];
        $host = '';
        foreach ($possibleHostSources as $source) {
            if (!empty($host)) {
                break;
            }

            if (empty($_SERVER[$source])) {
                continue;
            }

            $host = $_SERVER[$source];
            if (array_key_exists($source, $sourceTransformations)) {
                $host = $sourceTransformations[$source]($host);
            }
        }

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

        return trim($host);
    }
214904
public function getHost() : string
    {
        $host = null;

        if ($this->isUsingTrustedProxy() && $this->headers->has(self::$trustedHeaderNames[RequestHeaders::CLIENT_HOST])) {
            $hosts = explode(',', $this->headers->get(self::$trustedHeaderNames[RequestHeaders::CLIENT_HOST]));
            $host = trim(end($hosts));
        }

        if ($host === null) {
            $host = $this->headers->get('HOST');
        }

        if ($host === null) {
            $host = $this->server->get('SERVER_NAME');
        }

        if ($host === null) {
            // Return an empty string by default so we can do string operations on it later
            $host = $this->server->get('SERVER_ADDR', '');
        }

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

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

        return $host;
    }
269182
public static function getDomain()
    {
        $domain=self::getAppDomain();
        $arr=explode(".", $domain);
        $c=count($arr);
        $root="";
        if($c>0)$root=$arr[$c-1];
        if($c>1)$root=$arr[$c-2].".".$root;
        if(strpos($root, ":")){
            $root=substr($root, 0,strpos($root, ":"));
        }
        return $root;
    }
100998
private function getRemoteHostname()
    {
        $hostname = NULL;

        if(!is_null($this->ip)) {
            $hostname = gethostbyaddr($this->ip);
        }
        return $hostname;
    }
398174
protected function getDomain()
    {
        if ($this->domain !== null) {
            return $this->domain;
        }

        if (PHP_SAPI == 'cli') {
            $this->domain = '__CLI__';
            return $this->domain;
        }

        $this->domain = isset($_SERVER['SERVER_NAME'])? $_SERVER['SERVER_NAME'] : 'default';
        return $this->domain;
    }
398231
protected function getDomain()
    {
        if (!empty($this->sDomain)) {
            return $this->sDomain;
        } elseif (site_url() === '/') {
            $oInput    = Factory::service('Input');
            $sHost     = $oInput->server('SERVER_NAME');
            $sProtocol = $oInput->server('REQUEST_SCHEME') ?: 'http';
            if (empty($sHost)) {
                throw new HostNotKnownException('Failed to resolve host; email links will be incomplete.');
            } else {
                $this->sDomain = $sProtocol . '://' . $sHost . '/';
            }
        } else {
            $this->sDomain = site_url();
        }

        $this->sDomain = rtrim($this->sDomain, '/');
        return $this->sDomain;
    }
1220533
public function getRegistrableDomain()
    {
        if (null === $this->suffix) {
            return null;
        }

        return null === $this->hostname ? null : $this->hostname . '.' . $this->suffix;
    }
563438
public function getHostName()
    {
        if (strpos($this->getWorkingHost(), ':') === false) {
            return $this->getWorkingHost();
        }

        $info = explode(':', $this->getWorkingHost());
        return $info[0];
    }
1215270
public function getHost() {
		if (!is_null($this->host)) {
			return $this->host;
		}

		if ($_SERVER['HTTP_X_FORWARDED_HOST']) {
			$elements = explode(',', $value);
			$host = trim(end($elements));
		} else if ($_SERVER['HTTP_HOST']) {
			$host = $_SERVER['HTTP_HOST'];
		} else if ($_SERVER['SERVER_NAME']) {
			$host = $_SERVER['SERVER_NAME'];
		}

		if (isset($host)) {
			$host = preg_replace('/:\d+$/', '', $host);
			$this->host = $host;
		}

		return $this->host;
	}
1373694
public function toString()
   {

      if ( empty( $this->_hostName ) )
      {
         return $this->_tld->toString();
      }

      if ( null === $this->_tld )
      {
         return $this->_hostName;
      }

      return $this->_hostName . '.' . $this->_tld->toString();

   }
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;
    }