@param $refererUrl
@param $host
@param $domain_id

@return mixed
177551
public function store($refererUrl, $host, $domain_id)
    {
        $attributes = [
            'url'               => $refererUrl,
            'host'              => $host,
            'domain_id'         => $domain_id,
            'medium'            => null,
            'source'            => null,
            'search_terms_hash' => null,
        ];

        $parsed = $this->refererParser->parse($refererUrl, $this->currentUrl);

        if ($parsed->isKnown()) {
            $attributes['medium'] = $parsed->getMedium();

            $attributes['source'] = $parsed->getSource();

            $attributes['search_terms_hash'] = sha1($parsed->getSearchTerm());
        }

        $referer = $this->findOrCreate(
            $attributes,
            ['url', 'search_terms_hash']
        );

        $referer = $this->find($referer);

        if ($parsed->isKnown()) {
            $this->storeSearchTerms($referer, $parsed);
        }

        return $referer->id;
    }
666417
protected function fetch_url($url, $referer = '', $timeout = null, $post_data = null, $headers = null)
    {
        // If we've been redirected too many times, end it.
        if ($this->redirects > 4) {
            $this->error = 606;
            return false;
        }

        // Set up our fake IP's.
        $ip = array(
            'REMOTE_ADDR: ' . $this->ip,
            'HTTP_X_FORWARDED_FOR: ' . $this->ip
        );

        // If we have headers to send, send them.
        if ($headers) {
            $headers = array_merge($ip, $headers);
        } else {
            $headers = $ip;
        }

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6');
        curl_setopt($ch, CURLOPT_TIMEOUT, ($timeout) ? $timeout : $this->timeout);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie_file);
        curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie_file);
        curl_setopt($ch, CURLOPT_AUTOREFERER, true);

        if (!empty($referer)) {
            curl_setopt($ch, CURLOPT_REFERER, $referer);
        }

        // Are we POSTing?
        if (!empty($post_data)) {
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
        }

        $result = curl_exec($ch);

        // Checking for redirects
        if (stripos($result, '<title>Object moved</title>') !== false) {
            $follow = urldecode(trim($this->find($result, '<a href="', '">')));

            if (substr($follow, 0, 1) == '/') {
                $this->redirects++;
                $result = $this->fetch_url('http://live.xbox.com' . $follow, $url);
            } else {
                $this->redirects++;
                $result = $this->fetch_url($follow, $url);
            }
        } else if (stripos($result, '<!-------Error Info') !== false) {
            // For some reason, there's an error and we cannot continue...
            $this->force_new_login();

            if ($this->logged_in) {
                $this->redirects++;
                $result = $this->fetch_url($url, $referer);
            } else {
                $this->error = 600;

                return false;
            }
        } else if (stripos($result, 'UserAcceptsNewTermsOfUse') !== false) {
            // If we get stopped to agree to a new ToU, accept it.
            $follow = 'https://live.xbox.com' . $this->find($result, '<form action="', '" method="post">');
            $token  = $this->find($result, '<input name="__RequestVerificationToken" type="hidden" value="', '" />');
            $post   = 'UserAcceptsNewTermsOfUse=true&__RequestVerificationToken=' . urlencode($token);
            $result = $this->fetch_url($follow, $url, null, $post);
            $result = $this->fetch_url($url, $referer, $timeout, $post_data, $headers);
        } else {
            $this->save_to_debug('Loaded URL: ' . $url);
        }

        if (!$result) {
            $this->error = 607;
            return false;
        }

        curl_close($ch);

        return $result;
    }
1144529
public function recordList($domainId = 0, $hostId = 0, $offset = 0, $rowNum = 30) {
        //设置URL扩展
        $this->setUrlExtend("$domainId?host_id=$hostId&offset=$offset&row_num=$rowNum");
        //设置请求的方法
        $this->setMethod('GET');
        //初始化参数
        $this->initParam();
        //获取返回值
        return $this->response();
    }
340099
public function getReferer()
    {
        $referer = null;

        if (array_key_exists(self::REFERER_KEY, $this->serverData)) {
            $referer = $this->serverData[self::REFERER_KEY];
        }

        return $referer;
    }
856034
public function url($include_host = false)
    {
        if ($include_host) {
            return $this->url;
        }

        $url = str_replace($this->base, '', rtrim($this->url, '/'));

        return $url ?: '/';
    }
1277950
public function twitterShare($url = '', $text = '', $referer = '')
    {
        $twitter = new Twitter();

        return $twitter
            ->createShareLink($url, $text, $referer)
            ->getLink();
    }
484008
private function getReferer($url, $httpHeader = [])
    {
        $default_referer = $this->config['default_referer'];

        if (!empty($httpHeader['referer'])) {
            $this->logger->info('Found referer "{referer}" for url "{url}" from site config', ['referer' => $httpHeader['referer'], 'url' => $url]);

            return $httpHeader['referer'];
        }

        $this->logger->info('Use default referer "{referer}" for url "{url}"', ['referer' => $default_referer, 'url' => $url]);

        return $default_referer;
    }
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 '/';
    }
1240208
public static function getReferrer(ServerRequestInterface $request)
    {
        if ($referrer = $request->getAttribute(self::REFERRER)) {
            return $referrer;
        }
        if ($referrer = Respond::session()->get(self::REFERRER)) {
            return $referrer;
        }
        $info = $request->getServerParams();

        return array_key_exists('HTTP_REFERER', $info) ? $info['HTTP_REFERER'] : '';
    }
102977
public static function isOnline($host = 'google.com', $force = false) {
		static $hosts = array();

		if ($force || !array_key_exists($host, $hosts)) {
			$hosts[$host] = !in_array(gethostbyname($host), array($host, false));
		}

		return $hosts[$host];
	}
269948
def convert_http_request(request, referrer_host=None):
    '''
    '''
    new_request = urllib.request.Request(
        request.url_info.url,
        origin_req_host=referrer_host,
    )

    for name, value in request.fields.get_all():
        new_request.add_header(name, value)

    return new_request
380900
public function setReferrer($referrer = '')
    {
        $this->referrer = $referrer;
        $this->debug->info(__FUNCTION__, 'setReferrer: ', $this->referrer);

        return $this;
    }
946289
def get(url, referer = nil)
      limit = redirect_limit
      loc = url
      loop do
        # if redirected to a relative url, merge it with the host of the original
        # request url
        loc = url.merge(loc) if loc.relative?

        response, response_time = get_response(loc, referer)
        code = Integer(response.code)
        redirect_to =
          begin
            response.is_a?(Net::HTTPRedirection) ? URI(response['location']).normalize : nil
          rescue URI::InvalidURIError => e
            @opts[:logger].debug { "Request #{url} got #{e}" } if @opts[:logger]
            nil
          end
        yield response, code, loc, redirect_to, response_time
        limit -= 1
        break unless (loc = redirect_to) && allowed?(redirect_to, url) && limit > 0
      end
    end
1275480
public function getLocalReferer()
    {
        $request = $this->getRequest();
        $referer = $request->getHeaderLine('HTTP_REFERER');
        $host = $request->getHeaderLine('HTTP_HOST');

        return $referer && parse_url($referer, PHP_URL_HOST) === $host ? $referer : '';
    }
1114751
protected function checkReferrer()
    {
        if (! isset($_SERVER['HTTP_REFERER'])) {
            throw new ErrorException('Direct image manipulation is not allowed.');
        }

        $referrer = preg_replace('%^https?://%', '', $_SERVER['HTTP_REFERER']);
        if (! preg_match("%^{$_SERVER['SERVER_NAME']}%", $referrer)) {
            throw new ErrorException('Referrer does not match the correct domain.');
        }
    }
151664
protected function factoryVisit($uuid, $ip, $location, $referrer, array $extra = [])
    {
        $data = array_merge([
            'uuid'     => $uuid,
            'location' => $location,
            'ip'       => $ip,
            'referrer' => $referrer,
        ], $extra);

        $visit = app()->make(config('analytics.model', Visit::class));

        $visit->fill($data);

        return $visit;
    }
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 : '/';
	}