Extension:ConfirmEdit/zh

From MediaWiki.org
Jump to: navigation, search
語言:Project:Language policy English  • Deutsch • русский • 中文
本插件从1.18开始收录与MediaWiki。因此你不需要再次下载。
MediaWiki扩展手册Manual:Extensions
Crystal Clear action run.png
ConfirmEdit

发布状态:Extension status 稳定版

实现Template:Extension#type Page action
描述Template:Extension#description 为页面保存增加验证码机制和其他用户命令
作者Template:Extension#username Brion Vibber等人
最新版本Template:Extension#version 1.3 (2014-12-05)
MediaWikiTemplate:Extension#mediawiki 1.21+
PHPTemplate:Extension#php 5.3+
数据更新Template:Extension#needs-updatephp
许可协议Template:Extension#license GNU General Public License 2.0 or later
下载
例子Template:Extension#example One screenshot of ConfirmEdit running on Wikimanga.net
参数Template:Extension#parameters
  • $wgCaptchaClass
  • $wgCaptchaWhitelistIP
  • $wgCaptcha
  • $wgCaptchaTriggers
  • $wgCaptchaTriggersOnNamespace
  • $wgCaptchaStorageClass
  • $wgCaptchaSessionExpiration
  • $wgCaptchaBadLoginExpiration
  • $ceAllowConfirmedEmail
  • $wgCaptchaBadLoginAttempts
  • $wgCaptchaWhitelist
  • $wgCaptchaRegexes
  • $wgCaptchaQuestions
  • $wgReCaptchaPublicKey
  • $wgReCaptchaPrivateKey
添加的权限Template:Extension#rights

skipcaptcha

使用的钩子Template:Extension#hook
UserCreateFormManual:Hooks/UserCreateForm
AbortNewAccountManual:Hooks/AbortNewAccount
LoginAuthenticateAuditManual:Hooks/LoginAuthenticateAudit
UserLoginFormManual:Hooks/UserLoginForm
AbortLoginManual:Hooks/AbortLogin
EmailUserFormManual:Hooks/EmailUserForm
EmailUserManual:Hooks/EmailUser
EditPage::showEditForm:fieldsManual:Hooks/EditPage::showEditForm:fields
EditFilterMergedContentManual:Hooks/EditFilterMergedContent
APIGetAllowedParamsManual:Hooks/APIGetAllowedParams
APIGetParamDescriptionManual:Hooks/APIGetParamDescription
AddNewAccountApiFormManual:Hooks/AddNewAccountApiForm
AddNewAccountApiResultManual:Hooks/AddNewAccountApiResult

翻译ConfirmEdit扩展(如果在translatewiki.net可用)

检查使用和版本矩阵。

问题Phabricator

开放的工作 · 报告错误

ConfirmEdit扩展让你使用各种不同的验证码技术,来阻止Spam机器 和其他自动化工具来编辑你的wiki,并阻止自动化登录来猜密码。(阻止暴力破用户解密码)

ConfirmEdit集成了几个技术或模块来生存验证码。

模块 描述 防Spam效果
简单验证码 用户需要解决一个简单的数学问题。
复杂验证码 用户需要识别一系列的以一种风格显示的字符。
数学验证码 用户需要解决一个以图片显示的数学问题。
问题验证码 用户需要回答由管理员设置的问题。 很高,直到崩溃
ReCaptcha 用户需要识别一系列视觉化或听觉化的字符,小部件由reCAPTCHA提供服务。
Are You A Human Users are presented with a small JavaScript-based puzzle that they must complete, usually of the form of matching appropriate objects.

Some of these modules require additional setup work:

  • MathCaptcha requires both the presence of TeX and, for versions of MediaWiki after 1.17, the Math extension;
  • FancyCaptcha requires running a preliminary setup script in Python;
  • and reCAPTCHA requires obtaining API keys.

Caveats: CAPTCHAs reduce accessibility and cause inconvenience to human users. In addition, they are not 100% effective against bots, and they will not protect your wiki from spammers who are willing and able to use human labor to get through the CAPTCHAs. You may wish to use ConfirmEdit in conjunction with other anti-spam features. Regardless of the solution you use, if you have a publicly-editable wiki it's important to keep monitoring the "Recent changes" page.

Starting October 6, 2014 the available Asirra module is no longer functional due to the discontinuation of the underlying Asirra service.[1]

安装[edit]

注意 注意: 如果使用不同于规定版本MediaWiki ,ConfirmEdit可能无法正常工作,when downloading via the "Extension distributor".

  • 下载文件,并将其放置在您extensions/文件夹中的ConfirmEdit目录内。
  • 将下列代码放置在您的LocalSettings.php的底部:
    require_once "$IP/extensions/ConfirmEdit/ConfirmEdit.php";
    
  • 选择CAPTCHA验证类型
  • 需要配置
  • YesY 完成 - 在您的wiki上导航至Special:Version,以验证扩展已成功安装。

CAPTCHA types[edit]

There are numerous different CAPTCHA types included with ConfirmEdit.

QuestyCaptcha[edit]

This module presents a question and the user supplies the answer. You provide the questions in the configuration. This module has proven to offer a strong mechanism against spam bots; it also should have the advantage of a better accessibility, as textual questions can be read by text-to-speech software allowing visually impaired users (but not bots) to answer correctly.

Add the following to LocalSettings.php to enable this CAPTCHA, editing the Q&A:

// Use this line ONLY if your MediaWiki version is 1.25 or newer:
wfLoadExtension( 'ConfirmEdit/QuestyCaptcha' );
// Use this line ONLY if your MediaWiki version is older than 1.25:
require_once "$IP/extensions/ConfirmEdit/QuestyCaptcha.php";

$wgCaptchaClass = 'QuestyCaptcha';

// Add your questions in LocalSettings.php using this format
$wgCaptchaQuestions[] = array( 'question' => "A question?", 'answer' => "An Answer");
$wgCaptchaQuestions[] = array( 'question' => 'How much wood would a woodchuck chuck if a woodchuck could chuck wood?', 'answer' => 'as much wood as...' );
$wgCaptchaQuestions[] = array( 'question' => "What is this wiki's name?", 'answer' => "$wgSitename" );
// You can also provide several acceptable answers to a given question (the answers shall be in lowercase):
$wgCaptchaQuestions[] = array( 'question' => "2 + 2 ?", 'answer' => array( '4', 'four' ) );

It will randomly choose a question from those supplied. The minimum is one.

  • The answer must be easy to guess for a human interested in your wiki, but not by an automatic program. Ideally, it should not be contained in the text of the question; you can try and edit the captcha help messages[2] and provide the solution to the captcha response there.
  • Just change the questions when/if they start proving ineffective; this may never happen if your wiki is not specifically targeted.
  • Don't ever reuse questions already used by you or others in the past: spambots are known to remember a question and its answer forever once they broke it.
  • You can get even smarter, with questions like «What is the output of "date -u +%V`uname`|sha256sum|sed 's/\W//g'"?».
  • And other dynamic questy captchas. DO NOT use an exact copy of the dynamic questions from the link -- they've been cracked by spammers. However other dynamic questions in the style of the questions presented are highly effective.

ReCaptcha[edit]

Example screenshot of ReCaptcha

This module uses the "reCAPTCHA" widget/service. In addition to providing a CAPTCHA, it performs a valuable service because it helps to digitize old books (read more here.)

To use this module, first go here and obtain a public and private key for your wiki.

Add the following to LocalSettings.php, below the inclusion of ConfirmEdit:

// Use this line ONLY if your MediaWiki version is 1.25 or newer:
wfLoadExtension( 'ConfirmEdit/ReCaptcha' );
// Use this line ONLY if your MediaWiki version is older than 1.25:
require_once "$IP/extensions/ConfirmEdit/ReCaptcha.php";
$wgCaptchaClass = 'ReCaptcha';
$wgReCaptchaPublicKey = 'your public key here';
$wgReCaptchaPrivateKey = 'your private key here';
  • Recaptcha is only in the ConfirmEdit versions bundled with MediaWiki 1.18 and above. Earlier versions do not have the reCAPTCHA PHP files.
  • Unfortunately, as of 2011, some spammers appear to have figured out a way to bypass it, either through character recognition or by using humans. For that reason, it is not necessarily recommended.
  • Part of the weakness of the ReCaptcha module is that ConfirmEdit doesn't include any penalty mechanism, so spam bots can simply keep trying to bypass the CAPTCHA until they get through. This is an issue that is strongly worth addressing in some way.
  • Regardless of its strengths or weaknesses, reCAPTCHA can't be implemented on Wikimedia wikis because it produces a third-party dependency.

Are You A Human (aka PlayThru)[edit]

NB: Not yet merged into ConfirmEdit, pending code review; applying the patch is your own decision. → https://gerrit.wikimedia.org/r/#/c/65797/

The actual CAPTCHA is proprietary like ReCaptcha and English only, but unlike them requires (gratis) keys and may embed ads, specifically "branded games".[1]

This module uses the Are You A Human? service (demo), which is an alternative to distorted text-based CAPTCHAs. It presents a small JavaScript-based puzzle that the user must complete, usually of the form of matching appropriate objects. It includes audio support for the visually impaired.

To use this module: *NOTE - the default installation of MediaWiki does not include all the files necessary for this plugin. You'll have to get the latest from Github: https://github.com/nicjansma/mediawiki-ConfirmEdit-AreYouAHuman

And configure when you want to fire it by looking here: http://www.mediawiki.org/wiki/Extension:ConfirmEdit#Configuration

  1. Go here and obtain Publisher and Scoring keys for your domain and wiki.
    • When given the choice, select "embedded" style, rather than the default LightBox style. LightBox may work, but it hasn't been tested.
    • Enter the domain precisely how it appears in $wgServer, but without the protocol. For example: if your wiki is http://www.mywiki.com, use www.mywiki.com. Entering mywiki.com will not work.
    • MediaWiki is not listed as one of the officially supported platforms, so choose PHP instead.
  2. Download the AYAH PHP integration library when given the option.
  3. Unpack the PHP integration library and put ayah.php and ayah_config.php into $IP/extensions/ConfirmEdit/AreYouAHuman/.
  4. Edit ayah_config.php with your API keys
  5. Add the following to LocalSettings.php:
require_once "$IP/extensions/ConfirmEdit/AyahCaptcha.php";
$wgCaptchaClass = 'AyahCaptcha';

Not recommended[edit]

警告 警告: The following types are used by very few wikis outside WMF if any, probably because of scarce effectiveness.

SimpleCaptcha (calculation)[edit]

a simple math question.

This is the default CAPTCHA. This module provides a simple addition or subtraction question for the user.

Add the following lines to LocalSettings.php in the root of your MediaWiki to enable this CAPTCHA:

$wgCaptchaClass = 'SimpleCaptcha';

Note that the display of a trivial maths problem as plaintext yields a captcha which can be trivially solved by automated means; as of 2012, sites using SimpleCaptcha are receiving significant amounts of spam and many automated registrations of spurious new accounts. Wikis currently using this default setting should therefore migrate to VisualMathCaptcha or one of the other CAPTCHAs.

FancyCaptcha[edit]

FancyCaptcha screenshot.png

This module displays a stylized image of a set of characters. The Python Imaging Library must be installed in order to create the set of images initially, but isn't needed after that (can be installed with pip install pil in most environments).

  1. Add the following lines to LocalSettings.php in the root of your MediaWiki installation:
    MediaWiki version is 1.25 or newer:
    wfLoadExtensions( array( 'ConfirmEdit', 'ConfirmEdit/FancyCaptcha' ) );
    $wgCaptchaClass = 'FancyCaptcha';
    MediaWiki version is older than 1.25:
    require_once "$IP/extensions/ConfirmEdit/ConfirmEdit.php";
    require_once "$IP/extensions/ConfirmEdit/FancyCaptcha.php";
    $wgCaptchaClass = 'FancyCaptcha';
  2. In LocalSettings.php, set the variable $wgCaptchaDirectory to the directory where you will store Captcha images. Below it set $wgCaptchaSecret to your passphrase.
  3. Create the images by running the following, where:
    • font is a path to some font, for instance AriBlk.TTF.
    • wordlist is a path to some word list, for instance /usr/share/dict/words. (Note: on Debian/Ubuntu, the 'wbritish' and 'wamerican' packages provide such lists. On Fedora, use the 'words' package).
    • key is the the exact passphrase you set $wgCaptchaSecret to. Use quotes if necessary.
    • output is the path to where the images should be stored (defined in $wgCaptchaDirectory).
    • count is how many images to generate.
    python /path/to/captcha.py --font=<font> --wordlist=<wordlist> --key=<key> --output=<output> --count=<count>
    • An example, assuming you're in the extensions/ConfirmEdit directory (font location from Ubuntu 6.06, probably different on other operating systems):
    python captcha.py --font=/usr/share/fonts/truetype/freefont/FreeSans.ttf --wordlist=/usr/share/dict/words --key=FOO --output=../../../captcha --count=100
    • If you are not satisfied with the results of the words you've generated you can simply remove the images and create a new set. Comic_Sans_MS_Bold.ttf seems to generate relatively legible words, and you could also edit the last line of captcha.py to increase the font size from the default of 40.
  4. Put the images you get into captcha directory in your installation
  5. Edit your wiki's LocalSettings.php: specify full path to your captcha directory in $wgCaptchaDirectory and secret key you've been using while generating captures in $wgCaptchaSecret
$wgCaptchaDirectory = "/.php-data/my-wiki.org/wiki/captcha";
$wgCaptchaDirectoryLevels = 0; // Set this to a value greater than zero to break the images into subdirectories
$wgCaptchaSecret = "FOO"; // same value you used in --key option in captcha.py

See also wikitech:Generating CAPTCHAs for how Wikimedia Foundation does it.

How to avoid common problems running Python[edit]
  1. Install the most recent version of Python Imaging Library (PIL).
  2. Make the installation of Python on a short folder name. Like C:\Python\
  3. Create a folder like C:\Ex and place files CAPTCHA.py / FONT.ttf / LIST.txt into the folder.
  4. To execute easily, run the following example as a batch file:
C:\python\python.exe C:\Ex\CAPTCHA.py --font C:\Ex\FONT.ttf --wordlist C:\Ex\LIST.txt --key=YOURPASSWORD --output C:\Ex\ --count=20

Using Pillow instead of PIL[edit]

You can use the Pillow Library (can be installed with pip install pillow in most environments) instead of the (old) Python Imaging Library (PIL) by simply changing the following lines in the file captcha.py (included in the extension folder of ConfirmEdit):

Change this lines in captcha.py: (cp. Porting existing PIL-based code to Pillow)

try:
        import Image
	import ImageFont
	import ImageDraw
	import ImageEnhance
	import ImageOps

To this:

try:
        from PIL import Image
	from PIL import ImageFont
	from PIL import ImageDraw
	from PIL import ImageEnhance
	from PIL import ImageOps

MathCaptcha[edit]

This requires the Math extension to be installed.
Until MediaWiki 1.18 this was part of MediaWiki, later versions need to install it manually. See also Extension:Math

This module generates an image using TeX to ask a basic math question.

Set the following to enable this CAPTCHA:

// Use this line ONLY if your MediaWiki version is 1.25 or newer:
wfLoadExtension( 'ConfirmEdit/MathCaptcha' );
// Use this line ONLY if your MediaWiki version is older than 1.25:
require_once "$IP/extensions/ConfirmEdit/MathCaptcha.php";
$wgCaptchaClass = 'MathCaptcha';

See the readme file in the math folder to install this captcha.

其他扩展[edit]

VisualMathCaptcha[edit]

你也可以使用扩展VisualMathCaptcha,来配合ConfirmEdit. 详情请参见扩展的参考文档,了解相关安装和配置信息。

Configuration[edit]

ConfirmEdit introduces a 'skipcaptcha' permission type to wgGroupPermissions. This lets you set certain groups to never see CAPTCHAs. All of the following can be added to localsettings.php.

Defaults from ConfirmEdit.php:

$wgGroupPermissions['*'            ]['skipcaptcha'] = false;
$wgGroupPermissions['user'         ]['skipcaptcha'] = false;
$wgGroupPermissions['autoconfirmed']['skipcaptcha'] = false;
$wgGroupPermissions['bot'          ]['skipcaptcha'] = true; // registered bots
$wgGroupPermissions['sysop'        ]['skipcaptcha'] = true;

To skip captchas for users that confirmed their email, you need to both set:

$wgGroupPermissions['emailconfirmed']['skipcaptcha'] = true;
$ceAllowConfirmedEmail = true;

There are five "triggers" on which CAPTCHAs can be displayed:

  • 'edit' - triggered on every attempted page save
  • 'create' - triggered on page creation
  • 'addurl' - triggered on a page save that would add one or more URLs to the page
  • 'createaccount' - triggered on creation of a new account
  • 'badlogin' - triggered on the next login attempt after a failed one. Requires $wgMainCacheType to be set to something other than CACHE_NONE in your LocalSettings.php, if in doubt the following will always work
$wgMainCacheType = CACHE_ANYTHING;

The default values for these are:

$wgCaptchaTriggers['edit']          = false; 
$wgCaptchaTriggers['create']        = false; 
$wgCaptchaTriggers['addurl']        = true; 
$wgCaptchaTriggers['createaccount'] = true;
$wgCaptchaTriggers['badlogin']      = true;

The triggers edit, create and addurl can be configured per namespace using the $wgCaptchaTriggersOnNamespace setting. If there is no $wgCaptchaTriggersOnNamespace for the current namespace, the normal $wgCaptchaTriggers apply. So suppose that in addition to the above $wgCaptchaTriggers defaults we configure the following:

$wgCaptchaTriggersOnNamespace[NS_TALK]['addurl'] = false;
$wgCaptchaTriggersOnNamespace[NS_PROJECT]['edit'] = true;

Then the CAPTCHA will not trigger when adding URLs to a talk page, but on the other hand user will need to solve a CAPTCHA any time they try to edit a page in the project namespace, even if they aren't adding a link.

URL and IP whitelists[edit]

It is possible to define a whitelist of known "good" sites for which the CAPTCHA should not kick in, when the 'addurl' action is triggered.

Sysop users can do this by editing the system message page called [[MediaWiki:Captcha-addurl-whitelist]]. The expected format is a set of regex's one per line. Comments can be added with # prefix. You can see an example of this usage on OpenStreetMap.

This set of whitelist regexes can also be defined using the $wgCaptchaWhitelist config variable in LocalSettings.php, to keep the value(s) a secret.

Some other variables you can add to LocalSettings.php:

  • $wgCaptchaWhitelistIP - List of IP ranges to allow to skip the CAPTCHA
  • $ceAllowConfirmedEmail - Allow users who have confirmed their e-mail addresses to post URL links

These are described more thoroughly in the code comments

Regular expressions[edit]

The global variable wgCaptchaRegexes accepts an array of regexes to be tested against the page text and will trigger the CAPTCHA in case of a match.

Wikimedia projects[edit]

For example, Wikimedia Foundation wikis use FancyCaptcha with a custom set of images and the default configuration, modified by what follows.

$wgGroupPermissions['autoconfirmed']['skipcaptcha'] = true;

This means only unregistered and newly registered users have to pass the CAPTCHA.

EmergencyCaptcha mode[edit]

Additionally the shortcut named $wmgEmergencyCaptcha is designed for use in a limited number of emergency situations, for instance in case of massive vandalism or spam attacks: it changes the default trigger values (see above) into the following:

$wgCaptchaTriggers['edit']          = true; 
$wgCaptchaTriggers['create']        = true;

So all anonymous and new users have to solve a CAPTCHA also before being able to save an edit or create a new page, in addition to the normal situation.

Rate-Limiting[edit]

With Gerrit change 182551, ConfirmEdit supports rate limiting for false CAPTCHA. For more information about $wgRateLimits and how to set it up, read the manual, the action key is badcaptcha.

Test plan[edit]

See ConfirmEdit Test Plan.

Patch for even more spam protection[edit]

This is a patch to allow experienced users to bring in external links without solving a captcha, regardless she has skipcaptcha permissions. A user is considered to be trusted if she has a large number of edits.

This patch also prohibits new users from adding _any_ external links. Such behaviour should help a lot to tackle spam, because the whole reason of spam is to add such links (they call it "link building") and spam is almost always added by newly created users.

Configuration:

Apply the patch to extensions/ after unpacking ConfirmEdit 1.2. If you want to deviate from the defaults, add this to LocalSettings.php:

# Don't ask for a captcha for users with more than this number of edits.
$wgCaptchaTrustedThreshold = 150; // default 100
# Always reject edits adding new external links with less than this number of edits.
$wgCaptchaNewbieThreshold = 10;   // default 5

The patch isn't as well honed as it could be, for example user messages aren't localized. Also, the refusal for newbies to add external links applies no matter which permissions a user has. Other than that, it appears to work just fine. For a wiki using this patch, see http://reprap.org.

Markus "Traumflug" Hitter, September 2013, <mah@jump-ing.de>

--- ConfirmEdit/Captcha.php.2013-09-06	2013-05-28 12:10:57.000000000 -0700
+++ ConfirmEdit/Captcha.php	2013-09-08 10:30:12.000000000 -0700
@@ -1,6 +1,9 @@
 <?php
 
 class SimpleCaptcha {
+
+	private $newLinks = null;
+
 	function getCaptcha() {
 		$a = mt_rand( 0, 100 );
 		$b = mt_rand( 0, 10 );
@@ -62,6 +65,21 @@
 	}
 
 	/**
+	 * Insert the captcha prompt into an edit form.
+	 * @param OutputPage $out
+	 */
+	function newbieCallback( &$out ) {
+		global $wgCaptchaNewbieThreshold, $wgUser;
+		$count =  $wgUser->getEditCount();
+		$out->addWikiText( "As a spam protection measure, users with fewer than
+		                    $wgCaptchaNewbieThreshold edits are '''not''' allowed
+				    to add ''external'' links. Please use internal links
+				    instead (which is always to be perferred) or raise
+				    your edit count by doing a few edits without links.
+				    \n\nYour edit count is $count.\n\n" );
+	}
+
+	/**
 	 * Show a message asking the user to enter a captcha on edit
 	 * The result will be treated as wiki text
 	 *
@@ -237,6 +255,34 @@
 	/**
 	 * @param $editPage EditPage
 	 * @param $newtext string
+	 * @param $merged bool
+	 * @return an array with the number of newly added links
+	 */
+	function findNewLinks( &$editPage, $newtext, $merged ) {
+		if ( $this->newLinks != null )
+			return $this->newLinks;
+
+		if ( $merged ) {
+			// Get links from the database
+			$oldLinks = $this->getLinksFromTracker( $editPage->mArticle->getTitle() );
+			// Share a parse operation with Article::doEdit()
+			$editInfo = $editPage->mArticle->prepareTextForEdit( $newtext );
+			$newLinks = array_keys( $editInfo->output->getExternalLinks() );
+		} else {
+			// Get link changes in the slowest way known to man
+			$oldtext = $this->loadText( $editPage, $section );
+			$oldLinks = $this->findLinks( $editPage, $oldtext );
+			$newLinks = $this->findLinks( $editPage, $newtext );
+		}
+
+		$unknownLinks = array_filter( $newLinks, array( &$this, 'filterLink' ) );
+		$this->newLinks = array_diff( $unknownLinks, $oldLinks );
+		return $this->newLinks;
+	}
+
+	/**
+	 * @param $editPage EditPage
+	 * @param $newtext string
 	 * @param $section string
 	 * @param $merged bool
 	 * @return bool true if the captcha should run
@@ -246,6 +292,18 @@
 		$title = $editPage->mArticle->getTitle();
 
 		global $wgUser;
+
+		// Users with more than $wgCaptchaTrustedThreshold edits
+		// are considered to be trusted, so they don't need a captcha.
+		global $wgCaptchaTrustedThreshold;
+		if ( ! isset( $wgCaptchaTrustedThreshold ) )
+			$wgCaptchaTrustedThreshold = 100;
+		if ( $wgUser->getEditCount() > $wgCaptchaTrustedThreshold ) {
+			wfDebug( "ConfirmEdit: trusted user, skipping captcha\n" );
+			return false;
+		}
+
 		if ( $wgUser->isAllowed( 'skipcaptcha' ) ) {
 			wfDebug( "ConfirmEdit: user group allows skipping captcha\n" );
 			return false;
@@ -284,22 +341,7 @@
 		}
 
 		if ( $this->captchaTriggers( $editPage, 'addurl' ) ) {
-			// Only check edits that add URLs
-			if ( $merged ) {
-				// Get links from the database
-				$oldLinks = $this->getLinksFromTracker( $title );
-				// Share a parse operation with Article::doEdit()
-				$editInfo = $editPage->mArticle->prepareTextForEdit( $newtext );
-				$newLinks = array_keys( $editInfo->output->getExternalLinks() );
-			} else {
-				// Get link changes in the slowest way known to man
-				$oldtext = $this->loadText( $editPage, $section );
-				$oldLinks = $this->findLinks( $editPage, $oldtext );
-				$newLinks = $this->findLinks( $editPage, $newtext );
-			}
-
-			$unknownLinks = array_filter( $newLinks, array( &$this, 'filterLink' ) );
-			$addedLinks = array_diff( $unknownLinks, $oldLinks );
+			$addedLinks = $this->findNewLinks( $editPage, $newtext, $merged );
 			$numLinks = count( $addedLinks );
 
 			if ( $numLinks > 0 ) {
@@ -469,6 +511,21 @@
 			# The CAPTCHA was already checked and approved
 			return true;
 		}
+
+		// Always reject edits of newbies adding external links.
+		global $wgCaptchaNewbieThreshold, $wgUser;
+		if ( ! isset( $wgCaptchaNewbieThreshold ) )
+			$wgCaptchaNewbieThreshold = 5;
+		if ( $wgUser->getEditCount() < $wgCaptchaNewbieThreshold ) {
+			$addedLinks = $this->findNewLinks( $editPage, $newtext, $merged );
+			if ( count( $addedLinks ) > 0 ) {
+				wfDebug( "ConfirmEdit: rejecting newbie edit due to new links\n" );
+				$editPage->showEditForm( array( &$this, 'newbieCallback' ) );
+				return false;
+			}
+		}
+
 		if ( !$this->doConfirmEdit( $editPage, $newtext, $section, $merged ) ) {
 			$editPage->showEditForm( array( &$this, 'editCallback' ) );
 			return false;

Experience with this patch[edit]

After two months with this patch, we still wait for the first spam edit. Other than spambots still creating accounts, misuse of our wiki has completely disappeared.

Legitimate users apparently understand the error message. No complaints, but occasionally useless edits to raise the edit count appear. Typically, these users revert their useless edits without maintainer intervention. Exactly like planned.

-- Traumflug@reprap.org

作者[edit]

基础框架主要由Brion Vibber设计,此外他还编写了SimpleCaptcha和FancyCaptcha模块。MathCaptcha模块由Rob Church编写。QuestyCaptcha模块由 Benjamin Lees编写。reCAPTCHA模块由Mike Crawford和Ben Maurer编写。另外的维护工作由Yaron Koren完成。

注意[edit]

  1. Homepage of the Asirra project
  2. MediaWiki:Questycaptchahelp-text, MediaWiki:Questycaptcha-edit, MediaWiki:Questycaptcha-addurl, MediaWiki:Questycaptcha-create and MediaWiki:Questycaptcha-createaccount.

参见[edit]