X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2FIP.php;h=8efcd1589b4ff48872e3e1dbb20f78841c11b308;hb=76082f3b553b59ecca95aefdce67816ac967a430;hp=f95bb1ebded8a0b9df6c3e979b4b303dc416d754;hpb=86d7bd86fa08db2dbf3651a656d8238a34703c4f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/IP.php b/includes/libs/IP.php index f95bb1ebde..8efcd1589b 100644 --- a/includes/libs/IP.php +++ b/includes/libs/IP.php @@ -164,7 +164,7 @@ class IP { } if ( self::isIPv4( $ip ) ) { // Remove leading 0's from octet representation of IPv4 address - $ip = preg_replace( '/(?:^|(?<=\.))0+(?=[1-9]|0\.|0$)/', '', $ip ); + $ip = preg_replace( '!(?:^|(?<=\.))0+(?=[1-9]|0[./]|0$)!', '', $ip ); return $ip; } // Remove any whitespaces, convert to upper case @@ -425,7 +425,7 @@ class IP { $ip = self::sanitizeIP( $ip ); $n = ip2long( $ip ); if ( $n < 0 ) { - $n += pow( 2, 32 ); + $n += 2 ** 32; # On 32-bit platforms (and on Windows), 2^32 does not fit into an int, # so $n becomes a float. We convert it to string instead. if ( is_float( $n ) ) { @@ -487,7 +487,7 @@ class IP { } # Convert to unsigned if ( $network < 0 ) { - $network += pow( 2, 32 ); + $network += 2 ** 32; } } else { $network = false; @@ -523,7 +523,7 @@ class IP { $start = $end = false; } else { $start = sprintf( '%08X', $network ); - $end = sprintf( '%08X', $network + pow( 2, ( 32 - $bits ) ) - 1 ); + $end = sprintf( '%08X', $network + 2 ** ( 32 - $bits ) - 1 ); } // Explicit range } elseif ( strpos( $range, '-' ) !== false ) {