getNonProxyIpFromHeader() public static method

Returns a non-proxy IP address from header.
public static getNonProxyIpFromHeader ( string $default, array $proxyHeaders ) : string
$default string Default value to return if there no matching proxy header.
$proxyHeaders array List of proxy headers.
return string
Esempio n. 1
0
 /**
  * Returns the current host.
  *
  * @param string $default Default value to return if host unknown
  * @param bool $checkTrustedHost Whether to do trusted host check. Should ALWAYS be true,
  *                               except in Controller.
  * @return string eg, `"example.org"` if the current URL is
  *                `"http://example.org/dir1/dir2/index.php?param1=value1&param2=value2"`
  * @api
  */
 public static function getCurrentHost($default = 'unknown', $checkTrustedHost = true)
 {
     $hostHeaders = array();
     $config = Config::getInstance()->General;
     if (isset($config['proxy_host_headers'])) {
         $hostHeaders = $config['proxy_host_headers'];
     }
     if (!is_array($hostHeaders)) {
         $hostHeaders = array();
     }
     $host = self::getHost($checkTrustedHost);
     $default = Common::sanitizeInputValue($host ? $host : $default);
     return IP::getNonProxyIpFromHeader($default, $hostHeaders);
 }