Strix has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/65797


Change subject: Add support for the AreYouAHuman/PlayThru CAPTCHA
......................................................................

Add support for the AreYouAHuman/PlayThru CAPTCHA

Initial support.  Tested with MediaWiki 1.20.2 and 1.21.0.

Update README with mention of Ayah capture in similar manner to
existing entries.

Change-Id: I632153da66a2cafc99003a622b711a16bae6f7cd
---
A AreYouAHuman/.gitignore
A AyahCaptcha.class.php
A AyahCaptcha.i18n.php
A AyahCaptcha.php
M README
5 files changed, 176 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ConfirmEdit 
refs/changes/97/65797/1

diff --git a/AreYouAHuman/.gitignore b/AreYouAHuman/.gitignore
new file mode 100644
index 0000000..f85311b
--- /dev/null
+++ b/AreYouAHuman/.gitignore
@@ -0,0 +1,6 @@
+# The AYAH PHP integration library should be downloaded from:
+#      http://portal.areyouahuman.com/installation/php
+
+*
+
+!.gitignore
diff --git a/AyahCaptcha.class.php b/AyahCaptcha.class.php
new file mode 100644
index 0000000..3817767
--- /dev/null
+++ b/AyahCaptcha.class.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * @author strix
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+       exit;
+}
+
+$dir = __DIR__;
+require_once $dir . '/AreYouAHuman/ayah.php';
+
+class AyahCaptcha extends SimpleCaptcha {
+       /**
+       * Determines if the Catpcha was a pass.
+       *
+       * @return {bool} True if the Captcha was a pass
+       */
+       function passCaptcha() {
+               $ayah = new AYAH();
+               return $ayah->scoreResult();
+       }
+
+        /* Suppress redundant generation of SimpleCaptcha itself */
+       function addCaptchaAPI( &$resultArr ) {
+       }
+
+       /**
+       * Gets the HTML that will be displayed on a form.
+       *
+       * @return {string} HTML
+       */
+       function getForm() {
+               $ayah = new AYAH();
+               return $ayah->getPublisherHTML() . '<noscript>' . wfMessage( 
'ayahcaptcha-nojs' )->parse() . '</noscript>';
+       }
+
+       /**
+       * Gets a localized string
+       *
+       * @param {string} $action Action being taken
+       *
+       * @return {string} Localized string
+       */
+       function getMessage( $action ) {
+               $name = 'ayahcaptcha-' . $action;
+               $text = wfMessage( $name )->text();
+               # Obtain a more tailored message, if possible, otherwise, fall 
back to
+               # the default for edits
+               return wfMessage( $name, $text )->isDisabled() ? wfMessage( 
'ayahcaptcha-edit' )->text() : $text;
+       }
+
+       /**
+       * Adds a help message to the output
+       */
+       function showHelp() {
+               global $wgOut;
+               $wgOut->setPageTitle( wfMessage( 'captchahelp-title' )->text() 
);
+               $wgOut->addWikiMsg( 'ayahcaptchahelp-text' );
+       }
+}
diff --git a/AyahCaptcha.i18n.php b/AyahCaptcha.i18n.php
new file mode 100644
index 0000000..bb79dff
--- /dev/null
+++ b/AyahCaptcha.i18n.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * Internationalisation file for the AyahCaptcha sub-extension.
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+$messages = array();
+
+/** English
+ * @author strix
+ */
+$messages['en'] = array(
+       'ayahcaptcha-edit'               => 'To edit this page, please PlayThru 
([[Special:Captcha/help|more info]]):',
+       'ayahcaptcha-desc'               => 'Provides CAPTCHA techniques to 
protect against spam and password-guessing',
+       'ayahcaptcha-label'              => 'CAPTCHA',
+       'ayahcaptcha-addurl'             => 'Your edit includes new external 
links.
+To protect the wiki against automated spam, we kindly ask you to PlayThru in 
order to save your edit ([[Special:Captcha/help|more info]]):',
+       'ayahcaptcha-badlogin'           => 'To protect the wiki against 
automated password cracking, we kindly ask you to PlayThru 
([[Special:Captcha/help|more info]]):',
+       'ayahcaptcha-createaccount'      => 'To protect the wiki against 
automated account creation, we kindly ask you to PlayThru 
([[Special:Captcha/help|more info]]):',
+       'ayahcaptcha-createaccount-fail' => 'Incomplete PlayThru!',
+       'ayahcaptcha-create'             => 'To create the page, please 
PlayThru ([[Special:Captcha/help|more info]]):',
+       'ayahcaptcha-sendemail'          => 'To protect the wiki against 
automated spamming, we kindly ask you to PlayThru ([[Special:Captcha/help|more 
info]]):',
+       'ayahcaptcha-sendemail-fail'     => 'Incomplete PlayThru!',
+       'ayahcaptcha-disabledinapi'      => 'This action requires a captcha, so 
it cannot be performed through the API.',
+        'ayahcaptcha-nojs'               => '\'\'\'<span style="font-size: 
150%; color: red;">You need to enable JavaScript in order to verify by 
PlayThru.</span>\'\'\'',
+       'ayahcaptchahelp-text'           => "Web sites that accept postings 
from the public, like this wiki, are often abused by spammers who use automated 
tools to post their links to many sites.
+While these spam links can be removed, they are a significant nuisance.
+
+Sometimes, especially when adding new web links to a page, the wiki may ask 
you to complete a PlayThru puzzle.  Since this is a task that's hard to 
automate, it will allow most real humans to make their posts while stopping 
most spammers and other robotic attackers.  Please contact the  
[[{{MediaWiki:Grouppage-sysop}}|site administrators]] for assistance if this is 
unexpectedly preventing you from making legitimate actions.
+
+Hit the 'back' button in your browser to return to the page editor.",
+);
+
+/** Message documentation (Message documentation)
+ * @author Aotake
+ * @author Hamilton Abreu
+ * @author MF-Warburg
+ * @author Meithal
+ * @author Meno25
+ * @author Purodha
+ * @author Siebrand
+ * @author The Evil IP address
+ * @author Toliño
+ * @author Umherirrender
+ */
+$messages['qqq'] = array(
+       'ayahcaptcha-edit' => 'This message will be shown when editing if the 
wiki requires solving a captcha for editing.
+See also
+*{{msg-mw|Questycaptcha-edit}}
+*{{msg-mw|Fancycaptcha-edit}}',
+       'ayahcaptcha-desc' => '{{desc}}',
+       'ayahcaptcha-label' => 'Label field for input field shown in forms',
+       'ayahcaptcha-addurl' => 'The explanation of CAPTCHA shown to users 
trying to add new external links.
+See also
+*{{msg-mw|Questycaptcha-addurl}}
+*{{msg-mw|Fancycaptcha-addurl}}',
+       'ayahcaptcha-badlogin' => 'The explanation of CAPTCHA shown to users 
failed three times to type in correct password.
+See also
+*{{msg-mw|Questycaptcha-badlogin}}
+*{{msg-mw|Fancycaptcha-badlogin}}',
+       'ayahcaptcha-createaccount' => 'The explanation of CAPTCHA shown to 
users trying to create a new account.
+See also
+*{{msg-mw|Questycaptcha-createaccount}}
+*{{msg-mw|Fancycaptcha-createaccount}}',
+       'ayahcaptcha-createaccount-fail' => 'Used as failure message.
+{{Related|ConfirmEdit-createaccount-fail}}',
+       'ayahcaptcha-create' => 'This message will be shown when creating a 
page if the wiki requires solving a captcha for that.
+See also
+*{{msg-mw|Questycaptcha-create}}
+*{{msg-mw|Fancycaptcha-create}}',
+        'ayahcaptcha-nojs'  => 'This message will be shown when a PlayThru 
should be shown, but user has JavaScript disabled.',
+       'ayahcaptcha-sendemail' => 'Used as footer text.
+{{Related|ConfirmEdit-sendemail}}',
+       'ayahcaptcha-sendemail-fail' => 'Used as failure message.
+
+See also:
+* {{msg-mw|Captcha-createaccount-fail}}',
+       'ayahcaptcha-disabledinapi' => 'Used as error message when in the API 
mode.',
+       'ayahcaptchahelp-text' => 'This is the help text shown on 
[[Special:Captcha/help]].',
+);
diff --git a/AyahCaptcha.php b/AyahCaptcha.php
new file mode 100644
index 0000000..6a79be3
--- /dev/null
+++ b/AyahCaptcha.php
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Captcha class using the Are You A Human service
+ *
+ * @file
+ * @ingroup Extensions
+ * @author strix
+ * @copyright © 2013 Strix
+ * @licence GNU General Public Licence 2.0
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+       exit;
+}
+
+$dir = __DIR__;
+require_once $dir . '/ConfirmEdit.php';
+$wgCaptchaClass = 'AyahCaptcha';
+
+$wgExtensionMessagesFiles['AyahCaptcha'] = $dir . '/AyahCaptcha.i18n.php';
+$wgAutoloadClasses['AyahCaptcha'] = $dir . '/AyahCaptcha.class.php';
diff --git a/README b/README
index acfe481..eaff3ab 100644
--- a/README
+++ b/README
@@ -21,6 +21,9 @@
 visually or audially, from a widget provided by the reCAPTCHA service
 * Asirra - users have to identify the cats in a set of photos of cats
 and dogs, from a widget provided by the Microsoft Asirra service
+* AreYouAHuman (aka PlayThru) - users have to play a very short game, in
+which the user matches related objects.  Demo at:
+http://areyouahuman.com/demo/
 
 == License ==
 
@@ -39,6 +42,8 @@
 
 The Asirra module was written by Bachsau.
 
+The AreYouAHuman module was written by strix.
+
 Additional maintenance work was done by Yaron Koren.
 
 == Changelog ==

-- 
To view, visit https://gerrit.wikimedia.org/r/65797
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I632153da66a2cafc99003a622b711a16bae6f7cd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ConfirmEdit
Gerrit-Branch: master
Gerrit-Owner: Strix <strix.a...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to