Perfected private IP Address detection

This commit is contained in:
Andre Lorbach 2008-07-25 15:34:39 +02:00
parent d2893c446d
commit d02044b92c

View File

@ -893,12 +893,15 @@ function InsertLookupLink( $szIP, $szDomain, $prepend, $append )
$szReturn = $prepend;
if ( strlen($szIP) > 0 )
{
// Split IP into array
$IPArray = explode(".", $szIP);
if (
(($pos = strpos($szIP, "10.")) !== FALSE && $pos == 0) ||
(($pos = strpos($szIP, "127.")) !== FALSE && $pos == 0) ||
(($pos = strpos($szIP, "172.")) !== FALSE && $pos == 0) ||
(($pos = strpos($szIP, "192.")) !== FALSE && $pos == 0) ||
(($pos = strpos($szIP, "255.")) !== FALSE && $pos == 0)
(intval($IPArray[0]) == 10 ) ||
(intval($IPArray[0]) == 127 ) ||
(intval($IPArray[0]) == 172 && intval($IPArray[1]) >= 16 && intval($IPArray[1]) <= 31) ||
(intval($IPArray[0]) == 192 && intval($IPArray[1]) == 168) ||
(intval($IPArray[0]) == 255 )
)
// Do not create a LINK in this case!
$szReturn .= '<b>' . $szIP . '</b>';