note 89935 added to function.ip2long
| From: | Robert at osu1 dot php dot net | Date: | Sun, 29 Mar 2009 23:55:49 +0000 |
| Subject: | note 89935 added to function.ip2long | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152592@lists.php.net to get a copy of this message | ||
to kaputt at starnet dot md @ 04-Nov-2008 09:47
Your code is WRONG!
for example: 10.0.0.0/8
$net_addr=decbin(myip2long('10.0.0.0')); -> 1010 00000000 00000000 00000000
in next step: substr($net_addr, 0, 8) -> 10100000
but real value must be: 00001010
as result your function '10.255.1.1' not mached by '10.0.0.0/8'
you must add some '0' in left part of binary IP to reach strlen($net_addr)==32
----
Server IP: 81.94.227.69
Probable Submitter: 83.241.18.18
----
Manual Page -- http://www.php.net/manual/en/function.ip2long.php
Edit -- https://master.php.net/note/edit/89935
Del: integrated -- https://master.php.net/note/delete/89935/integrated
Del: useless -- https://master.php.net/note/delete/89935/useless
Del: bad code -- https://master.php.net/note/delete/89935/bad+code
Del: spam -- https://master.php.net/note/delete/89935/spam
Del: non-english -- https://master.php.net/note/delete/89935/non-english
Del: in docs -- https://master.php.net/note/delete/89935/in+docs
Del: other reasons-- https://master.php.net/note/delete/89935
Reject -- https://master.php.net/note/reject/89935
Search -- https://master.php.net/manage/user-notes.php