http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72959
Revision: 72959
Author: raymond
Date: 2010-09-14 08:58:07 +0000 (Tue, 14 Sep 2010)
Log Message:
-----------
(bug 16574) Allow administrators to temporarily disable the account creation
limit for IP addresses: [[MediaWiki:Ratelimit-excluded-ips]]
Modified Paths:
--------------
trunk/phase3/RELEASE-NOTES
trunk/phase3/includes/DefaultSettings.php
trunk/phase3/includes/User.php
trunk/phase3/languages/messages/MessagesEn.php
trunk/phase3/maintenance/language/messages.inc
Modified: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES 2010-09-14 07:50:19 UTC (rev 72958)
+++ trunk/phase3/RELEASE-NOTES 2010-09-14 08:58:07 UTC (rev 72959)
@@ -158,6 +158,8 @@
* (bug 24007) Diff pages now mention the number of users having edited
intermediate revisions
* Added new hook GetIP
+* (bug 16574) Allow administrators to temporarily disable the account creation
+ limit for IP addresses: [[MediaWiki:Ratelimit-excluded-ips]]
=== Bug fixes in 1.17 ===
* (bug 17560) Half-broken deletion moved image files to deletion archive
Modified: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php 2010-09-14 07:50:19 UTC (rev
72958)
+++ trunk/phase3/includes/DefaultSettings.php 2010-09-14 08:58:07 UTC (rev
72959)
@@ -3407,6 +3407,8 @@
/**
* Array of IPs which should be excluded from rate limits.
* This may be useful for whitelisting NAT gateways for conferences, etc.
+ * Wiki administrators can add additional IP addresses via
+ * [[MediaWiki:Ratelimit-excluded-ips]]
*/
$wgRateLimitsExcludedIPs = array();
Modified: trunk/phase3/includes/User.php
===================================================================
--- trunk/phase3/includes/User.php 2010-09-14 07:50:19 UTC (rev 72958)
+++ trunk/phase3/includes/User.php 2010-09-14 08:58:07 UTC (rev 72959)
@@ -1212,10 +1212,34 @@
// Deprecated, but kept for backwards-compatibility
config
return false;
}
- if( in_array( wfGetIP(), $wgRateLimitsExcludedIPs ) ) {
+
+ wfDebug( "Checking the list of IP addresses excluded from rate
limit..\n" );
+
+ // Read list of IP addresses from MediaWiki namespace
+ $message = wfMsgForContentNoTrans( 'ratelimit-excluded-ips' );
+ $lines = explode( "\n", $message );
+ foreach( $lines as $line ) {
+ // Remove comment lines
+ $comment = substr( trim( $line ), 0, 1 );
+ if ( $comment == '#' || $comment == '' ) {
+ continue;
+ }
+ // Remove additional comments after an IP address
+ $comment = strpos( $line, '#' );
+ if ( $comment > 0 ) {
+ $line = trim( substr( $line, 0, $comment-1 ) );
+ if ( IP::isValid( $line ) ) {
+ $wgRateLimitsExcludedIPs[] =
IP::sanitizeIP( $line );
+ }
+ }
+ }
+
+ $ip = IP::sanitizeIP( wfGetIP() );
+ if( in_array( $ip, $wgRateLimitsExcludedIPs ) ) {
// No other good way currently to disable rate limits
// for specific IPs. :P
// But this is a crappy hack and should die.
+ wfDebug( "IP $ip matches the list of rate limit
excluded IPs\n" );
return false;
}
return !$this->isAllowed('noratelimit');
Modified: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php 2010-09-14 07:50:19 UTC
(rev 72958)
+++ trunk/phase3/languages/messages/MessagesEn.php 2010-09-14 08:58:07 UTC
(rev 72959)
@@ -1134,6 +1134,11 @@
* Italiano|it
* Nederlands|nl', # do not translate or duplicate this message to other
languages
'suspicious-userlogout' => 'Your request to log out was denied because it
looks like it was sent by a broken browser or caching proxy.',
+'ratelimit-excluded-ips' => ' #<!-- leave this line exactly as it is -->
<pre>
+# Syntax is as follows:
+# * Everything from a "#" character to the end of the line is a comment
+# * Every non-blank line is an IP address excluded from the rate limit
+ #</pre> <!-- leave this line exactly as it is -->',
# JavaScript password checks
'password-strength' => 'Estimated password strength: $1',
Modified: trunk/phase3/maintenance/language/messages.inc
===================================================================
--- trunk/phase3/maintenance/language/messages.inc 2010-09-14 07:50:19 UTC
(rev 72958)
+++ trunk/phase3/maintenance/language/messages.inc 2010-09-14 08:58:07 UTC
(rev 72959)
@@ -456,6 +456,7 @@
'loginlanguagelabel',
'loginlanguagelinks',
'suspicious-userlogout',
+ 'ratelimit-excluded-ips',
),
'passwordstrength' => array(
'password-strength',
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs