コード例 #1
0
ファイル: Visitor.php プロジェクト: Gninety/Microweber
 function getIp()
 {
     if (isset($this->details['location_ip'])) {
         return Piwik_Common::long2ip($this->details['location_ip']);
     }
     return false;
 }
コード例 #2
0
ファイル: IPTest.php プロジェクト: nnnnathann/piwik
 /**
  * @dataProvider getLong2IPTestData
  * @group Core
  * @group IP
  */
 public function testLong2ip($N, $P)
 {
     $this->assertEquals($P, Piwik_IP::long2ip($N), bin2hex($N));
     // this is our compatibility function
     $this->assertEquals($P, Piwik_Common::long2ip($N), bin2hex($N));
 }
コード例 #3
0
ファイル: Provider.php プロジェクト: Gninety/Microweber
 /**
  * Returns the hostname given the string IP in the format ip2long
  * php.net/ip2long
  * 
  * @param string $ip
  * 
  * @return string hostname
  */
 private function getHost($ip)
 {
     return trim(strtolower(@gethostbyaddr(Piwik_Common::long2ip($ip))));
 }
コード例 #4
0
ファイル: IP.test.php プロジェクト: nnnnathann/piwik
 function test_long2ip()
 {
     // a valid network address is either 4 or 16 bytes; those lines are intentionally left blank ;)
     $tests = array(null => '0.0.0.0', "" => '0.0.0.0', "" => '127.0.0.1', "��" => '192.168.1.1', "����" => '192.168.1.2', "���" => '0.0.0.0', "��" => '0.0.0.0', "��" => '0.0.0.0', '-1062731520' => '0.0.0.0', '3232235776' => '0.0.0.0', '168430090' => '0.0.0.0', '9999' => '57.57.57.57', "9999" => '57.57.57.57', '999' => '0.0.0.0', "999" => '0.0.0.0');
     foreach ($tests as $N => $P) {
         $this->assertEqual(Piwik_IP::long2ip($N), $P, bin2hex($N));
         // this is our compatibility function
         $this->assertEqual(Piwik_Common::long2ip($N), $P, bin2hex($N));
     }
 }
コード例 #5
0
ファイル: Visit.php プロジェクト: Gninety/Microweber
 /**
  * Checks if the visitor ip is in the excluded list
  * 
  * @param string $ip Long IP
  * @return bool
  */
 protected function isVisitorIpExcluded($ip)
 {
     $websiteAttributes = Piwik_Common::getCacheWebsiteAttributes($this->idsite);
     if (!empty($websiteAttributes['excluded_ips'])) {
         foreach ($websiteAttributes['excluded_ips'] as $ipRange) {
             if ($ip >= $ipRange[0] && $ip <= $ipRange[1]) {
                 printDebug('Visitor IP ' . Piwik_Common::long2ip($ip) . ' is excluded from being tracked');
                 return true;
             }
         }
     }
     return false;
 }