Now the simple math captcha is combined with the cookie captcha.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 12 Feb 2013 21:57:56 +0000 (22:57 +0100)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 12 Feb 2013 21:57:56 +0000 (22:57 +0100)
CookieCaptcha.class.php

index b96ac4c674db1774ca47df8333bf1fcbce89471d..46b0deb605d7ff9204f7cb15e7cc4cff11151fee 100644 (file)
@@ -1,51 +1,22 @@
 <?php
 
 class CookieCaptcha extends SimpleCaptcha {
-       /**
-        * Check if the submitted form matches the captcha session data provided
-        * by the plugin when the form was generated.
-        *
-        * @param string $answer
-        * @param array $info
-        * @return bool
-        */
-       function keyMatch( $answer, $info ) {
+       // Check whether the cookie is present
+       function keyMatch($answer, $info) {
                global $wgCaptchaCookieName;
                if (isset($_COOKIE[$wgCaptchaCookieName])) {
                        wfDebug( "CookieCaptcha: Found cookie\n" );
-                       return true;
+                       return parent::keyMatch($answer, $info);
                } else {
                        wfDebug( "CookieCaptcha: Didn't find cookie...\n" );
                        return false;
                }
        }
 
-       function retrieveCaptcha() {
-               return true;
-       }
-
-       /*
-       function addCaptchaAPI( &$resultArr ) {
-               $info = $this->pickImage();
-               if ( !$info ) {
-                       $resultArr['captcha']['error'] = 'Out of images';
-                       return;
-               }
-               $index = $this->storeCaptcha( $info );
-               $title = SpecialPage::getTitleFor( 'Captcha', 'image' );
-               $resultArr['captcha']['type'] = 'image';
-               $resultArr['captcha']['mime'] = 'image/png';
-               $resultArr['captcha']['id'] = $index;
-               $resultArr['captcha']['url'] = $title->getLocalUrl( 'wpCaptchaId=' . urlencode( $index ) );
-       }
-        */
 
-       /**
-        * Insert the captcha prompt into the edit form.
-        */
        function getForm() {
                global $wgCaptchaCookieName, $wgCaptchaCookieImage, $wgCaptchaCookieAlt, $wgCaptchaCookieStyle;
-               return "<p>" .
+               return parent::getForm() . "<p>" .
                        Html::element( 'img', array(
                                'src'    => $wgCaptchaCookieImage,
                                'alt'    => $wgCaptchaCookieAlt,
@@ -53,22 +24,4 @@ class CookieCaptcha extends SimpleCaptcha {
                        "</p>\n";
        }
 
-       /**
-        * Show a message asking the user to enter a captcha on edit
-        * The result will be treated as wiki text
-        *
-        * @param $action string Action being performed
-        * @return string
-        */
-       /*
-       function getMessage( $action ) {
-               $name = 'fancycaptcha-' . $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( 'fancycaptcha-edit' )->text() : $text;
-       }
-        */
-
 }