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 = '<table><tr><td>' . $this->fetchMath( $sum ) . '</td>';
- $form .= '<td>' . wfInput( 'wpCaptchaWord', 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 .= Html::hidden( 'wpCaptchaId', $index );
return $form;
}
-
+
/** Pick a random sum */
function pickSum() {
$a = mt_rand( 0, 100 );
$ans = $op == '+' ? ( $a + $b ) : ( $a - $b );
return array( $sum, $ans );
}
-
+
/** Fetch the math */
function fetchMath( $sum ) {
$math = new MathRenderer( $sum );
$html = $math->render();
return preg_replace( '/alt=".*?"/', '', $html );
}
-
}
-?>