private function postUpdateWebsite($idSite) { Site::clearCache(); Cache::regenerateCacheWebsiteAttributes($idSite); SiteUrls::clearSitesCache(); }
/** * We have previously tried to detect the campaign variables in the URL * so at this stage, if the referrer host is the current host, * or if the referrer host is any of the registered URL for this website, * it is considered a direct entry * @return bool */ protected function detectReferrerDirectEntry() { if (empty($this->referrerHost)) { return false; } $urlsByHost = $this->getCachedUrlsByHostAndIdSite(); $directEntry = new SiteUrls(); $matchingSites = $directEntry->getIdSitesMatchingUrl($this->referrerUrlParse, $urlsByHost); if (isset($matchingSites) && is_array($matchingSites) && in_array($this->idsite, $matchingSites)) { $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY; return true; } elseif (isset($matchingSites)) { return false; } $site = Cache::getCacheWebsiteAttributes($this->idsite); $excludeUnknowns = $site['exclude_unknown_urls']; // fallback logic if the referrer domain is not known to any site to not break BC if (!$excludeUnknowns && isset($this->currentUrlParse['host'])) { // this might be actually buggy if first thing tracked is eg an outlink and referrer is from that site $currentHost = Common::mb_strtolower($this->currentUrlParse['host']); if ($currentHost == Common::mb_strtolower($this->referrerHost)) { $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_DIRECT_ENTRY; return true; } } return false; }
private function assertCachedSiteUrls($expectedUrls) { $urls = $this->siteUrls->getAllCachedSiteUrls(); $this->assertEquals($expectedUrls, $urls); }
public function setTrackerCacheGeneral(&$cacheContent) { $siteUrls = new SiteUrls(); $urls = $siteUrls->getAllCachedSiteUrls(); return $cacheContent['allUrlsByHostAndIdSite'] = $siteUrls->groupUrlsByHost($urls); }
/** * Checks if request URL is excluded * @return bool */ protected function isUrlExcluded() { $site = Cache::getCacheWebsiteAttributes($this->idSite); if (!empty($site['exclude_unknown_urls']) && !empty($site['urls'])) { $url = $this->request->getParam('url'); $parsedUrl = parse_url($url); $trackingUrl = new SiteUrls(); $urls = $trackingUrl->groupUrlsByHost(array($this->idSite => $site['urls'])); $idSites = $trackingUrl->getIdSitesMatchingUrl($parsedUrl, $urls); $isUrlExcluded = !isset($idSites) || !in_array($this->idSite, $idSites); return $isUrlExcluded; } return false; }
public function shouldPerformRedirectToUrl() { if (!$this->hasRedirectUrl()) { return false; } if (!$this->hasRequests()) { return false; } $redirectUrl = $this->getRedirectUrl(); $host = Url::getHostFromUrl($redirectUrl); if (empty($host)) { return false; } $urls = new SiteUrls(); $siteUrls = $urls->getAllCachedSiteUrls(); $siteIds = $this->getAllSiteIdsWithinRequest(); foreach ($siteIds as $siteId) { if (empty($siteUrls[$siteId])) { $siteUrls[$siteId] = array(); } if (Url::isHostInUrls($host, $siteUrls[$siteId])) { return $redirectUrl; } } return false; }
private function performRedirectToUrlIfSet() { if (!$this->hasRedirectUrl()) { return; } if (empty($this->requests)) { return; } $redirectUrl = $this->getRedirectUrl(); $host = Url::getHostFromUrl($redirectUrl); if (empty($host)) { return; } $urls = new SiteUrls(); $siteUrls = $urls->getAllCachedSiteUrls(); $siteIds = $this->getAllSiteIdsWithinRequest(); foreach ($siteIds as $siteId) { if (empty($siteUrls[$siteId])) { continue; } if (Url::isHostInUrls($host, $siteUrls[$siteId])) { Url::redirectToUrl($redirectUrl); } } }