4 * @author Niklas Laxström
7 class Asirra extends SimpleCaptcha {
8 public $asirra_clientscript = 'http://challenge.asirra.com/js/AsirraClientSide.js';
10 // As we don't have to store anything but some other things to do,
11 // we're going to replace that constructor completely.
12 function __construct() {
13 global $wgExtensionAssetsPath;
14 $this->asirra_localpath = "$wgExtensionAssetsPath/ConfirmEdit";
20 $wgOut->addModules( 'ext.confirmedit.asirra' );
21 $js = Html::linkedScript( $this->asirra_clientscript );
23 $message = Xml::encodeJsVar( wfMessage( 'asirra-createaccount-fail' )->plain() );
24 $js .= Html::inlineScript( <<<JAVASCRIPT
25 var asirra_js_failed = '$message';
28 $js .= '<noscript>' . wfMessage( 'asirra-nojs' )->parse() . '</noscript>';
32 function getMessage( $action ) {
33 $name = 'asirra-' . $action;
34 $text = wfMessage( $name )->text();
35 # Obtain a more tailored message, if possible, otherwise, fall
36 # back to the default for edits
37 return wfMessage( $name, $text )->isDisabled() ? wfMessage( 'asirra-edit' )->text() : $text;
40 function passCaptcha() {
43 $ticket = $wgRequest->getVal( 'Asirra_Ticket' );
44 $api = 'http://challenge.asirra.com/cgi/Asirra?';
46 'action' => 'ValidateTicket',
50 $response = Http::get( $api . wfArrayToCgi( $params ) );
51 $xml = simplexml_load_string( $response );
52 $result = $xml->xpath( '/AsirraValidation/Result' );
53 return strval( $result[0] ) === 'Pass';