@@ 140-146 (lines=7) @@ | ||
137 | * @return boolean TRUE if IPv6 |
|
138 | */ |
|
139 | ||
140 | private static function _is_ipv6( $ip ) { |
|
141 | if ( function_exists('filter_var') ) { |
|
142 | return filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) !== false; |
|
143 | } else { |
|
144 | return ! self::_is_ipv4( $ip ); |
|
145 | } |
|
146 | } |
|
147 | ||
148 | /** |
|
149 | * Check for an IPv4 address |
|
@@ 154-160 (lines=7) @@ | ||
151 | * @param string $ip IP to validate |
|
152 | * @return integer TRUE if IPv4 |
|
153 | */ |
|
154 | private static function _is_ipv4( $ip ) { |
|
155 | if ( function_exists('filter_var') ) { |
|
156 | return filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) !== false; |
|
157 | } else { |
|
158 | return preg_match( '/^\d{1,3}(\.\d{1,3}){3,3}$/', $ip ); |
|
159 | } |
|
160 | } |
|
161 | ||
162 | private static function _cut_ip( $ip, $cut_end = true ) { |
|
163 | $separator = ( self::_is_ipv4( $ip ) ? '.' : ':' ); |