r23758 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23757‎ | r23758 | r23759 >
Date:19:48, 5 July 2007
Author:brion
Status:old
Tags:
Comment:
Add $wgCaptchaWhitelistIP array of IP addresses or ranges allowed to skip the captcha.
From patch http://bugzilla.wikimedia.org/attachment.cgi?id=3868 by andy
Modified paths:
  • /trunk/extensions/ConfirmEdit/ConfirmEdit.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmEdit/ConfirmEdit.php
@@ -56,6 +56,16 @@
5757 $wgGroupPermissions['bot' ]['skipcaptcha'] = true; // registered bots
5858 $wgGroupPermissions['sysop' ]['skipcaptcha'] = true;
5959
 60+/**
 61+ * List of IP ranges to allow to skip the captcha, similar to the group setting:
 62+ * "$wgGroupPermission[...]['skipcaptcha'] = true"
 63+ *
 64+ * Specific IP addresses or CIDR-style ranges may be used,
 65+ * for instance:
 66+ * $wgCaptchaWhitelistIP = array('192.168.1.0/24', '10.1.0.0/16');
 67+ */
 68+$wgCaptchaWhitelistIP = false;
 69+
6070 global $wgCaptcha, $wgCaptchaClass, $wgCaptchaTriggers;
6171 $wgCaptcha = null;
6272 $wgCaptchaClass = 'SimpleCaptcha';
@@ -393,7 +403,17 @@
394404 wfDebug( "ConfirmEdit: user group allows skipping captcha\n" );
395405 return false;
396406 }
 407+ global $wgCaptchaWhitelistIP;
 408+ if( !empty( $wgCaptchaWhitelistIP ) ) {
 409+ $ip = wfGetIp();
 410+ foreach ( $wgCaptchaWhitelistIP as $range ) {
 411+ if ( IP::isInRange( $ip, $range ) ) {
 412+ return false;
 413+ }
 414+ }
 415+ }
397416
 417+
398418 global $wgEmailAuthentication, $ceAllowConfirmedEmail;
399419 if( $wgEmailAuthentication && $ceAllowConfirmedEmail &&
400420 $wgUser->isEmailConfirmed() ) {

Status & tagging log