コード例 #1
0
ファイル: HitsView.php プロジェクト: riimu/accesslogstats
 public function processRow(\Riimu\LogParser\LogRow $row)
 {
     $day = $row->getDay();
     $agent = $row->getBrowser();
     $ip = $row->getIp();
     $this->increment($this->hits[$day]);
     if (!isset($this->lastSeen[$ip])) {
         $this->increment($this->ips[$day]);
     }
     if ($agent === null) {
         $this->increment($this->unknown[$day]);
     } elseif ($agent->Crawler) {
         $this->increment($this->crawlers[$day]);
     } else {
         if (!isset($this->lastSeen[$ip])) {
             $this->increment($this->visitors[$day]);
             $this->increment($this->new[$day]);
         } else {
             if ($this->lastSeen[$ip]->format('Y-m-d') !== $day) {
                 $this->increment($this->visitors[$day]);
             }
             if ($row->getDate()->modify('-7 days today')->getTimestamp() > $this->lastSeen[$ip]->getTimestamp()) {
                 $this->increment($this->new[$day]);
             }
             if ($this->isPageView($row)) {
                 $this->increment($this->views[$day]);
             }
         }
     }
     $this->lastSeen[$ip] = $row->getDate();
     return true;
 }
コード例 #2
0
ファイル: LinksView.php プロジェクト: riimu/accesslogstats
 public function processRow(\Riimu\LogParser\LogRow $row)
 {
     $url = $row->getReferrer();
     if ($url === null) {
         $this->noReferrer++;
         return true;
     }
     $agent = $row->getBrowser();
     if ($agent === null || $agent->Crawler) {
         $name = $agent === null ? 'Unknown' : $agent->Browser;
         $this->increment($this->crawlerReferrers[$name][$url]);
         return true;
     }
     if (!isset($this->referrers[$url])) {
         $info = $row->getUrlInfo();
         $referrer = $row->getReferrerInfo();
         if (!$info) {
             $this->increment($this->invalidReferrers[$url]);
             return true;
         } elseif ($referrer->getType() === 'search') {
             $this->increment($this->searchReferrers[$url]);
             return true;
         } elseif ($referrer->getType() === 'spam') {
             $this->increment($this->spamReferrers[$url]);
             return true;
         }
         $domain = $info->getHostname();
         if (in_array($domain, $this->internalDomains)) {
             $this->increment($this->internalReferrers[$url]);
             return true;
         }
         $this->referrers[$url] = ['domain' => $domain, 'days' => [], 'targets' => []];
         if (!isset($this->domains[$domain])) {
             $this->domains[$domain] = ['days' => [], 'referrers' => []];
         }
         $this->domains[$domain]['referrers'][] = $url;
     } else {
         $domain = $this->referrers[$url]['domain'];
     }
     $path = $row->getPath();
     if (!isset($this->targets[$path])) {
         $this->targets[$path] = ['days' => [], 'referrers' => []];
     }
     if (!in_array($path, $this->referrers[$url]['targets'])) {
         $this->referrers[$url]['targets'][] = $path;
     }
     if (!in_array($url, $this->targets[$path]['referrers'])) {
         $this->targets[$path]['referrers'][] = $url;
     }
     $day = $row->getDay();
     $this->increment($this->referrers[$url]['days'][$day]);
     $this->increment($this->domains[$domain]['days'][$day]);
     $this->increment($this->targets[$path]['days'][$day]);
     return true;
 }
コード例 #3
0
ファイル: AgentView.php プロジェクト: riimu/accesslogstats
 public function processRow(\Riimu\LogParser\LogRow $row)
 {
     $agent = $row->getUserAgent();
     if ($agent === null) {
         $this->noUserAgent++;
         return true;
     }
     $browser = $row->getBrowser();
     if ($browser === null) {
         $this->increment($this->invalidAgents[$agent]);
         return true;
     }
     $day = $row->getDay();
     if ($browser->Crawler) {
         $this->increment($this->crawlers[$browser->Browser][$day]);
     } else {
         $this->increment($this->browsers[$browser->Browser][$day]);
         $this->increment($this->versions[$browser->Browser][$browser->Version][$day]);
     }
     return true;
 }