/**
* Determine if an IP address really is an IP address, and if it is public,
* i.e. not RFC 1918 or similar
- * Comes from ProxyTools.php
*
* @param $ip String
* @return Boolean
/**
* Given an IP address in dotted-quad/octet notation, returns an unsigned integer.
* Like ip2long() except that it actually works and has a consistent error return value.
- * Comes from ProxyTools.php
*
* @param string $ip quad dotted IP address.
* @return Mixed: string/int/false
if ( self::isIPv6( $ip ) ) {
$n = self::toUnsigned6( $ip );
} else {
+ // Bug 60035: an IP with leading 0's fails in ip2long sometimes (e.g. *.08)
+ $ip = preg_replace( '/(?<=\.)0+(?=[1-9])/', '', $ip );
$n = ip2long( $ip );
if ( $n < 0 ) {
$n += pow( 2, 32 );