function _word_list_captcha_get_word_list_captcha in CAPTCHA Pack 8
Same name and namespace in other branches
- 5 text_captcha/word_list_captcha/word_list_captcha.module \_word_list_captcha_get_word_list_captcha()
- 6 text_captcha/word_list_captcha/word_list_captcha.module \_word_list_captcha_get_word_list_captcha()
- 7 text_captcha/word_list_captcha/word_list_captcha.module \_word_list_captcha_get_word_list_captcha()
Helper function for generating a word list CAPTCHA.
1 call to _word_list_captcha_get_word_list_captcha()
- word_list_captcha_captcha in text_captcha/
modules/ word_list_captcha/ word_list_captcha.module - Implements hook_captcha().
File
- text_captcha/
modules/ word_list_captcha/ word_list_captcha.module, line 24 - Contains general functionality for the module.
Code
function _word_list_captcha_get_word_list_captcha($list_size) {
if (mt_rand(0, 1)) {
$normal_words = _text_captcha_word_pool_get_content('word_list_captcha_word_pool_1', NULL, WORD_LIST_CAPTCHA_WORD_POOL1, TRUE);
$other_words = _text_captcha_word_pool_get_content('word_list_captcha_word_pool_2', NULL, WORD_LIST_CAPTCHA_WORD_POOL2, TRUE);
}
else {
$normal_words = _text_captcha_word_pool_get_content('word_list_captcha_word_pool_2', NULL, WORD_LIST_CAPTCHA_WORD_POOL2, TRUE);
$other_words = _text_captcha_word_pool_get_content('word_list_captcha_word_pool_1', NULL, WORD_LIST_CAPTCHA_WORD_POOL1, TRUE);
}
shuffle($normal_words);
$word_list = array_slice($normal_words, 0, $list_size - 1);
$wrong_word = $other_words[array_rand($other_words)];
$word_list[] = $wrong_word;
shuffle($word_list);
return [
$word_list,
$wrong_word,
];
}