IP addresses in database table piwik_log_visit are showing in hex

Hi all-
I’m trying to use the Intranet Subnet plugin to help map our incoming IPs. (Basically we’re behind a firewall/proxy, so all incoming IPs are showing up as from U.S.-based even though they’re supposed to be overseas.) Unfortunately, it doesn’t seem to be working… I went through and chose some exisiting tracked IPs, converted them, and put them in manually to try and trigger it to show.

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

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

Anyway, I looked at the DB table and all the location_ip values are in hex. This doesn’t sound right, as I’m guessing they should be in an IPv4 format, e.g. 175275015…? Should I try and alter my DB table to fix this? :S

location_ip is hex for me too. Don’t alter your tables!

Use internal piwik functions to alter the ip address, or if they do not exist, find the function responsible for encoding the IP before putting them in the database.

Yep, tried that using a custom ip2long function that would take in a hex value and turn it into the ipv4 number… no such luck, AND it broke the tracking. (All web archiving reports are gone for yesterday. :stuck_out_tongue: They’re in the DB, just not showing up on the dashboard. :frowning: )

Piwik supports ipv6 which makes it slightly more complicated to play with IPs like we used to… See the code used (and reusable!!) in http://dev.piwik.org/trac/browser/trunk/core/IP.php