Answer the question
In order to leave comments, you need to log in
ZF1 Why does Captcha show the last character as an English letter when using Russian characters?
ZF1 Captcha when using Russian characters gives the last character as an English letter
Hello everyone. Who can tell in which direction to think?
I know where the error occurs, namely in the core of zend in `abstract class Zend_Captcha_Word` in this method
/**
* Generate new random word
*
* @return string
*/
protected function _generateWord()
{
$word = '';
$wordLen = $this->getWordLen();
$vowels = $this->_useNumbers ? self::$VN : self::$V;
$consonants = $this->_useNumbers ? self::$CN : self::$C;
$totIndexCon = count($consonants) - 1;
$totIndexVow = count($vowels) - 1;
for ($i=0; $i < $wordLen; $i = $i + 2) {
// generate word with mix of vowels and consonants
$consonant = $consonants[Zend_Crypt_Math::randInteger(0, $totIndexCon, true)];
$vowel = $vowels[Zend_Crypt_Math::randInteger(0, $totIndexVow, true)];
$word .= $consonant . $vowel;
}
if (strlen($word) > $wordLen) {
// *******************************************
// * ВОТ ЗДЕСЬ НУЖНО, ЧТОБЫ БЫЛО mb_substr() *
// *******************************************
$word = substr($word, 0, $wordLen);
}
return $word;
}
Zend_Captcha_Word::$CN = ['а', 'в', 'г', 'д', 'е', 'ж', 'и', 'к', 'л', 'м', 'н', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'э', 'ю', 'я', 1, 2, 3, 4, 5, 6, 7, 8, 9];
Zend_Captcha_Word::$VN = range(0, 9);
Zend_Captcha_Word::$V = ['с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'э', 'ю', 'я'];
Zend_Captcha_Word::$C = ['а', 'в', 'г', 'д', 'е', 'ж'];
$element = new Zend_Form_Element_Captcha('captcha', [
'captcha' => [
'captcha' => 'Image',
'wordLen' => 7,
'timeout' => 120,
'expiration' => 300,
'font' => './fonts/myfont.ttf',
'imgDir' => './captcha/',
'imgUrl' => '/captcha/',
'dotNoiseLevel' => 40,
'lineNoiseLevel' => 4,
'class' => 'img-thumbnail',
]
]);
$element->setRequired(true)
->setLabel('Проверочный код')
->setAttrib('placeholder', 'Введите число')
->setAttrib('class', 'form-control')
->addDecorator(['row' => 'HtmlTag'], ['tag' => 'div', 'class' => 'form-group']);
$this->addElement($element);
Answer the question
In order to leave comments, you need to log in
use the php function reload mechanism, man
namely in php.ini you need to add
mbstring.func_overload = 2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question