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, $wgAsirraScriptPath;
14 $this->asirra_localpath = "$wgExtensionAssetsPath/ConfirmEdit";
18 global $wgAsirraEnlargedPosition, $wgAsirraCellsPerRow, $wgOut, $wgLang;
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 passCaptcha() {
35 $ticket = $wgRequest->getVal( 'Asirra_Ticket' );
36 $api = 'http://challenge.asirra.com/cgi/Asirra?';
38 'action' => 'ValidateTicket',
42 $response = Http::get( $api . wfArrayToCgi( $params ) );
43 $xml = simplexml_load_string( $response );
44 $result = $xml->xpath( '/AsirraValidation/Result' );
45 return strval( $result[0] ) === 'Pass';