function _math_captcha_multiplication_challenge in CAPTCHA Pack 5
Same name and namespace in other branches
- 8 math_captcha/math_captcha.challenge.inc \_math_captcha_multiplication_challenge()
 - 6 math_captcha/math_captcha.challenge.inc \_math_captcha_multiplication_challenge()
 - 7 math_captcha/math_captcha.challenge.inc \_math_captcha_multiplication_challenge()
 
function for multiplication challenges
File
- math_captcha/
math_captcha.module, line 258  
Code
function _math_captcha_multiplication_challenge() {
  $argmax = intval(variable_get('math_captcha_multiplication_argmax', 5));
  $x = mt_rand(1, $argmax);
  $y = mt_rand(1, $argmax);
  if (variable_get('math_captcha_multiplication_allow_negative', FALSE)) {
    $x = $x * (mt_rand(0, 1) * 2 - 1);
    $y = $y * (mt_rand(0, 1) * 2 - 1);
  }
  $solution = $x * $y;
  $maxlength = strlen(strval($argmax * $argmax)) + intval(variable_get('math_captcha_multiplication_allow_negative', FALSE));
  return _math_captcha_build_captcha($x, $y, '*', $solution, $maxlength);
}