Gets or sets the number of valid Captcha responses for this session.
integer Core_Captcha::valid_count( [ integer $new_count = null , boolean $invalid = bool false ] )
参数列表
参数 类型 描述 默认值 $new_count
integer
New counter value null $invalid
boolean
Trigger invalid counter (for internal use only) bool false
integer
counter valuepublic static function valid_count($new_count = null, $invalid = false)
{
// Pick the right session to use
$session = Captcha::$valid_countname;
// Update counter
if (null!==$new_count)
{
$new_count = (int)$new_count;
// Reset counter = delete session
if ( $new_count < 1 )
{
Session::instance()->delete($session);
}
// Set counter to new value
else
{
Session::instance()->set($session, (int)$new_count);
}
// Return new count
return (int)$new_count;
}
// Return current count
return (int)Session::instance()->get($session);
}