FU r102105, escaped the quotes.
[toast/cookiecaptcha.git] / FancyCaptcha.class.php
index fd3590450e42430b18675f55213357c1256e197f..26227aa30bc11fd0014bc8917e547d664d2baaa2 100644 (file)
@@ -44,7 +44,7 @@ class FancyCaptcha extends SimpleCaptcha {
        function getForm() {
                $info = $this->pickImage();
                if ( !$info ) {
-                       die( "out of captcha images; this shouldn't happen" );
+                       throw new MWException( "Ran out of captcha images" );
                }
 
                // Generate a random key for use of this captcha image in this session.
@@ -69,9 +69,10 @@ class FancyCaptcha extends SimpleCaptcha {
                                'id'    => 'wpCaptchaId',
                                'value' => $index ) ) .
                        "<p>" .
-                       Xml::element( 'input', array(
+                       Html::element( 'input', array(
                                'name' => 'wpCaptchaWord',
                                'id'   => 'wpCaptchaWord',
+                               'required',
                                'tabindex' => 1 ) ) . // tab in before the edit textarea
                        "</p>\n";
        }
@@ -227,4 +228,23 @@ class FancyCaptcha extends SimpleCaptcha {
                # the default for edits
                return wfEmptyMsg( $name, $text ) ? wfMsg( 'fancycaptcha-edit' ) : $text;
        }
+
+       /**
+        * Delete a solved captcha image, if $wgCaptchaDeleteOnSolve is true.
+        */
+       function passCaptcha() {
+               global $wgCaptchaDeleteOnSolve;
+
+               $info = $this->retrieveCaptcha(); // get the captcha info before it gets deleted
+               $pass = parent::passCaptcha();
+
+               if ( $pass && $wgCaptchaDeleteOnSolve ) {
+                       $filename = $this->imagePath( $info['salt'], $info['hash'] );
+                       if ( file_exists( $filename ) ) {
+                               unlink( $filename );
+                       }
+               }
+
+               return $pass;
+       }
 }