X-Git-Url: https://git.toastfreeware.priv.at/toast/cookiecaptcha.git/blobdiff_plain/acdbf7ae1a810733dffad43e39ba316e92a9075e..e0c8737c449dbf15c13e27c6b7343c09fd7d22f3:/MathCaptcha.class.php diff --git a/MathCaptcha.class.php b/MathCaptcha.class.php index 9348d87..9b9cde2 100644 --- a/MathCaptcha.class.php +++ b/MathCaptcha.class.php @@ -7,26 +7,26 @@ class MathCaptcha extends SimpleCaptcha { return (int)$answer == (int)$info['answer']; } - function addCaptchaAPI(&$resultArr) { + function addCaptchaAPI( &$resultArr ) { list( $sum, $answer ) = $this->pickSum(); - $index = $this->storeCaptcha( array('answer' => $answer ) ); + $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() { list( $sum, $answer ) = $this->pickSum(); $index = $this->storeCaptcha( array( 'answer' => $answer ) ); - + $form = ''; $form .= '
' . $this->fetchMath( $sum ) . '' . Xml::input( 'wpCaptchaWord', false, false, array( 'tabindex' => '1' ) ) . '
'; $form .= Xml::hidden( 'wpCaptchaId', $index ); return $form; } - + /** Pick a random sum */ function pickSum() { $a = mt_rand( 0, 100 ); @@ -36,7 +36,7 @@ class MathCaptcha extends SimpleCaptcha { $ans = $op == '+' ? ( $a + $b ) : ( $a - $b ); return array( $sum, $ans ); } - + /** Fetch the math */ function fetchMath( $sum ) { $math = new MathRenderer( $sum ); @@ -44,6 +44,4 @@ class MathCaptcha extends SimpleCaptcha { $html = $math->render(); return preg_replace( '/alt=".*?"/', '', $html ); } - } -?>