/**
* Validates the input to see if it matches the generated code.
* @param string user input
* @param boolean whether the comparison should be case-sensitive
* @return whether the input is valid
*/
public function validate($input,$caseSensitive)
{
$code=$this->getVerifyCode();
$valid=$caseSensitive?($input===$code):!strcasecmp($input,$code);
$session=Yii::app()->session;
$session->open();
$name=$this->getSessionKey().'count';
if (Yii::app()->getRequest()->isAjaxRequest == false)//可能是漏洞
{
$session[$name]=$session[$name]+1;
}
if($session[$name]>$this->testLimit && $this->testLimit>0)
$this->getVerifyCode(true);
return $valid;
}
There are some limitations of CActiveForm regarding to its AJAX validation support. First, it does not validate with file upload fields. Second, it should not be used to perform validations that may cause server-side state change. For example, it is not suitable to perform CAPTCHA validation done by CCaptchAction because each validation request will increase the number of tests by one. Third, it is not designed to work with tabular data input for the moment.
我现在就是遇到你说的这个问题。increase the number of tests by one,不过我会参考开心的方式,只能用一次。ajax验证一次,图片刷新一次。另外你说的方法,我周一会尝试。我一开始用的1.1.2-dev。现在所有工作在svn上做的,周一回单位去尝试更新。