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.

31 lines
764 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. * @version SVN: $Id$
  9. * @filesource $URL$
  10. */
  11. class CaptchaValidator extends Validator
  12. {
  13. const WRONG_CODE = 'is_empty';
  14. protected $templates = array(self::WRONG_CODE => 'Entered code wrong');
  15. public function isValid($value, $context = null)
  16. {
  17. if (!$context || !isset($context['ctoken']) || !isset($context['ccode'])) {
  18. $this->error();
  19. return false;
  20. }
  21. $captcha = new Captcha();
  22. if ($captcha->checkCode($context['ctoken'], $context['ccode'])) {
  23. return true;
  24. }
  25. $this->error();
  26. return false;
  27. }
  28. }