X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=Uplink%2FNumerics.class.php;fp=Uplink%2FNumerics.class.php;h=7b6bee116e219da74223c50deb4d5ff1f215d480;hb=74fcc85514c9bd0a4a8dfbd909d9555a9f1ee5b8;hp=2af7132f404dfd473298188d8f82aa94eeb3802f;hpb=412e324075de1312fbc5f49b735180b46cdff82c;p=PHP-P10.git diff --git a/Uplink/Numerics.class.php b/Uplink/Numerics.class.php index 2af7132..7b6bee1 100644 --- a/Uplink/Numerics.class.php +++ b/Uplink/Numerics.class.php @@ -137,14 +137,25 @@ class Numerics { $ipv6 = array(); $ip = explode(":",$ip); $last_zero = false; $zero_sequence = 0; $biggest_zero_sequence = 0; $max_start = -1; - foreach($ip as $i => $v) { + $i = 0; + foreach($ip as $v) { if($v == "") { $skipBlocks = (8 - count($ip)); for($j = 0; $j < $skipBlocks; $j++) { $ipv6[$i+$j] = "_"; } $max_start = $i; - $biggest_zero_sequence = $skipBlocks; + if($last_zero) { + $zero_sequence += $skipBlocks; + } else { + $last_zero = true; + $zero_sequence = $skipBlocks; + } + $i+=$skipBlocks; + if($zero_sequence > $biggest_zero_sequence) { + $biggest_zero_sequence = $zero_sequence; + $max_start = $i-($zero_sequence-1); + } } else { $value = hexdec($v); if($value == 0) { @@ -163,6 +174,7 @@ class Numerics { $ipv6[$i] = self::intToNum($value,3); $last_zero = false; } + $i++; } } $ip = "";