Proof of concept.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 27 Nov 2012 22:41:47 +0000 (23:41 +0100)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 27 Nov 2012 22:41:47 +0000 (23:41 +0100)
CookieCaptcha.class.php

index 1ab28797a99497be8a70a37e87042b796a04529b..a85973608223f3438f4c2326d53feae9ad6459a3 100644 (file)
@@ -9,22 +9,19 @@ class CookieCaptcha extends SimpleCaptcha {
         * @param array $info
         * @return bool
         */
-       /*
        function keyMatch( $answer, $info ) {
-               global $wgCaptchaSecret;
-
-               $digest = $wgCaptchaSecret . $info['salt'] . $answer . $wgCaptchaSecret . $info['salt'];
-               $answerHash = substr( md5( $digest ), 0, 16 );
-
-               if ( $answerHash == $info['hash'] ) {
-                       wfDebug( "FancyCaptcha: answer hash matches expected {$info['hash']}\n" );
+               if (isset($_COOKIE['cookiecaptcha'])) {
+                       wfDebug( "CookieCaptcha: Found cookie\n" );
                        return true;
                } else {
-                       wfDebug( "FancyCaptcha: answer hashes to $answerHash, expected {$info['hash']}\n" );
+                       wfDebug( "CookieCaptcha: Didn't find cookie...\n" );
                        return false;
                }
        }
-        */
+
+       function retrieveCaptcha() {
+               return true;
+       }
 
        /*
        function addCaptchaAPI( &$resultArr ) {
@@ -45,49 +42,14 @@ class CookieCaptcha extends SimpleCaptcha {
        /**
         * Insert the captcha prompt into the edit form.
         */
-    /*
        function getForm() {
-               $info = $this->pickImage();
-               if ( !$info ) {
-                       throw new MWException( "Ran out of captcha images" );
-               }
-
-               // Generate a random key for use of this captcha image in this session.
-               // This is needed so multiple edits in separate tabs or windows can
-               // go through without extra pain.
-               $index = $this->storeCaptcha( $info );
-
-               wfDebug( "Captcha id $index using hash ${info['hash']}, salt ${info['salt']}.\n" );
-
-               $title = SpecialPage::getTitleFor( 'Captcha', 'image' );
-
+               global $wgLogo;
                return "<p>" .
                        Html::element( 'img', array(
-                               'src'    => $title->getLocalUrl( 'wpCaptchaId=' . urlencode( $index ) ),
-                               'width'  => $info['width'],
-                               'height' => $info['height'],
+                               'src'    => $wgLogo,
                                'alt'    => '' ) ) .
-                       "</p>\n" .
-                       Html::element( 'input', array(
-                               'type'  => 'hidden',
-                               'name'  => 'wpCaptchaId',
-                               'id'    => 'wpCaptchaId',
-                               'value' => $index ) ) .
-                       '<p>' .
-                       Html::element( 'label', array(
-                               'for' => 'wpCaptchaWord',
-                       ), parent::getMessage( 'label' ) . wfMessage( 'colon-separator' )->text() ) .
-                       Html::element( 'input', array(
-                               'name' => 'wpCaptchaWord',
-                               'id'   => 'wpCaptchaWord',
-                               'type' => 'text',
-                               'autocorrect' => 'off',
-                               'autocapitalize' => 'off',
-                               'required' => 'required',
-                               'tabindex' => 1 ) ) . // tab in before the edit textarea
                        "</p>\n";
        }
-   */
 
        /**
         * Show a message asking the user to enter a captcha on edit