function _phrase_captcha_word_question_double_occurence in CAPTCHA Pack 8
Same name and namespace in other branches
- 5 text_captcha/phrase_captcha/phrase_captcha.module \_phrase_captcha_word_question_double_occurence()
- 6 text_captcha/phrase_captcha/phrase_captcha.inc \_phrase_captcha_word_question_double_occurence()
- 7 text_captcha/phrase_captcha/phrase_captcha.module \_phrase_captcha_word_question_double_occurence()
Return details of 'double occurrence' challenge.
1 string reference to '_phrase_captcha_word_question_double_occurence'
- phrase_captcha.settings.yml in text_captcha/
modules/ phrase_captcha/ config/ install/ phrase_captcha.settings.yml - text_captcha/modules/phrase_captcha/config/install/phrase_captcha.settings.yml
File
- text_captcha/
modules/ phrase_captcha/ phrase_captcha.module, line 238 - Implementation of a phrase based CAPTCHA, for use with the CAPTCHA module.
Code
function _phrase_captcha_word_question_double_occurence($words) {
// Assure single occurence of each word.
$words = array_unique($words);
// Pick a word.
$key = array_rand($words, 1);
$answer = $words[$key];
// Replace another word with it.
while (($pos = array_rand($words, 1)) == $key) {
// NOP aka NOOP aka pass.
}
array_splice($words, $pos, 1, $answer);
$description = t('Which word occurs two times in the CAPTCHA phrase above?');
return [
$words,
$description,
$answer,
];
}