Changeset 50842 for trunk/src/wp-includes/Requests/IPv6.php
- Timestamp:
- 05/11/2021 07:40:41 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/Requests/IPv6.php
r46586 r50842 41 41 42 42 list($ip1, $ip2) = explode('::', $ip); 43 $c1 = ($ip1 === '') ? -1 : substr_count($ip1, ':');44 $c2 = ($ip2 === '') ? -1 : substr_count($ip2, ':');43 $c1 = ($ip1 === '') ? -1 : substr_count($ip1, ':'); 44 $c2 = ($ip2 === '') ? -1 : substr_count($ip2, ':'); 45 45 46 46 if (strpos($ip2, '.') !== false) { … … 52 52 } 53 53 // ::xxx 54 else 54 elseif ($c1 === -1) { 55 55 $fill = str_repeat('0:', 7 - $c2); 56 $ip = str_replace('::', $fill, $ip);56 $ip = str_replace('::', $fill, $ip); 57 57 } 58 58 // xxx:: 59 else 59 elseif ($c2 === -1) { 60 60 $fill = str_repeat(':0', 7 - $c1); 61 $ip = str_replace('::', $fill, $ip);61 $ip = str_replace('::', $fill, $ip); 62 62 } 63 63 // xxx::xxx 64 64 else { 65 65 $fill = ':' . str_repeat('0:', 6 - $c2 - $c1); 66 $ip = str_replace('::', $fill, $ip);66 $ip = str_replace('::', $fill, $ip); 67 67 } 68 68 return $ip; … … 85 85 public static function compress($ip) { 86 86 // Prepare the IP to be compressed 87 $ip = self::uncompress($ip);87 $ip = self::uncompress($ip); 88 88 $ip_parts = self::split_v6_v4($ip); 89 89 … … 127 127 protected static function split_v6_v4($ip) { 128 128 if (strpos($ip, '.') !== false) { 129 $pos = strrpos($ip, ':');129 $pos = strrpos($ip, ':'); 130 130 $ipv6_part = substr($ip, 0, $pos); 131 131 $ipv4_part = substr($ip, $pos + 1); … … 146 146 */ 147 147 public static function check_ipv6($ip) { 148 $ip = self::uncompress($ip);148 $ip = self::uncompress($ip); 149 149 list($ipv6, $ipv4) = self::split_v6_v4($ip); 150 $ipv6 = explode(':', $ipv6);151 $ipv4 = explode('.', $ipv4);150 $ipv6 = explode(':', $ipv6); 151 $ipv4 = explode('.', $ipv4); 152 152 if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4) { 153 153 foreach ($ipv6 as $ipv6_part) {
Note: See TracChangeset
for help on using the changeset viewer.