protected function getReferrerInformation() { // default values for the referer_* fields $referrerUrl = Common::unsanitizeInputValue($this->referrerUrl); if (!empty($referrerUrl) && !UrlHelper::isLookLikeUrl($referrerUrl)) { $referrerUrl = ''; } $currentUrl = PageUrl::cleanupUrl($this->currentUrl); echo "a"; print_r($referrerUrl); exit; $this->referrerUrl = $referrerUrl; $this->referrerUrlParse = @parse_url($this->referrerUrl); $this->currentUrlParse = @parse_url($currentUrl); $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY; $this->nameReferrerAnalyzed = ''; $this->keywordReferrerAnalyzed = ''; $this->referrerHost = ''; if (isset($this->referrerUrlParse['host'])) { $this->referrerHost = $this->referrerUrlParse['host']; } $referrerDetected = $this->detectReferrerCampaign(); if (!$referrerDetected) { if ($this->detectReferrerDirectEntry() || $this->detectReferrerSearchEngine()) { $referrerDetected = true; } } if (!$referrerDetected && !empty($this->referrerHost)) { $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_WEBSITE; $this->nameReferrerAnalyzed = Common::mb_strtolower($this->referrerHost); $urlsByHost = $this->getCachedUrlsByHostAndIdSite(); $directEntry = new SiteUrls(); $path = $directEntry->getPathMatchingUrl($this->referrerUrlParse, $urlsByHost); if (!empty($path) && $path !== '/') { $this->nameReferrerAnalyzed .= rtrim($path, '/'); } } $referrerInformation = array('referer_type' => $this->typeReferrerAnalyzed, 'referer_name' => $this->nameReferrerAnalyzed, 'referer_keyword' => $this->keywordReferrerAnalyzed, 'referer_url' => $this->referrerUrl, 'current_url' => $this->currentUrl); return $referrerInformation; }
public static function getUrlIfLookValid($url) { $url = PageUrl::cleanupString($url); if (!UrlHelper::isLookLikeUrl($url)) { //WARNING: URL looks invalid and is discarded return false; } return $url; }
public static function getHostFromUrl($url) { if (!UrlHelper::isLookLikeUrl($url)) { $url = "http://" . $url; } return parse_url($url, PHP_URL_HOST); }
public static function getTrustedHostsFromConfig() { $hosts = self::getHostsFromConfig('General', 'trusted_hosts'); // Case user wrote in the config, http://example.com/test instead of example.com foreach ($hosts as &$host) { if (UrlHelper::isLookLikeUrl($host)) { $host = parse_url($host, PHP_URL_HOST); } } return $hosts; }