@robocoder opened this issue on December 1st 2009

A modified provider plugin for intranet subnetwork identification, posted by Alain on the forum.

For example:

192.168.0.1 to 192.168.0.255: net1
192.168.1.0 to 192.168.1.255: net2
...

Use a spreadsheet to help create the php code to insert in IntranetSubNetwork.php, defining the first address, last address and net name.

Disclaimer: this plugin has not been reviewed by the Piwik team. Keywords: third-party-plugin

@robocoder commented on April 24th 2011

Attachment: v0.2 IntranetSubNetwork.zip

@anonymous-piwik-user commented on June 14th 2011

Attachment: Hack to make plugin work with IPv4 again ipv4hack.diff

@anonymous-piwik-user commented on June 17th 2011

Attachment: IPv6 support (missing comma) intraIPv6.diff

@anonymous-piwik-user commented on February 4th 2011

When I try to activate this plugin I get the following error

Fatal error: Call to undefined method Piwik::prefixtable() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\piwik\plugins\IntranetSubNetwork\IntranetSubNetwork.php on line 47

From reading other forums in Piwik it seems that the method Piwik::prefixtable() has been depricated.

Are there any efforts being carried out to update the plugin to resolve this issues?

@robocoder commented on February 4th 2011

Change it to Piwik_Common::prefixTable().

@mattab commented on April 23rd 2011

Plugin is broken currently, per message

@robocoder commented on April 24th 2011

Fixed the obvious errors. I'll patch it later for IPv6 support.

@anonymous-piwik-user commented on June 14th 2011

As PHP does not seem to have 128-bit int, this plugin will probably need a bit of refactoring to work with IPv6.

Attached patch to make it work with IPv4, no idea if it will barf on IPv6, as I do not have access to such a machine right now.

@anonymous-piwik-user commented on June 17th 2011

Well, that was a lot easier than I thought. The required function was already available in Piwik.

@anonymous-piwik-user commented on November 30th 2011

Plugin is not working correctly as of 30 Nov 2011. (Running Piwik 1.6)

This part

public function logIntranetSubNetworkInfo($notification)
  $hostname = $visitorInfo['location_ip'];
  $myipcomp = ip2long(inet_ntop($visitorInfo['location_ip']));

  if ($myipcomp>='2493968850' && $myipcomp<='2493969105')   { $hostname ='Net 1'; }  
...

does not appear to be processing the IP address properly. Using stored hex value in column location_ip in piwik_log_visit, it should be using something like base_convert($hex,16,10) to format into decimal value. (Based on testing the DB query select inet_ntoa(conv(location_ip), 16, 10) from piwik_log_visit;)

Even when given a VERY broad range of subnet addresses, the plugin still registers every visit as "Unknown."

@anonymous-piwik-user commented on December 7th 2011

I'm unable to upload a .diff due to our rigid network policies, so here's the fix I used. I ended up splitting the conversion into two variables for clarity, but obviously you can change $myipcomp to $myipcomp = hexdec(bin2hex($bin)).

-       $hostname = $visitorInfo['location_ip'];
+       $bin = $visitorInfo['location_ip']; /*IPv4 hack*/
+       $hex = bin2hex($bin); /* convert to hex (e.g., 94A6F1D2) */

+       $myipcomp = hexdec($hex); /* convert hex to IPv4 long (e.g., 2493968850) */
+       $hostname = long2ip($myipcomp); /* convert to human-readable format */

Obviously this means the comparison later needs to be replaced with $myipcomp, e.g.

if ($myipcomp>='2493968850' && $myipcomp<='2493969105')   { $hostname ='Net 1'; }
@anonymous-piwik-user commented on January 3rd 2012

I forgot to mention, intraIPv6.diff should work fine for IPv4 too. (Still works for me in 1.6)

@pklaus commented on April 26th 2012

This plugin is really useful! I created a repository on GitHub for this plugin: https://github.com/pklaus/IntranetSubNetwork It includes the IPv6 support patch by TW and I also added "default" networks for addresses belonging to the IPv4 and IPv6 address space respectively.

Thus, the plugin can also address the feature suggestion ipv6 statistics: http://forum.piwik.org/read.php?3,83250,83250

@pklaus commented on April 28th 2012

One more thing: You can see all a list of the commits and the diffs of the changes I made to the code on https://github.com/pklaus/IntranetSubNetwork/compare/v0.2...HEAD

@mattab commented on February 6th 2014

@pklaus, great to hear you published it on Github!

Along with the Piwik 2.0 release and new design for Piwik, we have also launched the official Plugins Marketplace to let any developer share their work to the thousands of Piwik users worldwide.

Maybe you'd like to publish your plugin there?

In any case, keep up the good work! Cheers.

@kwasib commented on February 6th 2014

This plugin currently doesn't work with Piwik 2.x. I've converted to be compatible and have published it to GitHub at https://github.com/kwasib/IntranetSubNetwork.

This issue was closed on February 6th 2014
Powered by GitHub Issue Mirror