Compare Referrer List With Referrer Domain

@param array $botreferrerlist
@param string $referrer_DNS
@return boolean      true: found, false: not found
963170
protected static function checkReferrerList($botreferrerlist, $referrer_DNS)
    {
        //Prüfung
        foreach ($botreferrerlist as $botreferrer)
        {
            $CheckBotRef = str_ireplace($botreferrer, '#', $referrer_DNS);
            if ($referrer_DNS != $CheckBotRef)
            {
                return true;
            };
        }
        return false;
    }
1319417
public function fetchRefererUrl(): string
    {
        $url = $this->session->get($this->refererUrlKey, '');
        $this->session->remove($this->refererUrlKey);

        return $url;
    }
615969
public function checkDns(&$result)
    {
        if ($this->deepWhois && empty($result['regrinfo']['domain']['nserver'])) {
            $ns = @dns_get_record($this->query['query'], DNS_NS);
            if (!is_array($ns)) {
                return;
            }
            $nserver = array();
            foreach ($ns as $row) {
                $nserver[] = $row['target'];
            }
            if (count($nserver) > 0) {
                $result['regrinfo']['domain']['nserver'] = $this->fixNameServer($nserver);
            }
        }
    }
679466
private function storeFrontendReferrer()
	{
		$base = \Environment::get('path');
		$base .= \System::getContainer()->get('router')->generate('contao_backend');

		$referrer = parse_url(\Environment::get('httpReferer'));
		$referrer = $referrer['path'] . ($referrer['query'] ? '?' . $referrer['query'] : '');

		// Stop if the referrer is a backend URL
		if (
			substr($referrer, 0, strlen($base)) === $base
			&& in_array(substr($referrer, strlen($base), 1), array(false, '/', '?'), true)
		) {
			return;
		}

		// Fix empty referrers
		if (empty($referrer)) {
			$referrer = '/';
		}

		// Make homepage possible as referrer
		if ($referrer === \Environment::get('path') . '/') {
			$referrer .= '?';
		}

		$referrer = \Environment::get('path') . '/bundles/rocksolidfrontendhelper/html/referrer.html?referrer=' . rawurlencode($referrer);

		// set the frontend URL as referrer

		$referrerSession = \System::getContainer()->get('session')->get('referer');

		if (defined('TL_REFERER_ID') && !\Input::get('ref')) {

			$referrer = substr($referrer, strlen(TL_PATH) + 1);
			$tlRefererId = substr(md5(TL_START - 1), 0, 8);
			$referrerSession[$tlRefererId]['current'] = $referrer;
			\Input::setGet('ref', $tlRefererId);
			$requestUri = \Environment::get('requestUri');
			$requestUri .= (strpos($requestUri, '?') === false ? '?' : '&') . 'ref=' . $tlRefererId;
			\Environment::set('requestUri', $requestUri);
			\System::getContainer()->get('request_stack')->getCurrentRequest()->query->set('ref', $tlRefererId);

		}

		\System::getContainer()->get('session')->set('referer', $referrerSession);
	}
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 '/';
    }
214572
function getReferrerUrl(bidderRequest) {
  let referer = '';
  if (bidderRequest && bidderRequest.refererInfo) {
    referer = encodeURIComponent(bidderRequest.refererInfo.referer);
  }
  return referer;
}
50848
function onReferralChase(ref) {
    var index = 0;
    var referralUrl;
    // Loop over the referrals received.
    while (referralUrl = (ref.uris || [])[index++]) {
      if (isAllowedReferral(referralUrl)) {
        log.debug('Following LDAP referral chase at %s', referralUrl);
        var referralClient = createClient.call(self, referralUrl, opts);
        pendingReferrals.push(referralClient);

        var referral = Url.parse(referralUrl);
        var referralBaseDn = (referral.pathname || '/').substring(1);
        referralClient.search(referralBaseDn, getLdapOpts(opts), controls, function(err, res) {
          /**
           * Occurs when a error is encountered with the referral client.
           * @param {Object} err The error object or string.
           */
          function onReferralError(err) {
            log.error(err, '[%s] An error occurred chasing the LDAP referral on %s (%j)',
                     (err || {}).errno, referralBaseDn, opts);
            removeReferral(referralClient);
          }
          // If the referral chase / search failed, fail silently.
          if (err) {
            onReferralError(err);
            return;
          }

          res.on('searchEntry', onSearchEntry);
          res.on('searchReference', onReferralChase);
          res.on('error', onReferralError);
          res.on('end', function(result) {
            removeReferral(referralClient);
            onSearchEnd();
          });
        });
      }
    }
  }
599130
public function referer($referer) {

		if(false === is_string($referer)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($referer)), E_USER_ERROR);
		}

		$this -> options[CURLOPT_REFERER] = $referer;

		return $this;
	}
569424
protected function detectReferrerSocialNetwork()
    {
        $cache    = \Piwik\Cache::getTransientCache();
        $cacheKey = 'cachedReferrerSocialNetworks';

        $cachedReferrerSocialNetworks = [];
        if ($cache->contains($cacheKey)) {
            $cachedReferrerSocialNetworks = $cache->fetch($cacheKey);
        }

        $socialNetworkName = false;
        if (isset($cachedReferrerSocialNetworks[$this->referrerUrl])) {
            $socialNetworkName = $cachedReferrerSocialNetworks[$this->referrerUrl];
        } else {
            if (SocialNetworkDetection::getInstance()->isSocialUrl($this->referrerUrl)) {
                $socialNetworkName = SocialNetworkDetection::getInstance()->getSocialNetworkFromDomain($this->referrerUrl);
            }

            /**
             * Triggered when detecting the social network of a referrer URL.
             *
             * Plugins can use this event to provide custom social network detection
             * logic.
             *
             * @param string|false &$socialNetworkName Name of the social network, or false if none detected
             *
             *                                        This parameter is initialized to the results
             *                                        of Matomo's default social network detection
             *                                        logic.
             * @param string referrerUrl The referrer URL from the tracking request.
             */
            Piwik::postEvent('Tracker.detectReferrerSocialNetwork', array(&$socialNetworkName, $this->referrerUrl));

            $cachedReferrerSocialNetworks[$this->referrerUrl] = $socialNetworkName;
            $cache->save($cacheKey, $cachedReferrerSocialNetworks);
        }

        if ($socialNetworkName === false) {
            return false;
        }

        $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_SOCIAL_NETWORK;
        $this->nameReferrerAnalyzed = $socialNetworkName;
        $this->keywordReferrerAnalyzed = '';
        return true;
    }
989961
public function addReferrer(ForeignKey $fk)
    {
        if ($this->referrers === null) {
            $this->referrers = array();
        }
        $this->referrers[] = $fk;
    }
1238422
private static function secondDomainFilter($requestUrlArr) {
        $domain = Domain::checkSecondDomain();
        if ($domain) {
            if (empty($requestUrlArr[0])) {
                $requestUrlArr[0] = $domain;
            } else {
                array_unshift($requestUrlArr, $domain);
            }
        }
        return $requestUrlArr;
    }
526218
public function hasReferrer(ForeignKey $fk)
    {
        return $this->hasReferrers() && in_array($fk, $this->referrers, true);
    }
764056
protected function queryExternalReferrers($idaction, $actionType, $logAggregator, $limitBeforeGrouping = false)
    {
        $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping);

        // we generate a single column that contains the interesting data for each referrer.
        // the reason we cannot group by referer_* becomes clear when we look at search engine keywords.
        // referer_url contains the url from the search engine, referer_keyword the keyword we want to
        // group by. when we group by both, we don't get a single column for the keyword but instead
        // one column per keyword + search engine url. this way, we could not get the top keywords using
        // the ranking query.
        $dimensions = array('referrer_data', 'referer_type');
        $rankingQuery->addLabelColumn('referrer_data');
        $selects = array(
            'CASE log_visit.referer_type
				WHEN ' . Common::REFERRER_TYPE_DIRECT_ENTRY . ' THEN \'\'
				WHEN ' . Common::REFERRER_TYPE_SEARCH_ENGINE . ' THEN log_visit.referer_keyword
				WHEN ' . Common::REFERRER_TYPE_SOCIAL_NETWORK . ' THEN log_visit.referer_name
				WHEN ' . Common::REFERRER_TYPE_WEBSITE . ' THEN log_visit.referer_url
				WHEN ' . Common::REFERRER_TYPE_CAMPAIGN . ' THEN CONCAT(log_visit.referer_name, \' \', log_visit.referer_keyword)
			END AS `referrer_data`');

        // get one limited group per referrer type
        $rankingQuery->partitionResultIntoMultipleGroups('referer_type', array(
                                                                              Common::REFERRER_TYPE_DIRECT_ENTRY,
                                                                              Common::REFERRER_TYPE_SEARCH_ENGINE,
                                                                              Common::REFERRER_TYPE_SOCIAL_NETWORK,
                                                                              Common::REFERRER_TYPE_WEBSITE,
                                                                              Common::REFERRER_TYPE_CAMPAIGN
                                                                         ));

        $type = $this->getColumnTypeSuffix($actionType);
        $where = 'visit_entry_idaction_' . $type . ' = ' . intval($idaction);

        $metrics = array(Metrics::INDEX_NB_VISITS);
        $data = $logAggregator->queryVisitsByDimension($dimensions, $where, $selects, $metrics, $rankingQuery);

        $referrerData = array();
        $referrerSubData = array();

        foreach ($data as $referrerType => &$subData) {
            $referrerData[$referrerType] = array(Metrics::INDEX_NB_VISITS => 0);
            if ($referrerType != Common::REFERRER_TYPE_DIRECT_ENTRY) {
                $referrerSubData[$referrerType] = array();
            }

            foreach ($subData as &$row) {
                if ($referrerType == Common::REFERRER_TYPE_SEARCH_ENGINE && empty($row['referrer_data'])) {
                    $row['referrer_data'] = \Piwik\Plugins\Referrers\API::LABEL_KEYWORD_NOT_DEFINED;
                }

                $referrerData[$referrerType][Metrics::INDEX_NB_VISITS] += $row[Metrics::INDEX_NB_VISITS];

                $label = $row['referrer_data'];
                if ($label) {
                    $referrerSubData[$referrerType][$label] = array(
                        Metrics::INDEX_NB_VISITS => $row[Metrics::INDEX_NB_VISITS]
                    );
                }
            }
        }

        $array = new DataArray($referrerData, $referrerSubData);
        return $array->asDataTable();
    }
1045375
public function referer( $valid_host = false, $valid_string = '' )
	{
		$ref = $this->server->getOr('HTTP_REFERER', '');
		if( $ref ) {

			if($valid_host) {
				$host = BASE_PROTOCOL . "://" . APP_HOST;
				$len = strlen($host);

				if( substr($ref, 0, $len) !== $host ) {
					return '';
				}

				if( strlen($ref) > $len ) {
					$end = $ref[$len];
					if( $end !== "/" && $end !== ":" ) {
						return '';
					}
				}
			}

			if($valid_string && strpos($ref, $valid_string) === false) {
				return '';
			}
		}

		return $ref;
	}
63937
public function track($refererUrl, $pageUrl)
    {
        $firstParsed = $this->getRefererParser()->parseUrl($refererUrl);

        if ($firstParsed) {
            $attributes = [
                'url'               => $firstParsed['url'],
                'host'              => $firstParsed['host'],
                'domain_id'         => $this->trackDomain($firstParsed['domain']),
                'medium'            => null,
                'source'            => null,
                'search_terms_hash' => null,
            ];

            $secondParsed = $this->getRefererParser()->parse($firstParsed['url'], $pageUrl);

            if ($secondParsed->isKnown()) {
                $attributes['medium']            = $secondParsed->getMedium();
                $attributes['source']            = $secondParsed->getSource();
                $attributes['search_terms_hash'] = sha1($secondParsed->getSearchTerm());
            }

            /** @var  \Arcanedev\LaravelTracker\Models\Referer  $referer */
            $referer = $this->getModel()->newQuery()->firstOrCreate(
                Arr::only($attributes, ['url', 'search_terms_hash']),
                $attributes
            );

            if ($secondParsed->isKnown()) {
                $this->trackRefererSearchTerms($referer, $secondParsed->getSearchTerm());
            }

            return $referer->id;
        }

        return null;
    }
1277483
public function hasNodeRef(NodeRef $nodeRef): bool
    {
        if (null === $this->getNodeBatchRequest) {
            return false;
        }

        return $this->getNodeBatchRequest->isInSet('node_refs', $nodeRef);
    }
665906
function isAllowedReferral(referral) {
  log.trace('isAllowedReferral(%j)', referral);
  if (! defaultReferrals.enabled) return(false);
  if (! referral) return(false);

  return(! _.any(defaultReferrals.exclude, function(exclusion) {
    var re = new RegExp(exclusion, "i");
    return(re.test(referral));
  }));
}