Skip to content

Commit

Permalink
Fixing #11
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaDafinser committed Jul 13, 2015
1 parent aa59dba commit d7c174f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
data.php
.project
.buildpath
.settings/org.eclipse.php.core.prefs
.settings
13 changes: 11 additions & 2 deletions IntranetGeoIP.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Piwik\Network;
use Piwik\Log;
use Piwik\Notification;
use Piwik\Plugins\PrivacyManager\Config as PrivacyManagerConfig;
use Piwik\Tracker\Request as TrackerRequest;

class IntranetGeoIP extends Plugin
{
Expand Down Expand Up @@ -89,7 +91,7 @@ public function uninstall()
*
* @see getListHooksRegistered()
*/
public function logIntranetSubNetworkInfo(&$visitorInfo)
public function logIntranetSubNetworkInfo(&$visitorInfo, TrackerRequest $request)
{
if (! file_exists($this->getDataFilePath())) {
Log::error('Plugin IntranetGeoIP does not work. File is missing: ' . $this->getDataFilePath());
Expand All @@ -104,7 +106,14 @@ public function logIntranetSubNetworkInfo(&$visitorInfo)
return;
}

$ip = Network\IP::fromBinaryIP($visitorInfo['location_ip']);
$privacyConfig = new PrivacyManagerConfig();

$ipBinary = $request->getIp();
if ($privacyConfig->useAnonymizedIpForVisitEnrichment === true) {
$ipBinary = $visitorInfo['location_ip'];
}

$ip = Network\IP::fromBinaryIP($ipBinary);

foreach ($data as $value) {
if (isset($value['networks']) && $ip->isInRanges($value['networks']) === true) {
Expand Down

0 comments on commit d7c174f

Please sign in to comment.