import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -220,6 +220,10 @@ abstract class Zend_Captcha_Word extends Zend_Captcha_Base
|
||||
{
|
||||
if (!isset($this->_session) || (null === $this->_session)) {
|
||||
$id = $this->getId();
|
||||
if (!class_exists($this->_sessionClass)) {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($this->_sessionClass);
|
||||
}
|
||||
$this->_session = new $this->_sessionClass('Zend_Form_Captcha_' . $id);
|
||||
$this->_session->setExpirationHops(1, null, true);
|
||||
$this->_session->setExpirationSeconds($this->getTimeout());
|
||||
@ -322,21 +326,34 @@ abstract class Zend_Captcha_Word extends Zend_Captcha_Base
|
||||
*/
|
||||
public function isValid($value, $context = null)
|
||||
{
|
||||
$name = $this->getName();
|
||||
if (!isset($context[$name]['input'])) {
|
||||
if (!is_array($value) && !is_array($context)) {
|
||||
$this->_error(self::MISSING_VALUE);
|
||||
return false;
|
||||
}
|
||||
$value = strtolower($context[$name]['input']);
|
||||
$this->_setValue($value);
|
||||
if (!is_array($value) && is_array($context)) {
|
||||
$value = $context;
|
||||
}
|
||||
|
||||
if (!isset($context[$name]['id'])) {
|
||||
$name = $this->getName();
|
||||
|
||||
if (isset($value[$name])) {
|
||||
$value = $value[$name];
|
||||
}
|
||||
|
||||
if (!isset($value['input'])) {
|
||||
$this->_error(self::MISSING_VALUE);
|
||||
return false;
|
||||
}
|
||||
$input = strtolower($value['input']);
|
||||
$this->_setValue($input);
|
||||
|
||||
if (!isset($value['id'])) {
|
||||
$this->_error(self::MISSING_ID);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_id = $context[$name]['id'];
|
||||
if ($value !== $this->getWord()) {
|
||||
$this->_id = $value['id'];
|
||||
if ($input !== $this->getWord()) {
|
||||
$this->_error(self::BAD_CAPTCHA);
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user