You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
721 B

13 years ago
13 years ago
  1. <?php
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage validator
  7. * @since 2010-04-26
  8. */
  9. class CaptchaValidator extends Validator
  10. {
  11. const WRONG_CODE = 'is_empty';
  12. protected $templates = array(self::WRONG_CODE => 'Entered code wrong');
  13. public function isValid($value, $context = null)
  14. {
  15. if (!$context || !isset($context['ctoken']) || !isset($context['ccode'])) {
  16. $this->error();
  17. return false;
  18. }
  19. $captcha = new Captcha();
  20. if ($captcha->checkCode($context['ctoken'], $context['ccode'])) {
  21. return true;
  22. }
  23. $this->error();
  24. return false;
  25. }
  26. }