Localisation updates (extensions) from Betawiki (2008-06-25 22:11 CEST)
[toast/cookiecaptcha.git] / MathCaptcha.class.php
index 01d63915035bb20c2d1fff645218e3380b31d80c..66567e03503495846d449beb17a4e463030ce78c 100644 (file)
@@ -3,8 +3,17 @@
 class MathCaptcha extends SimpleCaptcha {
 
        /** Validate a captcha response */
-       function keyMatch( $req, $info ) {
-               return (int)$req->getVal( 'wpCaptchaAnswer' ) == (int)$info['answer'];
+       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 */