当前位置: 首页>>代码示例>>PHP>>正文


PHP Captcha::checkRequirements方法代码示例

本文整理汇总了PHP中yii\captcha\Captcha::checkRequirements方法的典型用法代码示例。如果您正苦于以下问题:PHP Captcha::checkRequirements方法的具体用法?PHP Captcha::checkRequirements怎么用?PHP Captcha::checkRequirements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\captcha\Captcha的用法示例。


在下文中一共展示了Captcha::checkRequirements方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderImage

 /**
  * Renders the CAPTCHA image.
  * @param string $code the verification code
  * @return string image contents
  */
 protected function renderImage($code)
 {
     if (Captcha::checkRequirements() === 'gd') {
         return $this->renderImageByGD($code);
     } else {
         return $this->renderImageByImagick($code);
     }
 }
开发者ID:uxff,项目名称:yii2-advanced,代码行数:13,代码来源:CaptchaAction.php

示例2: renderImage

 /**
  * Renders the CAPTCHA image.
  * @param string $code the verification code
  * @return string image contents
  * @throws InvalidConfigException if imageLibrary is not supported
  */
 protected function renderImage($code)
 {
     if (isset($this->imageLibrary)) {
         $imageLibrary = $this->imageLibrary;
     } else {
         $imageLibrary = Captcha::checkRequirements();
     }
     if ($imageLibrary === 'gd') {
         return $this->renderImageByGD($code);
     } elseif ($imageLibrary === 'imagick') {
         return $this->renderImageByImagick($code);
     } else {
         throw new InvalidConfigException("Defined library '{$imageLibrary}' is not supported");
     }
 }
开发者ID:yiisoft,项目名称:yii2,代码行数:21,代码来源:CaptchaAction.php

示例3: createFormModel

 /**
  * A factory to create pre-configured form models. Only model class names
  * from the nineinchnick\usr\models namespace are allowed.
  * Sets scenario, password strength rules for models extending BasePasswordForm and attaches behaviors.
  *
  * @param  string $class    without the namespace
  * @param  string $scenario
  * @return Model
  */
 public function createFormModel($class, $scenario = null)
 {
     $namespacedClass = "\\nineinchnick\\usr\\models\\{$class}";
     /** @var Model */
     $form = new $namespacedClass();
     if ($scenario !== null) {
         $form->setScenario($scenario);
     }
     if ($form instanceof \nineinchnick\usr\models\BaseUsrForm) {
         $form->webUser = Yii::$app->user;
     }
     if ($form instanceof \nineinchnick\usr\models\BasePasswordForm) {
         $form->passwordStrengthRules = $this->passwordStrengthRules;
     }
     switch ($class) {
         default:
             break;
         case 'ProfileForm':
             $form->pictureUploadRules = $this->pictureUploadRules;
             if (!empty($this->profileFormBehaviors)) {
                 foreach ($this->profileFormBehaviors as $name => $config) {
                     $form->attachBehavior($name, $config);
                 }
             }
             // no break
         // no break
         case 'RecoveryForm':
             if ($this->captcha !== null && \yii\captcha\Captcha::checkRequirements()) {
                 $form->attachBehavior('captcha', ['class' => 'nineinchnick\\usr\\components\\CaptchaFormBehavior', 'ruleOptions' => $class == 'ProfileForm' ? ['on' => 'register'] : ['except' => ['reset', 'verify']]]);
             }
             break;
         case 'LoginForm':
             if ($this->loginFormBehaviors !== null && is_array($this->loginFormBehaviors)) {
                 foreach ($this->loginFormBehaviors as $name => $config) {
                     $form->attachBehavior($name, $config);
                 }
             }
             break;
         case 'AuthForm':
             $form->setValidProviders(array_keys(Yii::$app->get('authClientCollection')->clients));
             break;
     }
     return $form;
 }
开发者ID:rumatakira,项目名称:yii2-usr,代码行数:53,代码来源:Module.php

示例4: rules

 public function rules()
 {
     return array([['username'], 'required', 'message' => '请输入用户名'], [['username'], 'required', 'message' => '请输入密码'], [['username'], 'checkUserNameAndPassword'], [['password'], 'checkUserNameAndPassword'], [['verifyCode'], 'captcha', 'skipOnEmpty' => !Captcha::checkRequirements(), 'message' => '验证码不正确']);
 }
开发者ID:jaybril,项目名称:www.mimgpotea.com,代码行数:4,代码来源:AdminUserLoginForm.php


注:本文中的yii\captcha\Captcha::checkRequirements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。