]> ToastFreeware Gitweb - toast/cookiecaptcha.git/blobdiff - MathCaptcha.class.php
Localisation updates for extension messages from translatewiki.net (2009-06-28 19...
[toast/cookiecaptcha.git] / MathCaptcha.class.php
index adf1663b8de956b6c3e03df859f25e53206fc0ec..9348d873b28b68251ea452a0b2428650a5b3b04c 100644 (file)
@@ -6,6 +6,15 @@ class MathCaptcha extends SimpleCaptcha {
        function keyMatch( $answer, $info ) {
                return (int)$answer == (int)$info['answer'];
        }
+
+       function addCaptchaAPI(&$resultArr) {
+               list( $sum, $answer ) = $this->pickSum();
+               $index = $this->storeCaptcha( array('answer' => $answer ) );
+               $resultArr['captcha']['type'] = 'math';
+               $resultArr['captcha']['mime'] = 'text/tex';
+               $resultArr['captcha']['id'] = $index;
+               $resultArr['captcha']['question'] = $sum;
+       }
        
        /** Produce a nice little form */
        function getForm() {
@@ -13,8 +22,8 @@ class MathCaptcha extends SimpleCaptcha {
                $index = $this->storeCaptcha( array( 'answer' => $answer ) );
                
                $form = '<table><tr><td>' . $this->fetchMath( $sum ) . '</td>';
-               $form .= '<td>' . wfInput( 'wpCaptchaAnswer', false, false, array( 'tabindex' => '1' ) ) . '</td></tr></table>';
-               $form .= wfHidden( 'wpCaptchaId', $index );
+               $form .= '<td>' . Xml::input( 'wpCaptchaWord', false, false, array( 'tabindex' => '1' ) ) . '</td></tr></table>';
+               $form .= Xml::hidden( 'wpCaptchaId', $index );
                return $form;
        }
        
@@ -33,7 +42,7 @@ class MathCaptcha extends SimpleCaptcha {
                $math = new MathRenderer( $sum );
                $math->setOutputMode( MW_MATH_PNG );
                $html = $math->render();
-               return preg_replace( '/alt=".*"/', '', $html );
+               return preg_replace( '/alt=".*?"/', '', $html );
        }
 
 }