Gets the referring URL of this request.

@param string $default Default URL to use if HTTP_REFERER cannot be read from headers.
@param boolean $local If true, restrict referring URLs to local server.
@return string Referring URL.
325856
public function referer($default = null, $local = false) {
		if ($ref = $this->env('HTTP_REFERER')) {
			if (!$local) {
				return $ref;
			}
			$url = parse_url($ref) + ['path' => ''];
			if (empty($url['host']) || $url['host'] === $this->env('HTTP_HOST')) {
				$ref = $url['path'];
				if (!empty($url['query'])) {
					$ref .= '?' . $url['query'];
				}
				if (!empty($url['fragment'])) {
					$ref .= '#' . $url['fragment'];
				}
				return $ref;
			}
		}
		return ($default !== null) ? $default : '/';
	}
578406
public function referer($local = false)
    {
        $ref = $this->getEnv('HTTP_REFERER');

        $base = Configure::read('App.fullBaseUrl') . $this->webroot;
        if (!empty($ref) && !empty($base)) {
            if ($local && strpos($ref, $base) === 0) {
                $ref = substr($ref, strlen($base));
                if (!strlen($ref) || strpos($ref, '//') === 0) {
                    $ref = '/';
                }
                if ($ref[0] !== '/') {
                    $ref = '/' . $ref;
                }

                return $ref;
            }
            if (!$local) {
                return $ref;
            }
        }

        return '/';
    }
1237349
public function getServerParam($key, $default = null)
    {
        $serverParams = $this->serverRequest->getServerParams();
        return isset($serverParams[$key]) ? $serverParams[$key] : $default;
    }
897480
public static function get(string $variable, $default = null) {
		return isset(self::$_get[$variable])
			? urldecode(self::$_get[$variable])
			: $default;
	}
514138
public function getParameter($key, $default = null) {
        $value = $this->getUrl()->getQuery()->get($key);

        if ($value === null) {
            $value = $this->getData()->get($key, $default);
        }

        return $value;
    }
368427
private function dispatchUrl($default = '#')
    {
        if ($this->isType('url')) {
            return $this->getProperty('url');
        }

        if ($this->isType('route')) {
            list($route, $parameters) = $this->getProperty('route');

            return route($route, $parameters);
        }

        if ($this->isType('action')) {
            list($action, $parameters) = $this->getProperty('action');

            return action($action, $parameters);
        }

        return $default;
    }
732158
public function getReferer() : ?Url
    {
        $referer = $this->getFirstHeader('Referer');

        if ($referer === null) {
            return null;
        }

        try {
            return new Url($referer);
        } catch (\InvalidArgumentException $e) {
            return null;
        }
    }
79479
protected function getLocalSessionValue($key, $default=null) {
    $sessionVarname = get_class($this);
    $localValues = $this->session->get($sessionVarname, null);
    return array_key_exists($key, $localValues) ? $localValues[$key] : $default;
  }
440847
public function getHeader($name, $default = null)
    {
        if (!$this->request) {
            return $this->getRequest()->getHeader($name);
        }
        return parent::getHeader($name, $default);
    }
767492
public function getAlternateLinks($urls)
    {
        // determine default and current values
        $webspaceKey = $this->requestAnalyzer->getWebspace()->getKey();
        $currentPortal = $this->requestAnalyzer->getPortal();

        $defaultLocale = null;
        if (null !== $currentPortal && null !== ($defaultLocale = $currentPortal->getXDefaultLocalization())) {
            $defaultLocale = $defaultLocale->getLocale();
        }

        $result = [];
        foreach ($urls as $locale => $url) {
            // url = '/' means that there is no translation for this page
            // the only exception is the homepage where the requested resource-locator is '/'
            if ('/' !== $url || '/' === $this->requestAnalyzer->getResourceLocator()) {
                if ($locale === $defaultLocale) {
                    $result[] = $this->getAlternate($url, $webspaceKey, $locale, true);
                }
                $result[] = $this->getAlternate($url, $webspaceKey, $locale);
            }
        }

        return implode(PHP_EOL, $result);
    }
1294148
public static function getReferer($full = false) {
		$ref = env('HTTP_REFERER');
		$forwarded = env('HTTP_X_FORWARDED_HOST');
		if ($forwarded) {
			$ref = $forwarded;
		}
		if (empty($ref)) {
			return $ref;
		}
		if ($full) {
			$ref = Router::url($ref, $full);
		}
		return $ref;
	}
627289
public static function get(string $name, $default = null)
    {
        $names = Imi::parseDotRule($name);
        if (isset($names[0]))
        {
            $first = array_shift($names);
            if('@currentServer' === $first)
            {
                if($isCurrentServer = (RequestContext::exsits() && null !== ($server = RequestContext::getServer())))
                {
                    $first = '@server';
                    array_unshift($names, $server->getName());
                }
                else
                {
                    $first = '@app';
                }
            }
            else
            {
                $isCurrentServer = false;
            }
            if(isset(static::$configs[$first]))
            {
                $result = static::$configs[$first]->get($names, null);
            }
            if(isset($result))
            {
                return $result;
            }
            else if($isCurrentServer)
            {
                $first = '@app';
                array_shift($names);
                return static::$configs[$first]->get($names, $default);
            }
        }
        return $default;
    }
945636
public function getHeader($name, $default = null)
    {
        if (empty($name)) {
            return $default;
        }

        $temp = 'HTTP_' . strtoupper(str_replace('-', '_', $name));
        if (isset($this->env[$temp])) {
            return $this->env[$temp];
        }

        if (function_exists('apache_request_headers')) {
            // @codeCoverageIgnoreStart
            $method = 'apache_request_headers';
            $headers = $method();
            if (isset($headers[$name])) {
                return $headers[$name];
            }
            $header = strtolower($name);
            foreach ($headers as $key => $value) {
                if (strtolower($key) == $name) {
                    return $value;
                }
            }
        }
        // @codeCoverageIgnoreEnd

        return $default;
    }
126135
public static function referrer($isInternal = true)
    {
        if (! isset(self::$_referrer)) {
            if ($referrer = AnRequest::get('server.HTTP_REFERER', 'url')) {
                self::$_referrer = AnService::get('anahita:http.url', array('url' => $referrer));

                if ($isInternal) {
                    if (! AnService::get('anahita:filter.internalurl')->validate((string) self::$_referrer)) {
                        return null;
                    }
                }
            }
        }

        return self::$_referrer;
    }
1253518
protected function getTranslationRoute($referrer, $oldLocale, $locale)
    {
        /** @var $languageSwitcherHelper LanguageSwitcherHelper */
        $languageSwitcherHelper = $this->get('networking_init_cms.page.helper.language_switcher');

        $oldURL = $languageSwitcherHelper->getPathInfo($referrer);

        return $languageSwitcherHelper->getTranslationRoute($oldURL, $oldLocale, $locale);
    }
646507
public function referrer($default = null, $attributes = null)
    {
        $referrer = $_SERVER['HTTP_REFERER'] ?? null;

        // Check that referrer came from our site.
        $root = $this->rootUrl(true);
        if ($referrer) {
            // Referrer should always have host set and it should come from the same base address.
            if (stripos($referrer, $root) !== 0) {
                $referrer = null;
            }
        }

        if (!$referrer) {
            $referrer = $default ?: $this->route(true, true);
        }

        if ($attributes) {
            $referrer .= $attributes;
        }

        // Return relative path.
        return substr($referrer, strlen($root));
    }
550247
public function get($parameter, $default = null)
    {
        if ('link' == $parameter) {
            return $this->getLink();
        }

        return isset($this->config[$parameter]) ? $this->config[$parameter] : $default;
    }