Index: trunk/extensions/ConfirmEdit/QuestyCaptcha.i18n.php |
— | — | @@ -0,0 +1,28 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation file for the QuestyCaptcha plug-in |
| 5 | + * |
| 6 | + * @addtogroup Extensions |
| 7 | +*/ |
| 8 | + |
| 9 | +$messages = array(); |
| 10 | + |
| 11 | +/** English */ |
| 12 | +$messages['en'] = array( |
| 13 | + 'questycaptcha-desc' => 'Questy captcha generator for Confirm Edit', |
| 14 | + 'questycaptcha-addurl' => 'Your edit includes new external links. |
| 15 | +To help protect against automated spam, please answer the question that appears below ([[Special:Captcha/help|more info]]):', |
| 16 | + 'questycaptcha-badlogin' => 'To help protect against automated password cracking, please answer the question that appears below ([[Special:Captcha/help|more info]]):', |
| 17 | + 'questycaptcha-createaccount' => 'To help protect against automated account creation, please answer the question that appears below ([[Special:Captcha/help|more info]]):', |
| 18 | + 'questycaptcha-create' => 'To create the page, please answer the question that appears below ([[Special:Captcha/help|more info]]):', |
| 19 | + 'questycaptcha-edit' => 'To edit this page, please answer the question that appears below ([[Special:Captcha/help|more info]]):', |
| 20 | + 'questycaptchahelp-text' => "Web sites that accept postings from the public, like this wiki, are often abused by spammers who use automated tools to post their links to many sites. |
| 21 | +While these spam links can be removed, they are a significant nuisance. |
| 22 | + |
| 23 | +Sometimes, especially when adding new web links to a page, the wiki may ask you to answer a question. |
| 24 | +Since this is a task that's hard to automate, it will allow most real humans to make their posts while stopping most spammers and other robotic attackers. |
| 25 | + |
| 26 | +Please contact the [[{{MediaWiki:Grouppage-sysop}}|site administrators]] for assistance if this is unexpectedly preventing you from making legitimate posts. |
| 27 | + |
| 28 | +Hit the 'back' button in your browser to return to the page editor.", |
| 29 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/ConfirmEdit/QuestyCaptcha.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 30 | + native |
Added: svn:executable |
2 | 31 | + * |
Index: trunk/extensions/ConfirmEdit/QuestyCaptcha.php |
— | — | @@ -0,0 +1,39 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * A question-based captcha plugin. |
| 5 | + * |
| 6 | + * Copyright (C) 2009 Benjamin Lees <emufarmers@gmail.com> |
| 7 | + * http://www.mediawiki.org/ |
| 8 | + * |
| 9 | + * This program is free software; you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU General Public License as published by |
| 11 | + * the Free Software Foundation; either version 2 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * This program is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU General Public License along |
| 20 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 22 | + * http://www.gnu.org/copyleft/gpl.html |
| 23 | + * |
| 24 | + * @addtogroup Extensions |
| 25 | + */ |
| 26 | + |
| 27 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 28 | + exit; |
| 29 | +} |
| 30 | + |
| 31 | +global $wgCaptchaQuestions; |
| 32 | +$wgCaptchaQuestions = array(); |
| 33 | +//$wgCaptchaQuestions[] = array( 'question' => "A question?", 'answer' => "An answer!" ); |
| 34 | +//$wgCaptchaQuestions[] = array( 'question' => 'How much wood would a woodchuck chuck if a woodchuck could chuck wood?', 'answer' => 'as much wood as...' ); |
| 35 | +//$wgCaptchaQuestions[] = array( 'question' => "What is this wiki's name?", 'answer' => "$wgSitename" ); |
| 36 | +//add your questions in LocalSettings.php using this format |
| 37 | + |
| 38 | +$wgExtensionMessagesFiles['QuestyCaptcha'] = dirname(__FILE__).'/QuestyCaptcha.i18n.php'; |
| 39 | +$wgAutoloadClasses['QuestyCaptcha'] = dirname( __FILE__ ) . '/QuestyCaptcha.class.php'; |
| 40 | + |
Property changes on: trunk/extensions/ConfirmEdit/QuestyCaptcha.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 41 | + native |
Added: svn:executable |
2 | 42 | + * |
Index: trunk/extensions/ConfirmEdit/QuestyCaptcha.class.php |
— | — | @@ -0,0 +1,67 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * QuestyCaptcha class |
| 6 | + * |
| 7 | + * @author Benjamin Lees <emufarmers@gmail.com> |
| 8 | + * @addtogroup extensions |
| 9 | + */ |
| 10 | + |
| 11 | +class QuestyCaptcha extends SimpleCaptcha { |
| 12 | + |
| 13 | + /** Validate a captcha response */ |
| 14 | + function keyMatch( $answer, $info ) { |
| 15 | + return strtolower( $answer ) == strtolower( $info['answer'] ); |
| 16 | + } |
| 17 | + |
| 18 | + function addCaptchaAPI(&$resultArr) { |
| 19 | + $captcha = $this->getCaptcha(); |
| 20 | + $index = $this->storeCaptcha( $captcha ); |
| 21 | + $resultArr['captcha']['type'] = 'question'; |
| 22 | + $resultArr['captcha']['mime'] = 'text/plain'; |
| 23 | + $resultArr['captcha']['id'] = $index; |
| 24 | + $resultArr['captcha']['question'] = $captcha['question']; |
| 25 | + } |
| 26 | + |
| 27 | + function getCaptcha() { |
| 28 | + global $wgCaptchaQuestions; |
| 29 | + return $wgCaptchaQuestions[mt_rand( 0, count( $wgCaptchaQuestions )-1 )]; //pick a question, any question |
| 30 | + } |
| 31 | + |
| 32 | + function getForm() { |
| 33 | + $captcha = $this->getCaptcha(); |
| 34 | + if(!$captcha) { |
| 35 | + die( "No questions found; set some in LocalSettings.php using the format from QuestyCaptcha.php." ); |
| 36 | + } |
| 37 | + $index = $this->storeCaptcha( $captcha ); |
| 38 | + return "<p><label for=\"wpCaptchaWord\">{$captcha['question']}</label> " . |
| 39 | + Xml::element( 'input', array( |
| 40 | + 'name' => 'wpCaptchaWord', |
| 41 | + 'id' => 'wpCaptchaWord', |
| 42 | + 'tabindex' => 1 ) ) . // tab in before the edit textarea |
| 43 | + "</p>\n" . |
| 44 | + Xml::element( 'input', array( |
| 45 | + 'type' => 'hidden', |
| 46 | + 'name' => 'wpCaptchaId', |
| 47 | + 'id' => 'wpCaptchaId', |
| 48 | + 'value' => $index ) ); |
| 49 | + } |
| 50 | + |
| 51 | + function getMessage( $action ) { |
| 52 | + $name = 'questycaptcha-' . $action; |
| 53 | + $text = wfMsg( $name ); |
| 54 | + # Obtain a more tailored message, if possible, otherwise, fall back to |
| 55 | + # the default for edits |
| 56 | + return wfEmptyMsg( $name, $text ) ? wfMsg( 'questycaptcha-edit' ) : $text; |
| 57 | + } |
| 58 | + |
| 59 | + function showHelp() { |
| 60 | + global $wgOut, $ceAllowConfirmedEmail; |
| 61 | + $wgOut->setPageTitle( wfMsg( 'captchahelp-title' ) ); |
| 62 | + $wgOut->addWikiText( wfMsg( 'questycaptchahelp-text' ) ); |
| 63 | + if ( $this->storage->cookiesNeeded() ) { |
| 64 | + $wgOut->addWikiText( wfMsg( 'captchahelp-cookies-needed' ) ); |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/ConfirmEdit/QuestyCaptcha.class.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 69 | + native |
Added: svn:executable |
2 | 70 | + * |