Validator, captcha, form, #16

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@141 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
pzinovkin
2010-04-26 19:56:01 +00:00
parent 64c3cace88
commit c214b75d60
19 changed files with 660 additions and 9 deletions

View File

@ -0,0 +1,32 @@
<?php
/**
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Majestic
* @subpackage validator
* @since 2010-04-26
* @version SVN: $Id$
* @filesource $URL$
*/
class CaptchaValidator extends Validator
{
const WRONG_CODE = 'is_empty';
protected $templates = array(self::WRONG_CODE => 'Entered code wrong');
public function isValid($value, $context = null)
{
if (!$context || !isset($context['ctoken']) || !isset($context['ccode'])) {
$this->error();
return false;
}
$captcha = new Captcha();
if ($captcha->checkCode($context['ctoken'], $context['ccode'])) {
return true;
}
$this->error();
return false;
}
}