diff --git a/includes/ipv6-functions.php b/includes/ipv6-functions.php deleted file mode 100644 index 5671d85ff..000000000 --- a/includes/ipv6-functions.php +++ /dev/null @@ -1,286 +0,0 @@ -0) { - $match = ''; - foreach($zeros[0] as $zero) { - if (strlen($zero) > strlen($match)) - $match = $zero; - } - $cip = preg_replace('/' . $match . '/', ':', $cip, 1); - } - $cip = preg_replace('/((^:)|(:$))/', '' ,$cip); - $cip = preg_replace('/((^:)|(:$))/', '::' ,$cip); - } - if('' != $netmask) { - $cip = $cip.'/'.$netmask; - } - return $cip; - } - - function SplitV64($ip) { - $ip = Net_IPv6::removeNetmaskSpec($ip); - $ip = Net_IPv6::Uncompress($ip); - if (strstr($ip, '.')) { - $pos = strrpos($ip, ':'); - $ip{$pos} = '_'; - $ipPart = explode('_', $ip); - return $ipPart; - } else { - return array($ip, ""); - } - } - - function checkIPv6($ip) { - $ip = Net_IPv6::removeNetmaskSpec($ip); - $ipPart = Net_IPv6::SplitV64($ip); - $count = 0; - if (!empty($ipPart[0])) { - $ipv6 =explode(':', $ipPart[0]); - for ($i = 0; $i < count($ipv6); $i++) { - $dec = hexdec($ipv6[$i]); - $hex = strtoupper(preg_replace("/^[0]{1,3}(.*[0-9a-fA-F])$/", "\\1", $ipv6[$i])); - if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex == strtoupper(dechex($dec))) { - $count++; - } - } - if (8 == $count) { - return true; - } elseif (6 == $count and !empty($ipPart[1])) { - $ipv4 = explode('.',$ipPart[1]); - $count = 0; - for ($i = 0; $i < count($ipv4); $i++) { - if ($ipv4[$i] >= 0 && (integer)$ipv4[$i] <= 255 && preg_match("/^\d{1,3}$/", $ipv4[$i])) { - $count++; - } - } - if (4 == $count) { - return true; - } - } else { - return false; - } - - } else { - return false; - } - } - - function _ip2Bin($ip) { - $binstr = ''; - $ip = Net_IPv6::removeNetmaskSpec($ip); - $ip = Net_IPv6::Uncompress($ip); - $parts = explode(':', $ip); - foreach($parts as $v) { - $str = base_convert($v, 16, 2); - $binstr .= str_pad($str, 16, '0', STR_PAD_LEFT); - } - return $binstr; - } - - function _bin2Ip($bin) { - $ip = ""; - if(strlen($bin)<128) { - $bin = str_pad($str, 128, '0', STR_PAD_LEFT); - } - $parts = str_split($bin, "16"); - foreach($parts as $v) { - $str = base_convert($v, 2, 16); - $ip .= $str.":"; - } - $ip = substr($ip, 0,-1); - return $ip; - } - -} - -?>