/** * If current URL is "http://example.org/dir1/dir2/index.php? param1=value1¶m2=value2" * will return "example.org" * * @param string $default Default value to return if host unknown * @return string */ public static function getCurrentHost($default = 'unknown') { static $hostHeaders = null; if (is_null($hostHeaders)) { $config = Zend_Registry::get('config'); if ($config !== false && isset($config->General->proxy_host_headers)) { $hostHeaders = $config->General->proxy_host_headers->toArray(); } if (!is_array($hostHeaders)) { $hostHeaders = array(); } } $default = Core_Common::sanitizeInputValue($default); if (isset($_SERVER['HTTP_HOST'])) { $default = Core_Common::sanitizeInputValue($_SERVER['HTTP_HOST']); } // @todo temporary workaround for #1331 if (!method_exists('Core_Common', 'getProxyFromHeader')) { return $default; } return Core_Common::getProxyFromHeader($default, $hostHeaders); }