[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @author Bachsau 4 * @author Niklas Laxström 5 */ 6 7 class Asirra extends SimpleCaptcha { 8 public $asirra_clientscript = '//challenge.asirra.com/js/AsirraClientSide.js'; 9 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"; 15 } 16 17 function getForm() { 18 global $wgOut; 19 20 $wgOut->addModules( 'ext.confirmEdit.asirra' ); 21 $js = Html::linkedScript( $this->asirra_clientscript ); 22 23 $message = Xml::encodeJsVar( wfMessage( 'asirra-createaccount-fail' )->plain() ); 24 $js .= Html::inlineScript( <<<JAVASCRIPT 25 var asirra_js_failed = '$message'; 26 JAVASCRIPT 27 ); 28 $js .= '<noscript>' . wfMessage( 'asirra-nojs' )->parse() . '</noscript>'; 29 return $js; 30 } 31 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; 38 } 39 40 function passCaptcha() { 41 global $wgRequest; 42 43 $ticket = $wgRequest->getVal( 'Asirra_Ticket' ); 44 $api = 'http://challenge.asirra.com/cgi/Asirra?'; 45 $params = array( 46 'action' => 'ValidateTicket', 47 'ticket' => $ticket, 48 ); 49 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'; 54 } 55 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |