You are here

function math_captcha_captcha in CAPTCHA Pack 6

Same name and namespace in other branches
  1. 8 math_captcha/math_captcha.module \math_captcha_captcha()
  2. 5 math_captcha/math_captcha.module \math_captcha_captcha()
  3. 7 math_captcha/math_captcha.module \math_captcha_captcha()

Implementation of hook_captcha().

File

math_captcha/math_captcha.module, line 38

Code

function math_captcha_captcha($op, $captcha_type = '') {
  switch ($op) {
    case 'list':
      return array(
        'Math CAPTCHA',
      );
    case 'generate':
      if ($captcha_type == 'Math CAPTCHA') {
        require_once 'math_captcha.challenge.inc';

        // get the available challenges
        $challenges = array_filter(_math_captcha_enabled_challenges());
        $challenge = $challenges[array_rand($challenges)];
        $form_item = call_user_func("_math_captcha_{$challenge}_challenge");
        return $form_item;
      }
  }
}