From 40947dfcc4d410b2af8316778d172efaba818e22 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 30 Oct 2009 21:41:34 +0000 Subject: [PATCH] (bug 3340) Allow configuring of /16 limit on range blocks --- RELEASE-NOTES | 2 ++ includes/DefaultSettings.php | 1 + includes/specials/SpecialBlockip.php | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 45e1e4170c..ee5650b832 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -90,6 +90,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * $wgCapitalLinkOverrides added to configure per-namespace capitalization * (bug 21172) $wgSorbsUrl can now be an array with multiple DNSBL * $wgEnableHtmlDiff has been removed +* (bug 3340) $wgBlockCIDRLimit added (default: 16) to configure the low end of + CIDR ranges for blocking === New features in 1.16 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 4e49053ce0..6f03c8b1bd 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1271,6 +1271,7 @@ $wgSysopRangeBans = true; # Allow sysops to ban IP ranges $wgAutoblockExpiry = 86400; # Number of seconds before autoblock entries expire $wgBlockAllowsUTEdit = false; # Default setting for option on block form to allow self talkpage editing whilst blocked $wgSysopEmailBans = true; # Allow sysops to ban users from accessing Emailuser +$wgBlockCIDRLimit = 16; # Blocks below the /16 set of IPs will not be allowed # Pages anonymous user may see as an array, e.g.: # array ( "Main Page", "Wikipedia:Help"); diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index a32092ee0c..81bdb64289 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -345,7 +345,7 @@ class IPBlockForm { * @return array(message key, arguments) on failure, empty array on success */ function doBlock( &$userId = null, &$expiry = null ) { - global $wgUser, $wgSysopUserBans, $wgSysopRangeBans, $wgBlockAllowsUTEdit; + global $wgUser, $wgSysopUserBans, $wgSysopRangeBans, $wgBlockAllowsUTEdit, $wgBlockCIDRLimit; $userId = 0; # Expand valid IPv6 addresses, usernames are left as is @@ -361,7 +361,7 @@ class IPBlockForm { if( preg_match( "/^($rxIP4)\\/(\\d{1,2})$/", $this->BlockAddress, $matches ) ) { # IPv4 if( $wgSysopRangeBans ) { - if( !IP::isIPv4( $this->BlockAddress ) || $matches[2] < 16 || $matches[2] > 32 ) { + if( !IP::isIPv4( $this->BlockAddress ) || $matches[2] < $wgBlockCIDRLimit || $matches[2] > 32 ) { return array( 'ip_range_invalid' ); } $this->BlockAddress = Block::normaliseRange( $this->BlockAddress ); -- 2.20.1