]> ToastFreeware Gitweb - toast/cookiecaptcha.git/blobdiff - FancyCaptcha.class.php
Localisation updates for extension messages from Betawiki (2008-12-01 09:20 CET)
[toast/cookiecaptcha.git] / FancyCaptcha.class.php
index 93b49ffca0a28317814c1ee8ab2ea933b22e710a..cf723d76315704bd67b4c4bbe1ab153059ace8ac 100644 (file)
@@ -5,14 +5,13 @@ class FancyCaptcha extends SimpleCaptcha {
         * Check if the submitted form matches the captcha session data provided
         * by the plugin when the form was generated.
         *
-        * @param WebRequest $request
+        * @param string $answer
         * @param array $info
         * @return bool
         */
-       function keyMatch( $request, $info ) {
+       function keyMatch( $answer, $info ) {
                global $wgCaptchaSecret;
 
-               $answer = $request->getVal( 'wpCaptchaWord' );
                $digest = $wgCaptchaSecret . $info['salt'] . $answer . $wgCaptchaSecret . $info['salt'];
                $answerHash = substr( md5( $digest ), 0, 16 );
 
@@ -25,6 +24,20 @@ class FancyCaptcha extends SimpleCaptcha {
                }
        }
 
+       function addCaptchaAPI(&$resultArr) {
+               $info = $this->pickImage();
+               if( !$info ) {
+                       $resultArr['captcha']['error'] = 'Out of images';
+                       return;
+               }
+               $index = $this->storeCaptcha( $info );
+               $title = Title::makeTitle( NS_SPECIAL, '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.
         */
@@ -159,10 +172,15 @@ class FancyCaptcha extends SimpleCaptcha {
 
                $info = $this->retrieveCaptcha();
                if( $info ) {
+                       /*
+                       // Be a little less restrictive for now; in at least some circumstances,
+                       // Konqueror tries to reload the image even if you haven't navigated
+                       // away from the page.
                        if( $info['viewed'] ) {
                                wfHttpError( 403, 'Access Forbidden', "Can't view captcha image a second time." );
                                return false;
                        }
+                       */
 
                        $info['viewed'] = wfTimestamp();
                        $this->storeCaptcha( $info );
@@ -174,6 +192,7 @@ class FancyCaptcha extends SimpleCaptcha {
                        if( file_exists( $file ) ) {
                                global $IP;
                                require_once "$IP/includes/StreamFile.php";
+                               header( "Cache-Control: private, s-maxage=0, max-age=3600" );
                                wfStreamFile( $file );
                                return true;
                        }