Re: ip2long and ipv6

From: Date: Mon, 09 Jan 2012 11:37:22 +0000
Subject: Re: ip2long and ipv6
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-316223@lists.php.net to get a copy of this message
On Jan 9, 2012, at 4:44 AM, Arno Kuhl wrote: > My dev and test tools are windows based and the apps deployed on linux, and > it's been working well. But moving to win7 created problems because it uses > ipv6 and code for ratings is for ipv4. Specifically, using ip2long to save > the ip as an int (to prevent duplicate votes) doesn't work in test > (win7/php5.3). I've got a quick-n-dirty workaround ("::1" converted to > "0") > but it seemed a good opportunity to add code to handle ipv6 properly when > it's deployed. > > I found a reference to do that in the help > (http://php.net/manual/en/function.ip2long.php), but the referenced site no > longer exists. I also found a page where Daniel Brown mentions that user > notes referencing external sites are normally removed > (http://www.lmpx.com/nav/article.php/news.php.net/php.notes/177158/read/inde > x.html) but that the note added enough value to make an exception. I'd be > very grateful if anyone could please point me to any other record of this > code, or could post it if they have a copy. > > Also, I'm assuming the code returns 2 ints because of the size of ipv6, and > it's fine to change my code to store that, but I'd like to know if there's a > standard way to store ip addresses in sql for quick lookup? > > Cheers > Arno Arno I use http://us.php.net/manual/en/function.inet-pton.php and http://us.php.net/manual/en/function.inet-ntop.php Tom

« previous php.general (#316223) next »