Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin: Intranet subnet identification #1054

Closed
robocoder opened this issue Dec 1, 2009 · 16 comments
Closed

Plugin: Intranet subnet identification #1054

robocoder opened this issue Dec 1, 2009 · 16 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. worksforme The issue cannot be reproduced and things work as intended.

Comments

@robocoder
Copy link
Contributor

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

@anonymous-matomo-user
Copy link

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
Copy link
Contributor Author

Change it to Piwik_Common::prefixTable().

@mattab
Copy link
Member

mattab commented Apr 23, 2011

Plugin is broken currently, per message

@robocoder
Copy link
Contributor Author

Attachment: v0.2
IntranetSubNetwork.zip

@robocoder
Copy link
Contributor Author

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

@anonymous-matomo-user
Copy link

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

@anonymous-matomo-user
Copy link

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-matomo-user
Copy link

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

@anonymous-matomo-user
Copy link

Attachment: IPv6 support (missing comma)
intraIPv6.diff

@anonymous-matomo-user
Copy link

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-matomo-user
Copy link

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-matomo-user
Copy link

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

@pklaus
Copy link

pklaus commented Apr 26, 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
Copy link

pklaus commented Apr 28, 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 pklaus/IntranetSubNetwork@v0.2...HEAD

@mattab
Copy link
Member

mattab commented Feb 6, 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
Copy link

kwasib commented Feb 6, 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

5 participants