Ticket #1111: ipv6.patch
| File ipv6.patch, 4.2 KB (added by veretcle, 21 months ago) |
|---|
-
plugins/Live/Visitor.php
91 91 } 92 92 93 93 function getIp() 94 { 95 if(isset($this->details['location_ip'])) 96 { 97 return long2ip($this->details['location_ip']); 98 } 99 return false; 100 } 94 { 95 if(isset($this->details['location_ip'])) 96 { 97 if($this->details['location_ip'] !== '0') 98 { 99 return long2ip($this->details['location_ip']); 100 } 101 } 102 if(isset($this->details['location_ipv6'])) 103 { 104 return $this->details['location_ipv6']; 105 } 106 return false; 107 } 101 108 102 109 function getIdVisit() 103 110 { -
core/Tracker/Visit.php
57 57 // can be overwritten in constructor 58 58 protected $timestamp; 59 59 protected $ipString; 60 protected $ipv6String; 60 61 61 public function __construct($forcedIpString = null, $forcedDateTime = null )62 public function __construct($forcedIpString = null, $forcedDateTime = null, $forcedIpv6String = null) 62 63 { 63 64 $this->timestamp = time(); 64 65 if(!empty($forcedDateTime)) … … 72 73 } 73 74 74 75 $this->ipString = Piwik_Common::getIp($ipString); 76 77 $ipv6String = $forcedIpv6String; 78 if(empty($ipv6String)) 79 { 80 $ipv6String = Piwik_Common::getIpv6(); 81 } 82 83 $this->ipv6String = $ipv6String; 75 84 } 76 85 77 86 function setRequest($requestArray) … … 120 129 { 121 130 // the IP is needed by isExcluded() and GoalManager->recordGoals() 122 131 $this->visitorInfo['location_ip'] = $this->ipString; 132 $this->visitorInfo['location_ipv6'] = $this->ipv6String; 123 133 124 134 if($this->isExcluded()) 125 135 { … … 407 417 'config_silverlight' => $userInfo['config_silverlight'], 408 418 'config_cookie' => $userInfo['config_cookie'], 409 419 'location_ip' => $this->getVisitorIp(), 420 'location_ipv6' => $this->getVisitorIpv6(), 410 421 'location_browser_lang' => $userInfo['location_browser_lang'], 411 422 'location_country' => $country, 412 423 ); … … 477 488 return $this->visitorInfo['location_ip']; 478 489 } 479 490 491 /** 492 * Returns the visitor's IPv6 address 493 * 494 * @return string 495 */ 496 protected function getVisitorIpv6() 497 { 498 return $this->visitorInfo['location_ipv6']; 499 } 480 500 481 501 /** 482 502 * Returns the visitor's browser (user agent) -
core/Db/Schema/Myisam.php
200 200 config_silverlight TINYINT(1) NOT NULL, 201 201 config_cookie TINYINT(1) NOT NULL, 202 202 location_ip INT UNSIGNED NOT NULL, 203 location_ipv6 CHAR(39) NOT NULL, 203 204 location_browser_lang VARCHAR(20) NOT NULL, 204 205 location_country CHAR(3) NOT NULL, 205 206 location_continent CHAR(3) NOT NULL, -
core/Common.php
736 736 737 737 return sprintf("%u", ip2long($ipStringFrom)); 738 738 } 739 740 /** 741 * Convert dotted IP to a stringified integer representation 742 * 743 * @return string ip 744 */ 745 static public function getIpv6($ipv6StringFrom = false) 746 { 747 if($ipv6StringFrom === false) 748 { 749 $ipv6StringFrom = self::getIpString(); 750 } 751 // Is an IPv6 regular string (contains at least one colon char) 752 if(strpos($ipv6StringFrom, ':')) 753 { 754 return $ipv6StringFrom; 755 } 756 // Is not an IPv6 regular string, generic IPv6 address used 757 else 758 { 759 return '::'; 760 } 761 } 739 762 740 763 /** 741 764 * Returns the best possible IP of the current user, in the format A.B.C.D
