getWordLen(); $vowels = $this->_useNumbers ? self::$VN : self::$V; $consonants = $this->_useNumbers ? self::$CN : self::$C; for ($i=0; $i < $wordLen; $i = $i + 2) { // generate word with mix of vowels and consonants $consonant = $consonants[array_rand($consonants)]; $vowel = $vowels[array_rand($vowels)]; $word .= $consonant . $vowel; } if (strlen($word) > $wordLen) { $word = substr($word, 0, $wordLen); } return $word; } /** * Set captcha word * * @param string $word * @return Zend_Captcha_Word */ protected function _setWord($word) { $word = strtoupper($word); $session = $this->getSession(); $session->word = $word; $this->_word = $word; return $this; } /** * Validate the word * * Overriden to handle on in uppercase for better readability * * @see Zend_Validate_Interface::isValid() * @param mixed $value * @return boolean */ public function isValid($value, $context = null) { $name = $this->getName(); if (!isset($context[$name]['input'])) { $this->_error(self::MISSING_VALUE); return false; } $value = strtoupper($context[$name]['input']); $this->_setValue($value); if (!isset($context[$name]['id'])) { $this->_error(self::MISSING_ID); return false; } $this->_id = $context[$name]['id']; if ($value !== $this->getWord()) { $this->_error(self::BAD_CAPTCHA); return false; } return true; } }