[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/extensions/ConfirmEdit/ -> Asirra.class.php (source)

   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  }
". ', [['includes','Html.php',597]], 7], 'isdisabled': ['isdisabled', 'Return whether the output will be completely disabled ', [['includes','OutputPage.php',1055],['includes/api','ApiFormatBase.php',118],['includes','Message.php',830]], 89], 'strval': ['strval', '', [], 149], 'simplexml_load_string': ['simplexml_load_string', '', [], 1]}; CLASS_DATA={ 'http': ['http', 'Various HTTP related functions ', [['includes','HttpFunctions.php',28]], 29], 'xml': ['xml', 'Module of static functions for generating XML ', [['includes','Xml.php',23]], 911], 'asirra': ['asirra', '', [['extensions/ConfirmEdit','Asirra.class.php',7]], 0], 'html': ['html', 'This class is a collection of static functions that serve two purposes: ', [['includes','Html.php',26]], 764], 'simplecaptcha': ['simplecaptcha', '', [['extensions/ConfirmEdit','Captcha.php',3]], 5]}; CONST_DATA={ };


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1