Returns the current hostname.

First tries to use X-Forward-Host before it goes on to use host in header, if none of them
exists fallback to use host part of site.ini\[SiteSettings]|SiteURL setting.

@return string
336952
public static function hostname()
    {
        $hostName = null;
        $forwardedHostsString = self::serverVariable( 'HTTP_X_FORWARDED_HOST', true );
        if ( $forwardedHostsString )
        {
            $forwardedHosts = explode( ',', $forwardedHostsString );
            $hostName = trim( $forwardedHosts[0] );
        }

        if ( !$hostName && self::serverVariable( 'HTTP_HOST', true ) )
        {
            $hostName = self::serverVariable( 'HTTP_HOST' );
        }

        if ( !$hostName )
        {
            $siteUrl = eZINI::instance()->variable( 'SiteSettings', 'SiteURL' );
            $hostName = parse_url( "http://{$siteUrl}", PHP_URL_HOST );
        }

        return $hostName;
    }
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;
    }
970795
public function getHeader()
    {
        if (is_null($this->header)) {
            $host = $this->getHost();

            $header = array();
            $header[] = 'POST /cgi-bin/webscr HTTP/1.1';
            $header[] = 'Content-Type: application/x-www-form-urlencoded';
            if (isset($host)) {
                $header[] = 'Host: ' . $host;
            }
            $header[] = 'Connection: close';

            $this->setHeader($header);
        }

        return $this->header;
    }
1276290
public function toString()
   {
      if ( empty( $this->_hostName ) )
      {
         if ( \is_null( $this->_tld ) )
         {
            return '';
         }
         return $this->_tld->toString();
      }
      if ( \is_null( $this->_tld ) )
      {
         return $this->_hostName;
      }
      return $this->_hostName . '.' . $this->_tld->toString();
   }
116980
protected function getCurrentUrl() {
        $isHttps = $this->getServerVar('HTTPS');
        $forwardedProto = $this->getServerVar('HTTP_X_FORWARDED_PROTO');
        if ($isHttps == 'on' || $forwardedProto === 'https') {
            $schema = 'https://';
        } else {
            $schema = 'http://';
        }

        $host = $this->getServerVar('HTTP_HOST');

        if (preg_match('#:(\d+)$#', $host, $match)) {
            $port = ':' . $match[1];
        } else {
            $port = '';
        }
        $urls = parse_url($this->getServerVar('REQUEST_URI'));

        $path = $urls['path'];
        $query = '';

        return $schema . $host . $port . $path . $query;
    }
960377
public static function getCurrentUrl()
    {
        if (isset($_SERVER['HTTPS']) &&
            ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
            isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
            $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
            $protocol = 'https';
        }
        else {
            $protocol = 'http';
        }

        return "$protocol://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    }
262272
public function getUrlHost()
    {
        $host = '';
        
        if (!empty($_SERVER['HTTP_FORWARDED'])) {
            extract($this->parseForwardedString($_SERVER['HTTP_FORWARDED']));
        }
        
        if (empty($host)) {
            if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
                $host = $_SERVER['HTTP_X_FORWARDED_HOST'];
            } elseif (!empty($_SERVER['HTTP_HOST'])) {
                $parts = explode(':', $_SERVER['HTTP_HOST']);
                $host = $parts[0];
            } elseif (!empty($_SERVER['SERVER_NAME'])) {
                $host = $_SERVER['SERVER_NAME'];
            } else {
                $host = 'unknown';
            }
        }
        
        return $host;
    }
563438
public function getHostName()
    {
        if (strpos($this->getWorkingHost(), ':') === false) {
            return $this->getWorkingHost();
        }

        $info = explode(':', $this->getWorkingHost());
        return $info[0];
    }
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);
    }
1055083
public function GetHostName () {
		if ($this->hostName === NULL) 
			$this->hostName = $this->globalServer['SERVER_NAME'];
		return $this->hostName;
	}
1198839
public static function getHost()
    {
        $host = '';
        if (isset($_SERVER['HTTP_X_FORWARDED_HOST']) && $host = $_SERVER['HTTP_X_FORWARDED_HOST']) {
            $elements = explode(',', $host);
            $host     = trim(end($elements));
        } else {
            if (isset($_SERVER['HTTP_HOST']) && !$host = $_SERVER['HTTP_HOST']) {
                if (isset($_SERVER['SERVER_NAME']) && !$host = $_SERVER['SERVER_NAME']) {
                    $host = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '';
                }
            }
        }
        // Remove port number from host
        $host = preg_replace('/:\d+$/', '', $host);

        return trim($host);
    }
194351
public function getPrefix()
    {
        if (is_null($this->_prefix)) {
            $hostName = gethostname();
            try {
                $this->_prefix = Configuration::get('config')
                    ->get('logger.prefix', $hostName);
            } catch(FileNotFoundException $exp) {
                $this->_prefix = $hostName;
            }

        }
        return $this->_prefix;
    }
800252
protected function _getHostFromUri()
    {
        $host  = $this->uri->getHost();
        $host .= $this->uri->getPort() ? ':' . $this->uri->getPort() : '';
        return $host;
    }
446516
public function getCurrentRouteName()
    {
        if (null === $this->currentRouteName)
        {
            $this->currentRouteName = $this->getRequest()->get('_route');
        }

        return $this->currentRouteName;
    }
340050
public function getHost()
    {
        if ($this->initialized) {
            $hostname = $this->getHostName();

            if (($this->secure && $this->port != self::HTTPS_PORT) ||
                 (!$this->secure && $this->port != self::HTTP_PORT)) {
                $hostname .= ':'.$this->port;
            }

            return $hostname;
        }

        throw new BadMethodCallException('Connection not initialized');
    }
232952
public function getHostname() {
        if (!empty($_SERVER['HTTP_HOST'])) {
            $httpHost = strtolower(trim($_SERVER['HTTP_HOST']));    // nginx doesn't set $_SERVER[SERVER_NAME]
            if (strlen($httpHost))                                  // automatically to $_SERVER[HTTP_HOST]
                return $httpHost;
        }
        return $_SERVER['SERVER_NAME'];
    }
1235643
public static function getHostname()
    {
        $hostname = $_SERVER['HTTP_HOST']; 

        if (isset($_SERVER['HTTPS']))
        {
            $hostname = 'https://' . $hostname;
        }
        else
        {
            $hostname = 'http://' . $hostname;
        }
        
        return $hostname;
    }