X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=blobdiff_plain;f=includes%2FUser.php;h=c6d43365b8e59643028871698d4e2264d193465b;hb=703206f38c63ba51e75a8aa49724f112ab78047d;hp=8c88c17778c6d87dabd6b2f41b60a586cd1d2c4d;hpb=464051acad0b43d8f47e74b2356f6e7c7dd39edf;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/User.php b/includes/User.php index 8c88c17778..c6d43365b8 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1499,7 +1499,6 @@ class User { $limits = $wgRateLimits[$action]; $keys = array(); $id = $this->getId(); - $ip = $this->getRequest()->getIP(); $userLimit = false; if ( isset( $limits['anon'] ) && $id == 0 ) { @@ -1514,12 +1513,23 @@ class User { $keys[wfMemcKey( 'limiter', $action, 'user', $id )] = $limits['newbie']; } if ( isset( $limits['ip'] ) ) { + $ip = $this->getRequest()->getIP(); $keys["mediawiki:limiter:$action:ip:$ip"] = $limits['ip']; } - $matches = array(); - if ( isset( $limits['subnet'] ) && preg_match( '/^(\d+\.\d+\.\d+)\.\d+$/', $ip, $matches ) ) { - $subnet = $matches[1]; - $keys["mediawiki:limiter:$action:subnet:$subnet"] = $limits['subnet']; + if ( isset( $limits['subnet'] ) ) { + $ip = $this->getRequest()->getIP(); + $matches = array(); + $subnet = false; + if ( IP::isIPv6( $ip ) ) { + $parts = IP::parseRange( "$ip/64" ); + $subnet = $parts[0]; + } elseif ( preg_match( '/^(\d+\.\d+\.\d+)\.\d+$/', $ip, $matches ) ) { + // IPv4 + $subnet = $matches[1]; + } + if ( $subnet !== false ) { + $keys["mediawiki:limiter:$action:subnet:$subnet"] = $limits['subnet']; + } } } // Check for group-specific permissions