本文整理汇总了PHP中CCaptcha类的典型用法代码示例。如果您正苦于以下问题:PHP CCaptcha类的具体用法?PHP CCaptcha怎么用?PHP CCaptcha使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCaptcha类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rules
public function rules()
{
$rules = array(array('gs_id,login,password,re_password,email', 'filter', 'filter' => 'trim'), array('gs_id,login,password,re_password,email', 'required'), array('login', 'length', 'min' => Users::LOGIN_MIN_LENGTH, 'max' => Users::LOGIN_MAX_LENGTH), array('password', 'length', 'min' => Users::PASSWORD_MIN_LENGTH, 'max' => Users::PASSWORD_MAX_LENGTH), array('re_password', 'length', 'min' => Users::PASSWORD_MIN_LENGTH, 'max' => Users::PASSWORD_MAX_LENGTH), array('re_password', 'compare', 'compareAttribute' => 'password', 'message' => Yii::t('main', 'Поля «{compareAttribute}» и «{attribute}» не совпадают.')), array('email', 'email', 'message' => Yii::t('main', 'Введите корректный Email адрес.')), array('email', 'checkBadEmail'), array('login', 'checkLoginChars'), array('gs_id', 'gsIsExists'), array('login', 'loginUnique'));
// Captcha
$captcha = config('register.captcha.allow') && CCaptcha::checkRequirements();
if ($captcha) {
$rules[] = array('verifyCode', 'filter', 'filter' => 'trim');
$rules[] = array('verifyCode', 'required');
$rules[] = array('verifyCode', 'validators.CaptchaValidator');
}
// Prefix
if (config('prefixes.allow') && config('prefixes.length') > 0 && config('prefixes.count_for_list') > 0) {
$rules[] = array('prefix', 'filter', 'filter' => 'trim');
$rules[] = array('prefix', 'required');
$rules[] = array('prefix', 'checkPrefix');
}
// Referral program
if (config('referral_program.allow')) {
$rules[] = array('referer', 'filter', 'filter' => 'trim');
$rules[] = array('referer', 'length', 'allowEmpty' => TRUE, 'min' => Users::REFERER_MIN_LENGTH, 'max' => Users::REFERER_MAX_LENGTH);
$rules[] = array('referer', 'refererIsExists');
}
// Unique email
if (!config('register.multiemail')) {
$rules[] = array('email', 'emailUnique');
}
return $rules;
}
示例2: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
$rules = array(array('nombre,apellido,username,email,rolid, nivelid, activo', 'required'), array('activo', 'numerical', 'integerOnly' => true), array('activo', 'default', 'value' => 1), array('username', 'length', 'max' => 15, 'min' => 3), array('username', 'unique'), array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u'), array('password', 'length', 'max' => 128, 'min' => 4), array('password,verifyPassword', 'required'), array('password', 'compare', 'compareAttribute' => 'verifyPassword'), array('nombre, apellido', 'length', 'max' => 30), array('email', 'length', 'max' => 60), array('email', 'unique'), array('email', 'email'), array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements()), array('rolid, nivelid, dependid', 'length', 'max' => 11), array('id, username, password, nombre, apellido, email, rolid, nivelid, activo, dependid', 'safe', 'on' => 'search'));
return $rules;
}
示例3: rules
public function rules()
{
$obj = new CHtmlPurifier();
$obj->options = array('HTML.Allowed' => '');
$obj = array($obj, 'purify');
return array(array('verifyCode', 'captcha', 'allowEmpty' => !Yii::app()->user->isGuest || !CCaptcha::checkRequirements()), array('name, email, message', 'required', 'message' => '{attribute} должен быть заполнен'), array('email', 'email', 'message' => "Неправильно указан email"), array('name, email, message', 'filter', 'filter' => $obj));
}
示例4: rules
/**
* Declares the validation rules.
* The rules state that username and password are required,
* and password needs to be authenticated.
*/
public function rules()
{
$obj = new CHtmlPurifier();
$obj->options = array('HTML.Allowed' => '');
$obj = array($obj, 'purify');
return array(array('verifyCode', 'captcha', 'allowEmpty' => !Yii::app()->user->isGuest || !CCaptcha::checkRequirements()), array('email, password', 'required'), array('rememberMe', 'boolean'), array('password', 'authenticate'), array('email, verifyCode', 'filter', 'filter' => $obj));
}
示例5: behaviors
public function behaviors()
{
if (Yii::app()->controller->module->captcha !== null && CCaptcha::checkRequirements()) {
return array('captcha' => array('class' => 'CaptchaFormBehavior', 'ruleOptions' => array('except' => 'reset,verify')));
}
return array();
}
示例6: rules
public function rules()
{
$rules = parent::rules();
/* FIXME: As soon as i grasp how i can dynamically add variables to a
class in PHP, i will enable this code snippet for flexibility:
$profile = new YumProfile;
$profile_rules = $profile->rules();
foreach($profile_rules as $rule)
if(isset($rule[0]) && is_string($rule[0]))
$this->${$rule[0]} = '';
$rules = array_merge($rules, $profile->rules()); */
$rules[] = array('username', 'required');
$rules[] = array('password, verifyPassword', 'required');
$rules[] = array('password', 'compare',
'compareAttribute'=>'verifyPassword',
'message' => Yum::t("Retype password is incorrect."));
if(Yum::module('registration')->enableCaptcha)
$rules[] = array('verifyCode', 'captcha',
'allowEmpty'=>CCaptcha::checkRequirements());
return $rules;
}
示例7: isCaptchaEnabled
public function isCaptchaEnabled()
{
$module = Yii::app()->getModule('user');
if (!$module->showCaptcha || !CCaptcha::checkRequirements() || $this->disableCaptcha) {
return false;
}
return true;
}
示例8: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
$obj = new CHtmlPurifier();
$obj->options = array('HTML.Allowed' => '');
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(array('verifyCode', 'captcha', 'allowEmpty' => !Yii::app()->user->isGuest || !CCaptcha::checkRequirements()), array('email', 'email', 'message' => "Email неверный"), array('email', 'unique', 'message' => 'Email уже зарегистрирован!'), array('name, password, email ', 'required', 'message' => '{attribute} обязательно для заполнения!'), array('summ_buy, summ_exit, summ_limit, activate_email, activate_phone', 'numerical', 'integerOnly' => true), array('name, password, password_repeat, email, phone, role', 'length', 'max' => 125, 'message' => '{attribute} длинна строки не должна превышшать 125 символов'), array('name, email, phone', 'filter', 'filter' => array($obj, 'purify')));
}
示例9: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
$obj = new CHtmlPurifier();
$obj->options = array('HTML.Allowed' => 'a[href],b,i,u,p,br,div');
//http://htmlpurifier.org/live/configdoc/plain.html#HTML.Allowed
return array(array('priority_id', 'numerical', 'integerOnly' => true, 'on' => 'add,update,moderate,authorize'), array('priority_id', 'numerical', 'min' => 1, 'max' => 3), array('title, content_type_id', 'required', 'on' => 'add,update'), array('content_type_id,country_id', 'numerical', 'integerOnly' => true, 'on' => 'add,update'), array('title', 'length', 'max' => 240, 'on' => 'add,update'), array('user_comment', 'type', 'type' => 'string', 'on' => 'add,update'), array('user_comment', 'filter', 'filter' => array($obj, 'purify')), array('image,image_source', 'safe', 'on' => 'add,update'), array('image_url', 'url', 'on' => 'add,update'), array('text', 'safe', 'on' => 'add,update'), array('video', 'safe', 'on' => 'add,update'), array('content_type_id', 'validateContentType', 'on' => 'add,update'), array('user_position_ymd,user_position_hour,user_position_minute', 'safe', 'on' => 'add,update'), array('user_position_anydatetime', 'validateDateTime', 'on' => 'add,update'), array('disabled,deleted', 'numerical', 'integerOnly' => true, 'on' => 'moderate,authorize'), array('tag, category', 'length', 'max' => 240), array('approved', 'numerical', 'integerOnly' => true, 'on' => 'moderate'), array('moderator_comment', 'length', 'max' => 240, 'on' => 'moderate'), array('approved', 'validateApprobation', 'on' => 'moderate'), array('authorized', 'numerical', 'integerOnly' => true, 'on' => 'authorize'), array('authorized', 'validateAuthorization', 'on' => 'authorize'), array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements(), 'on' => 'add'), array('id, user_id, user_ip, user_comment, title, urn, content_type_id, approved, authorized, disabled, deleted, content_id, country_id, moderator_id, moderator_ip, moderator_comment, time_submitted, time_moderated, priority_id, show_time,position', 'safe', 'on' => 'manage'), array('username, title, deleted, urn, tag, content_type_id, country_id, time_submitted, priority_id, show_time', 'safe', 'on' => 'history'));
}
示例10: rules
public function rules()
{
$rules = array(array('username, password, verifyPassword, email', 'required'), array('username', 'length', 'max' => 20, 'min' => 3, 'message' => UserModule::t("Incorrect username (length between 3 and 20 characters).")), array('password', 'length', 'max' => 128, 'min' => 4, 'message' => UserModule::t("Incorrect password (minimal length 4 symbols).")), array('email', 'email'), array('username', 'unique', 'message' => UserModule::t("This user's name already exists.")), array('email', 'unique', 'message' => UserModule::t("This user's email address already exists.")), array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u', 'message' => UserModule::t("Incorrect symbols (A-z0-9).")));
if (!(isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form')) {
array_push($rules, array('verifyCode', 'CaptchaExtendedValidator', 'allowEmpty' => !CCaptcha::checkRequirements() || !extension_loaded('gd')));
}
array_push($rules, array('verifyPassword', 'compare', 'compareAttribute' => 'password', 'message' => UserModule::t("Retype Password is incorrect.")));
return $rules;
}
示例11: rules
public function rules()
{
// add, edit - действия администратора
// register, update - действия пользователя
if ($this->rules) {
return $this->rules;
}
return array(array('login', 'filter', 'filter' => 'strtolower'), array('login, password, password_repeat', 'filter', 'filter' => 'trim'), array('login, password', 'required', 'on' => 'add'), array('login, email, password', 'length', 'max' => 32, 'min' => 5, 'encoding' => 'UTF-8'), array('login, email', 'unique'), array('email', 'required'), array('displayname', 'required', 'on' => 'update'), array('login', 'match', 'pattern' => '/^[a-z]+[a-z0-9-]*[a-z0-9]+$/', 'message' => Yii::t('cms', '{attribute} can only contain letters and numbers. And it can not start with a digit or sign')), array('password', 'match', 'pattern' => '/^[[:graph:]]*$/', 'message' => Yii::t('cms', '{attribute} can only contain letters and numbers')), array('email', 'email'), array('password', 'compare', 'compareAttribute' => 'password_repeat'), array('password, password_repeat, authcode', 'safe'), array('login', 'unsafe', 'on' => array('edit', 'update')), array('displayname', 'length', 'max' => 64, 'encoding' => 'UTF-8'), array('active, askfill, show_email, send_message', 'unsafe', 'on' => array('register', 'view')), array('active, askfill, captcha, agreed', 'unsafe', 'on' => array('update', 'view')), array('active, askfill, agreed', 'boolean'), array('show_email, send_message', 'safe'), array('extra_fields', 'FieldsValidator', 'config' => User::extraFields()), array('captcha', 'captcha', 'on' => 'register', 'allowEmpty' => !CCaptcha::checkRequirements() || !Yii::app()->user->isGuest, 'captchaAction' => 'site/captcha'), array('password, password_repeat, captcha', 'unsafe', 'on' => 'view'), array('timezone', 'safe'), array('_roles', 'safe'));
}
示例12: rules
public function rules()
{
$rules = array(array('email, password', 'required'), array('rememberMe', 'boolean'), array('password', 'authenticate'));
$cookieInfo = zmf::getCookie('checkWithCaptcha');
if ($cookieInfo == '1') {
$rules[] = array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements());
}
return $rules;
}
示例13: rules
/**
* Declares the validation rules.
*/
public function rules()
{
$rules = CMap::mergeArray(parent::rules(), array(array('textPassword, verifyPassword, verifyEmail, verifyCode', 'required'), array('textPassword', 'length', 'max' => 128, 'min' => 6, 'message' => UserModule::t("Incorrect password (minimal length 6 symbols).")), array('verifyPassword', 'compare', 'compareAttribute' => 'textPassword', 'message' => UserModule::t("Retype Password is incorrect.")), array('verifyEmail', 'compare', 'compareAttribute' => 'email', 'message' => UserModule::t("Retype Email is incorrect."))));
if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
return $rules;
} else {
array_push($rules, array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements()));
}
return $rules;
}
示例14: rules
/**
* Declares the validation rules.
*/
public function rules() {
return array(
// name, email, subject and body are required
array('name, email, subject, body', 'required'),
// email has to be a valid email address
array('email', 'email'),
// verifyCode needs to be entered correctly
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
);
}
示例15: rules
public function rules()
{
$rules = array(array('code, honour', 'required'), array('code', 'checkCode'), array('honour', 'checkHonour'), array('comment', 'checkComment'), array('url', 'checkUrl'), array('content', 'checkContent'), array('uploadedfile', 'file', 'allowEmpty' => true, 'maxSize' => 1024 * Helpers::getYiiParam('uploadMaxSize'), 'tooLarge' => 'The file was too large. Please upload a smaller file. The maximum size allowed is ' . Helpers::getYiiParam('uploadMaxSize') . ' KiB.'));
// FIXME - I should probably use a scenario for this. Must check!
if ($this->byteacher) {
$rules[] = array('verifyCode', 'safe');
} else {
$rules[] = array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements(), 'captchaAction' => 'site/captcha');
}
return $rules;
}