Пример #1
0
 public function test_groupUrlsByHost_shouldGroupByHost_WithDifferentDomainsAndPathsShouldListPathByNumberOfDirectoriesAndConvertToLowerCase()
 {
     $idSite = 1;
     $idSite2 = 2;
     $idSite3 = 3;
     $idSite4 = 4;
     $idSite5 = 5;
     $urls = array($idSite => array('http://apache.piwik/test', 'http://apache.piWik', 'http://apache.piwik/foo/bAr/', 'http://apache.piwik/Foo/SECOND'), $idSite2 => array('http://apache.piwik/test/', 'http://example.oRg', 'http://apache.piwik/foo/secOnd'), $idSite3 => array('http://apache.piwik/', 'http://apache.piwik/third', 'http://exampLe.com', 'http://example.org/foo/test/two'), $idSite4 => array(), $idSite5 => array('invalidUrl', 'ftp://example.org/'));
     $expected = array('apache.piwik' => array('/foo/second/' => array($idSite, $idSite2), '/foo/bar/' => array($idSite), '/third/' => array($idSite3), '/test/' => array($idSite, $idSite2), '/' => array($idSite, $idSite3)), 'example.org' => array('/foo/test/two/' => array($idSite3), '/' => array($idSite2, $idSite5)), 'example.com' => array('/' => array($idSite3)));
     $this->assertSame($expected, $this->siteUrls->groupUrlsByHost($urls));
 }
Пример #2
0
 public function setTrackerCacheGeneral(&$cacheContent)
 {
     $siteUrls = new SiteUrls();
     $urls = $siteUrls->getAllCachedSiteUrls();
     return $cacheContent['allUrlsByHostAndIdSite'] = $siteUrls->groupUrlsByHost($urls);
 }
Пример #3
0
 /**
  * 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;
 }