« throttle-analyze.php

( version controlblameraw text )



<?php
# WARNING: This file is publicly viewable on the web. Do not put private data here.

/**
* Helper to easily add a throttling request.
* See throttle.php for the format of $wmgThrottlingExceptions.
*/
$wgExtensionFunctions[] = function () {
global
$wmgThrottlingExceptions, $wgDBname, $wgRequest;

foreach (
$wmgThrottlingExceptions as $options ) {
# Validate entry, skip when it does not apply to our case

# 1) skip when it does not apply to our database name

if ( isset( $options['dbname'] ) && !in_array( $wgDBname, (array)$options['dbname'] ) ) {
continue;
}

# 2) skip expired entries
$inTimeWindow = time() >= strtotime( $options['from'] )
&&
time() <= strtotime( $options['to'] );

if ( !
$inTimeWindow ) {
continue;
}

# 3) skip when throttle does not apply to the client IP
$ip = $wgRequest->getIP();
if ( isset(
$options['IP'] ) ) {
$throttleIP = $options['IP'];
}
if ( isset(
$throttleIP ) && !in_array( $ip, (array)$throttleIP ) ) {
continue;
}
if ( isset(
$options['range'] ) && !IP::isInRanges( $ip, (array)$options['range'] ) ) {
continue;
}

# Finally) set up the throttle value
global $wgAccountCreationThrottle, $wgRateLimits, $wgGroupPermissions;
if ( isset(
$options['value'] ) && is_numeric( $options['value'] ) ) {
$wgAccountCreationThrottle = $options['value'];
} else {
$wgAccountCreationThrottle = 50; // Provide some sane default
}
$wgRateLimits['badcaptcha']['ip'] = [ 1000, 86400 ];
$wgRateLimits['badcaptcha']['newbie'] = [ 1000, 86400 ];
$wgGroupPermissions['user']['autoconfirmed'] = true; // T204583
$wgGroupPermissions['*']['skipcaptcha'] = true; // T227487
return; # No point in proceeding to another entry
}
};