From d02044b92c6728927e40dbb30617e2a1908a06e8 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 25 Jul 2008 15:34:39 +0200 Subject: [PATCH] Perfected private IP Address detection --- src/include/functions_common.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 2428902..c8039df 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -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 .= '' . $szIP . '';