From: Charles Melbye Date: Sun, 19 Jul 2009 04:15:55 +0000 (+0000) Subject: Moving QuestyCaptcha to ConfirmEdit X-Git-Url: https://git.toastfreeware.priv.at/toast/cookiecaptcha.git/commitdiff_plain/283ec4908cd436c4fcd023dee108d064afad1170 Moving QuestyCaptcha to ConfirmEdit --- diff --git a/QuestyCaptcha.class.php b/QuestyCaptcha.class.php new file mode 100755 index 0000000..385edab --- /dev/null +++ b/QuestyCaptcha.class.php @@ -0,0 +1,67 @@ + + * @addtogroup extensions + */ + +class QuestyCaptcha extends SimpleCaptcha { + + /** Validate a captcha response */ + function keyMatch( $answer, $info ) { + return strtolower( $answer ) == strtolower( $info['answer'] ); + } + + function addCaptchaAPI(&$resultArr) { + $captcha = $this->getCaptcha(); + $index = $this->storeCaptcha( $captcha ); + $resultArr['captcha']['type'] = 'question'; + $resultArr['captcha']['mime'] = 'text/plain'; + $resultArr['captcha']['id'] = $index; + $resultArr['captcha']['question'] = $captcha['question']; + } + + function getCaptcha() { + global $wgCaptchaQuestions; + return $wgCaptchaQuestions[mt_rand( 0, count( $wgCaptchaQuestions )-1 )]; //pick a question, any question + } + + function getForm() { + $captcha = $this->getCaptcha(); + if(!$captcha) { + die( "No questions found; set some in LocalSettings.php using the format from QuestyCaptcha.php." ); + } + $index = $this->storeCaptcha( $captcha ); + return "

" . + Xml::element( 'input', array( + 'name' => 'wpCaptchaWord', + 'id' => 'wpCaptchaWord', + 'tabindex' => 1 ) ) . // tab in before the edit textarea + "

\n" . + Xml::element( 'input', array( + 'type' => 'hidden', + 'name' => 'wpCaptchaId', + 'id' => 'wpCaptchaId', + 'value' => $index ) ); + } + + function getMessage( $action ) { + $name = 'questycaptcha-' . $action; + $text = wfMsg( $name ); + # Obtain a more tailored message, if possible, otherwise, fall back to + # the default for edits + return wfEmptyMsg( $name, $text ) ? wfMsg( 'questycaptcha-edit' ) : $text; + } + + function showHelp() { + global $wgOut, $ceAllowConfirmedEmail; + $wgOut->setPageTitle( wfMsg( 'captchahelp-title' ) ); + $wgOut->addWikiText( wfMsg( 'questycaptchahelp-text' ) ); + if ( $this->storage->cookiesNeeded() ) { + $wgOut->addWikiText( wfMsg( 'captchahelp-cookies-needed' ) ); + } + } + +} \ No newline at end of file diff --git a/QuestyCaptcha.i18n.php b/QuestyCaptcha.i18n.php new file mode 100755 index 0000000..5b22c52 --- /dev/null +++ b/QuestyCaptcha.i18n.php @@ -0,0 +1,28 @@ + 'Questy captcha generator for Confirm Edit', + 'questycaptcha-addurl' => 'Your edit includes new external links. +To help protect against automated spam, please answer the question that appears below ([[Special:Captcha/help|more info]]):', + 'questycaptcha-badlogin' => 'To help protect against automated password cracking, please answer the question that appears below ([[Special:Captcha/help|more info]]):', + 'questycaptcha-createaccount' => 'To help protect against automated account creation, please answer the question that appears below ([[Special:Captcha/help|more info]]):', + 'questycaptcha-create' => 'To create the page, please answer the question that appears below ([[Special:Captcha/help|more info]]):', + 'questycaptcha-edit' => 'To edit this page, please answer the question that appears below ([[Special:Captcha/help|more info]]):', + '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. +While these spam links can be removed, they are a significant nuisance. + +Sometimes, especially when adding new web links to a page, the wiki may ask you to answer a question. +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. + +Please contact the [[{{MediaWiki:Grouppage-sysop}}|site administrators]] for assistance if this is unexpectedly preventing you from making legitimate posts. + +Hit the 'back' button in your browser to return to the page editor.", +); \ No newline at end of file diff --git a/QuestyCaptcha.php b/QuestyCaptcha.php new file mode 100755 index 0000000..a984698 --- /dev/null +++ b/QuestyCaptcha.php @@ -0,0 +1,39 @@ + + * http://www.mediawiki.org/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Extensions + */ + +if ( !defined( 'MEDIAWIKI' ) ) { + exit; +} + +global $wgCaptchaQuestions; +$wgCaptchaQuestions = array(); +//$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" ); +//add your questions in LocalSettings.php using this format + +$wgExtensionMessagesFiles['QuestyCaptcha'] = dirname(__FILE__).'/QuestyCaptcha.i18n.php'; +$wgAutoloadClasses['QuestyCaptcha'] = dirname( __FILE__ ) . '/QuestyCaptcha.class.php'; +