Index: trunk/extensions/ConfirmEdit/Asirra.i18n.php |
— | — | @@ -0,0 +1,36 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation file for the Asirra module of the ConfirmEdit |
| 5 | + * extension. |
| 6 | + * |
| 7 | + * @file |
| 8 | + * @ingroup Extensions |
| 9 | + */ |
| 10 | + |
| 11 | +$messages = array(); |
| 12 | + |
| 13 | +/* English */ |
| 14 | +$messages['en'] = array( |
| 15 | + 'asirra-desc' => 'Asirra module for ConfirmEdit', |
| 16 | + 'asirra-edit' => 'To help protect against automated edit spam, please select just the cat photos in the box below:', |
| 17 | + 'asirra-addurl' => 'Your edit includes new external links. To help protect against automated spam, please select just the cat photos in the box below:', |
| 18 | + 'asirra-badpass' => 'To help protect against automated password cracking, please select just the cat photos in the box below:', |
| 19 | + 'asirra-createaccount' => 'To help protect against automated account creation, please select just the cat photos in the box below:', |
| 20 | + 'asirra-createaccount-fail' => "Please correctly identify the cats.", |
| 21 | + 'asirra-create' => 'To help protect against automated page creation, please select just the cat photos in the box below:', |
| 22 | + 'asirra-nojs' => '\'\'\'Please enable JavaScript and resubmit the page.\'\'\'', |
| 23 | + 'asirra-failed' => 'Please identify all cat images', |
| 24 | +); |
| 25 | + |
| 26 | + |
| 27 | +/** German (Deutsch) */ |
| 28 | +$messages['de'] = array( |
| 29 | + 'asirra-desc' => 'Asirra-Modul für ConfirmEdit', |
| 30 | + 'asirra-edit' => 'Zum Schutz vor automatisiertem Spam, wähle bitte nur die Katzen im untenstehenden Feld aus:', |
| 31 | + 'asirra-addurl' => 'Deine Bearbeitung enthält neue externe Links. Zum Schutz vor automatisiertem Spam wähle bitte nur die Katzen im untenstehenden Feld aus:', |
| 32 | + 'asirra-badpass' => 'Zum Schutz gegen automatisiertes Knacken von Passwörtern, wähle bitte nur die Katzen im untenstehenden Feld aus:', |
| 33 | + 'asirra-createaccount' => 'Zum Schutz gegen automatisierte Erstellung von Benutzerkonten wähle bitte nur die Katzen im untenstehenden Feld aus:', |
| 34 | + 'asirra-createaccount-fail' => 'Bitte wähle nur Katzen aus.', |
| 35 | + 'asirra-create' => 'Zum Schutz gegen automatisierte Erstellung von Seiten, wähle bitte nur die Katzen im untenstehenden Feld aus:', |
| 36 | + 'asirra-nojs' => '\'\'\'Bitte aktiviere JavaScript und sende die Seite noch einmal ab.\'\'\'' |
| 37 | +); |
Property changes on: trunk/extensions/ConfirmEdit/Asirra.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 38 | + native |
Index: trunk/extensions/ConfirmEdit/ext.confirmedit.asirra.js |
— | — | @@ -0,0 +1,55 @@ |
| 2 | +/*======================================================================*\ |
| 3 | +|| #################################################################### || |
| 4 | +|| # Asirra module for ConfirmEdit by Bachsau # || |
| 5 | +|| # ---------------------------------------------------------------- # || |
| 6 | +|| # This code is released into public domain, in the hope that it # || |
| 7 | +|| # will be useful, but without any warranty. # || |
| 8 | +|| # ------------ YOU CAN DO WITH IT WHATEVER YOU LIKE! ------------- # || |
| 9 | +|| #################################################################### || |
| 10 | +\*======================================================================*/ |
| 11 | + |
| 12 | +jQuery( function( $ ) { |
| 13 | + var asirraform = $( "form#userlogin2" ) |
| 14 | + var submitButtonClicked = document.createElement("input"); |
| 15 | + var passThroughFormSubmit = false; |
| 16 | + |
| 17 | + function PrepareSubmit() { |
| 18 | + console.log( 'daa' ); |
| 19 | + submitButtonClicked.type = "hidden"; |
| 20 | + var inputFields = asirraform.find( "input" ); |
| 21 | + for (var i=0; i<inputFields.length; i++) { |
| 22 | + if (inputFields[i].type === "submit") { |
| 23 | + inputFields[i].onclick = function(event) { |
| 24 | + console.log( this ); |
| 25 | + submitButtonClicked.name = this.name; |
| 26 | + submitButtonClicked.value = this.value; |
| 27 | + } |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + asirraform.submit( function() { |
| 32 | + return MySubmitForm(); |
| 33 | + } ); |
| 34 | + } |
| 35 | + |
| 36 | + function MySubmitForm() { |
| 37 | + if (passThroughFormSubmit) { |
| 38 | + return true; |
| 39 | + } |
| 40 | + Asirra_CheckIfHuman(HumanCheckComplete); |
| 41 | + return false; |
| 42 | + } |
| 43 | + |
| 44 | + function HumanCheckComplete(isHuman) { |
| 45 | + if (!isHuman) { |
| 46 | + alert( mw.msg( 'asirra-failed' ) ); |
| 47 | + } else { |
| 48 | + asirraform.append(submitButtonClicked); |
| 49 | + passThroughFormSubmit = true; |
| 50 | + asirraform.submit(); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + PrepareSubmit(); |
| 55 | + |
| 56 | +} ); |
Property changes on: trunk/extensions/ConfirmEdit/ext.confirmedit.asirra.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 57 | + native |
Index: trunk/extensions/ConfirmEdit/Asirra.php |
— | — | @@ -0,0 +1,43 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Asirra CAPTCHA module for the ConfirmEdit MediaWiki extension. |
| 5 | + * @author Bachsau |
| 6 | + * @author Niklas Laxström |
| 7 | + * |
| 8 | + * Makes use of the Asirra (Animal Species Image Recognition for |
| 9 | + * Restricting Access) CAPTCHA service, developed by John Douceur, Jeremy |
| 10 | + * Elson and Jon Howell at Microsoft Research. |
| 11 | + * |
| 12 | + * Asirra uses a large set of images from http://petfinder.com. |
| 13 | + * |
| 14 | + * For more information about Asirra, see: |
| 15 | + * http://research.microsoft.com/en-us/um/redmond/projects/asirra/ |
| 16 | + * |
| 17 | + * This MediaWiki code is released into the public domain, without any |
| 18 | + * warranty. YOU CAN DO WITH IT WHATEVER YOU LIKE! |
| 19 | + * |
| 20 | + * @file |
| 21 | + * @ingroup Extensions |
| 22 | + */ |
| 23 | + |
| 24 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 25 | + exit; |
| 26 | +} |
| 27 | + |
| 28 | +$dir = dirname( __FILE__ ) . '/'; |
| 29 | +require_once( "$dir/ConfirmEdit.php" ); |
| 30 | +$dir = dirname( __FILE__ ) . '/'; |
| 31 | + |
| 32 | +$wgCaptchaClass = 'Asirra'; |
| 33 | +$wgExtensionMessagesFiles['Asirra'] = "$dir/Asirra.i18n.php"; |
| 34 | +$wgAutoloadClasses['Asirra'] = "$dir/Asirra.class.php"; |
| 35 | + |
| 36 | +$wgResourceModules['ext.confirmedit.asirra'] = array( |
| 37 | + 'localBasePath' => $dir, |
| 38 | + 'remoteExtPath' => 'ConfirmEdit', |
| 39 | + 'scripts' => 'ext.confirmedit.asirra.js', |
| 40 | + 'messages' => array( |
| 41 | + 'asirra-failed', |
| 42 | + ), |
| 43 | +); |
| 44 | + |
Property changes on: trunk/extensions/ConfirmEdit/Asirra.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 45 | + native |
Index: trunk/extensions/ConfirmEdit/Asirra.class.php |
— | — | @@ -0,0 +1,47 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * @author Bachsau |
| 5 | + * @author Niklas Laxström |
| 6 | + */ |
| 7 | + |
| 8 | +class Asirra extends SimpleCaptcha { |
| 9 | + public $asirra_clientscript = 'http://challenge.asirra.com/js/AsirraClientSide.js'; |
| 10 | + |
| 11 | + // As we don't have to store anything but some other things to do, |
| 12 | + // we're going to replace that constructor completely. |
| 13 | + function __construct() { |
| 14 | + global $wgExtensionAssetsPath, $wgAsirraScriptPath; |
| 15 | + $this->asirra_localpath = "$wgExtensionAssetsPath/ConfirmEdit"; |
| 16 | + } |
| 17 | + |
| 18 | + function getForm() { |
| 19 | + global $wgAsirraEnlargedPosition, $wgAsirraCellsPerRow, $wgOut, $wgLang; |
| 20 | + |
| 21 | + $wgOut->addModules( 'ext.confirmedit.asirra' ); |
| 22 | + $js = Html::linkedScript( $this->asirra_clientscript ); |
| 23 | + |
| 24 | + $message = Xml::encodeJsVar( wfMessage( 'asirra-createaccount-fail' )->plain() ); |
| 25 | + $js .= Html::inlineScript( <<<JAVASCRIPT |
| 26 | +var asirra_js_failed = '$message'; |
| 27 | +JAVASCRIPT |
| 28 | + ); |
| 29 | + $js .= '<noscript>' . wfMessage( 'asirra-nojs' )->parse() . '</noscript>'; |
| 30 | + return $js; |
| 31 | + } |
| 32 | + |
| 33 | + function passCaptcha() { |
| 34 | + global $wgRequest; |
| 35 | + |
| 36 | + $ticket = $wgRequest->getVal( 'Asirra_Ticket' ); |
| 37 | + $api = 'http://challenge.asirra.com/cgi/Asirra?'; |
| 38 | + $params = array( |
| 39 | + 'action' => 'ValidateTicket', |
| 40 | + 'ticket' => $ticket, |
| 41 | + ); |
| 42 | + |
| 43 | + $response = Http::get( $api . wfArrayToCgi( $params ) ); |
| 44 | + $xml = simplexml_load_string( $response ); |
| 45 | + $result = $xml->xpath( '/AsirraValidation/Result' ); |
| 46 | + return strval( $result[0] ) === 'Pass'; |
| 47 | + } |
| 48 | +} |
Property changes on: trunk/extensions/ConfirmEdit/Asirra.class.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 49 | + native |