protected function _verify($code, $isTry)
{
if (!$this->session->has($this->_sessionVar)) {
throw new CaptchaException('captcha is not exist in server');
}
$sessionVar = $this->session->get($this->_sessionVar);
if ($isTry) {
if (isset($sessionVar['try_verified_time'])) {
$this->session->remove($this->_sessionVar);
throw new CaptchaException('captcha has been tried');
} else {
$sessionVar['try_verified_time'] = time();
$this->session->set($this->_sessionVar, $sessionVar);
}
} else {
$this->session->remove($this->_sessionVar);
}
if (time() - $sessionVar['created_time'] < $this->_minInterval) {
throw new CaptchaException('captcha verification is too frequency');
}
if (time() - $sessionVar['created_time'] > $sessionVar['ttl']) {
throw new CaptchaException('captcha is expired');
}
if (strtolower($sessionVar['code']) !== strtolower($code)) {
throw new CaptchaException('captcha is not match');
}
}