Example #1
0
 /**
  * @group Core
  * @group UserAgentIsKnownBot
  */
 public function testIsVisitor_userAgentIsKnownBot()
 {
     $isUserAgentBot = array('baiduspider' => true, 'bingbot' => true, 'BINGBOT' => true, 'x BingBot x' => true, 'BingPreview' => true, 'facebookexternalhit' => true, 'YottaaMonitor' => true, 'Mozilla/5.0 (compatible; CloudFlare-AlwaysOnline/1.0; +http://www.cloudflare.com/always-online) XXXX' => true, 'Pingdom.com_bot_version_1.4_(http://www.pingdom.com/)' => true, 'Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)' => true, 'Exabot/2.0' => true, 'sogou spider' => true, 'Mozilla/5.0(compatible;Sosospider/2.0;+http://help.soso.com/webspider.htm)' => true, 'AdsBot-Google (+http://www.google.com/adsbot.html)' => true, 'Google Page Speed Insights' => true, 'Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0 Google (+https://developers.google.com/+/web/snippet/)' => true, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.51 (KHTML, like Gecko; Google Web Preview) Chrome/12.0.742 Safari/534.51' => true, 'Googlebot-Video/1.0' => true, 'Googlebot' => true, 'random' => false, 'hello world' => false, 'this is a user agent' => false, 'Mozilla' => false);
     $idsite = API::getInstance()->addSite("name", "http://piwik.net/");
     foreach ($isUserAgentBot as $userAgent => $isBot) {
         $request = new Request(array('idsite' => $idsite, 'bots' => 0, 'ua' => $userAgent));
         $excluded = new VisitExcluded_public($request);
         $this->assertSame($isBot, $excluded->public_isNonHumanBot(), $userAgent);
     }
 }
Example #2
0
 /**
  * @group Core
  * @group IpIsKnownBot
  */
 public function testIsVisitor_ipIsKnownBot()
 {
     $isIpBot = array('66.249.85.36' => true, '66.249.91.150' => true, '64.233.172.1' => true, '1.202.218.8' => true, '66.248.91.150' => false, '66.250.91.150' => false);
     $idsite = API::getInstance()->addSite("name", "http://piwik.net/");
     $request = new Request(array('idsite' => $idsite, 'bots' => 0));
     foreach ($isIpBot as $ip => $isBot) {
         $excluded = new VisitExcluded_public($request, IP::P2N($ip));
         $this->assertSame($isBot, $excluded->public_isNonHumanBot(), $ip);
     }
 }