Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobocoder <anthon.pang@gmail.com>2010-09-27 18:22:02 +0400
committerrobocoder <anthon.pang@gmail.com>2010-09-27 18:22:02 +0400
commit880ee1876115d040409f758599b3e05b83426d5b (patch)
tree40651a51539cfe230bec12bc6c257e500554119e /plugins/AnonymizeIP
parent2459d0d6dc93217056639c41431640f91152019d (diff)
fixes #1735 - thanks arnotron
git-svn-id: http://dev.piwik.org/svn/trunk@3186 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'plugins/AnonymizeIP')
-rw-r--r--plugins/AnonymizeIP/AnonymizeIP.php3
-rw-r--r--plugins/AnonymizeIP/tests/AnonymizeIP.test.php3
2 files changed, 4 insertions, 2 deletions
diff --git a/plugins/AnonymizeIP/AnonymizeIP.php b/plugins/AnonymizeIP/AnonymizeIP.php
index 7e7daffe73..14a4266b8c 100644
--- a/plugins/AnonymizeIP/AnonymizeIP.php
+++ b/plugins/AnonymizeIP/AnonymizeIP.php
@@ -64,7 +64,8 @@ class Piwik_AnonymizeIP extends Piwik_Plugin
default:
}
- $res = unpack('V', $maskedIP);
+ // unpack byte array and mask to 32-bits
+ $res = unpack('V', $maskedIP) & 0xffffffff;
return sprintf("%u", $res[1]);
}
diff --git a/plugins/AnonymizeIP/tests/AnonymizeIP.test.php b/plugins/AnonymizeIP/tests/AnonymizeIP.test.php
index 44bc753234..e604b16502 100644
--- a/plugins/AnonymizeIP/tests/AnonymizeIP.test.php
+++ b/plugins/AnonymizeIP/tests/AnonymizeIP.test.php
@@ -36,7 +36,8 @@ class Test_Piwik_AnonymizeIP extends UnitTestCase
// each IP is tested with 0 to 4 octets masked
for($maskLength = 0; $maskLength <= 4; $maskLength++)
{
- $this->assertTrue( Piwik_AnonymizeIP::applyIPMask($ip, $maskLength) == $expected[$maskLength] );
+ $res = Piwik_AnonymizeIP::applyIPMask($ip, $maskLength);
+ $this->assertEqual( $res, $expected[$maskLength], "Got $res, Expected " . $expected[$maskLength] );
}
}
}