r81795 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81794‎ | r81795 | r81796 >
Date:23:39, 8 February 2011
Author:platonides
Status:ok
Tags:
Comment:
Allow several answers in QuestyCaptcha, per request at http://permalink.gmane.org/gmane.org.wikimedia.mediawiki/36769
Modified paths:
  • /trunk/extensions/ConfirmEdit/QuestyCaptcha.class.php (modified) (history)
  • /trunk/extensions/ConfirmEdit/QuestyCaptcha.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmEdit/QuestyCaptcha.php
@@ -30,10 +30,13 @@
3131
3232 global $wgCaptchaQuestions;
3333 $wgCaptchaQuestions = array();
 34+
 35+// Add your questions in LocalSettings.php using this format
3436 // $wgCaptchaQuestions[] = array( 'question' => "A question?", 'answer' => "An answer!" );
3537 // $wgCaptchaQuestions[] = array( 'question' => 'How much wood would a woodchuck chuck if a woodchuck could chuck wood?', 'answer' => 'as much wood as...' );
3638 // $wgCaptchaQuestions[] = array( 'question' => "What is this wiki's name?", 'answer' => "$wgSitename" );
37 -// add your questions in LocalSettings.php using this format
 39+// You can also provide several acceptable answers to a given question (the answers shall be in lowercase):
 40+// $wgCaptchaQuestions[] = array( 'question' => "2 + 2 ?", 'answer' => array( '4', 'four' ) );
3841
3942 $wgExtensionMessagesFiles['QuestyCaptcha'] = dirname( __FILE__ ) . '/QuestyCaptcha.i18n.php';
4043 $wgAutoloadClasses['QuestyCaptcha'] = dirname( __FILE__ ) . '/QuestyCaptcha.class.php';
Index: trunk/extensions/ConfirmEdit/QuestyCaptcha.class.php
@@ -12,7 +12,11 @@
1313
1414 /** Validate a captcha response */
1515 function keyMatch( $answer, $info ) {
16 - return strtolower( $answer ) == strtolower( $info['answer'] );
 16+ if ( is_array( $info['answer'] ) ) {
 17+ return in_array( strtolower( $answer ), $info['answer'] );
 18+ } else {
 19+ return strtolower( $answer ) == strtolower( $info['answer'] );
 20+ }
1721 }
1822
1923 function addCaptchaAPI( &$resultArr ) {

Status & tagging log