You are here

function _text_captcha_generate_words in CAPTCHA 6

Same name and namespace in other branches
  1. 5.3 text_captcha/text_captcha.module \_text_captcha_generate_words()

function for generating an array of words

1 call to _text_captcha_generate_words()
text_captcha_captcha in text_captcha/text_captcha.module
Implementation of hook_captcha

File

text_captcha/text_captcha.user.inc, line 27

Code

function _text_captcha_generate_words($num) {
  $words = array();
  if (variable_get('text_captcha_words', TEXT_CAPTCHA_GENERATE_NONSENSE_WORDS) == TEXT_CAPTCHA_USER_DEFINED_WORDS) {

    // use user defined words
    $uwords = explode(' ', variable_get('text_captcha_userdefined_words', ''));
    $keys = array_rand($uwords, $num);
    foreach ($keys as $key) {
      $words[] = $uwords[$key];
    }
  }
  else {

    // generate nonsense words
    for ($w = 0; $w < $num; ++$w) {
      $words[] = _text_captcha_generate_nonsense_word(mt_rand(3, 7));
    }
  }
  return $words;
}