summaryrefslogtreecommitdiff
path: root/extensions/ConfirmEdit/Asirra.class.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2012-04-26 18:23:31 +0200
committerPierre Schmitz <pierre@archlinux.de>2012-04-26 18:23:31 +0200
commitc4372dd38a4d109b4f3881ea63b667e33adbe503 (patch)
treee8e6dae1229a68c26b7a348c73dc0c8c77da97e5 /extensions/ConfirmEdit/Asirra.class.php
parentcf566324cfb218f0c7323d97d2a103bbb8d60ba4 (diff)
Update to MediaWiki 1.18.3
Diffstat (limited to 'extensions/ConfirmEdit/Asirra.class.php')
-rw-r--r--extensions/ConfirmEdit/Asirra.class.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/extensions/ConfirmEdit/Asirra.class.php b/extensions/ConfirmEdit/Asirra.class.php
new file mode 100644
index 00000000..1f31d089
--- /dev/null
+++ b/extensions/ConfirmEdit/Asirra.class.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * @author Bachsau
+ * @author Niklas Laxström
+ */
+
+class Asirra extends SimpleCaptcha {
+ public $asirra_clientscript = 'http://challenge.asirra.com/js/AsirraClientSide.js';
+
+ // As we don't have to store anything but some other things to do,
+ // we're going to replace that constructor completely.
+ function __construct() {
+ global $wgExtensionAssetsPath, $wgAsirraScriptPath;
+ $this->asirra_localpath = "$wgExtensionAssetsPath/ConfirmEdit";
+ }
+
+ function getForm() {
+ global $wgAsirraEnlargedPosition, $wgAsirraCellsPerRow, $wgOut, $wgLang;
+
+ $wgOut->addModules( 'ext.confirmedit.asirra' );
+ $js = Html::linkedScript( $this->asirra_clientscript );
+
+ $message = Xml::encodeJsVar( wfMessage( 'asirra-createaccount-fail' )->plain() );
+ $js .= Html::inlineScript( <<<JAVASCRIPT
+var asirra_js_failed = '$message';
+JAVASCRIPT
+ );
+ $js .= '<noscript>' . wfMessage( 'asirra-nojs' )->parse() . '</noscript>';
+ return $js;
+ }
+
+ function passCaptcha() {
+ global $wgRequest;
+
+ $ticket = $wgRequest->getVal( 'Asirra_Ticket' );
+ $api = 'http://challenge.asirra.com/cgi/Asirra?';
+ $params = array(
+ 'action' => 'ValidateTicket',
+ 'ticket' => $ticket,
+ );
+
+ $response = Http::get( $api . wfArrayToCgi( $params ) );
+ $xml = simplexml_load_string( $response );
+ $result = $xml->xpath( '/AsirraValidation/Result' );
+ return strval( $result[0] ) === 'Pass';
+ }
+}