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


PHP Captcha::enabled方法代码示例

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


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

示例1: render

 /**
  * Wrapper for captcha rendering.
  *
  * Allows conditional ignoring of captcha rendering if skipped in the config.
  *
  * @param Gdn_Controller $controller
  * @return null;
  */
 public static function render($controller)
 {
     if (!Captcha::enabled()) {
         return null;
     }
     // Hook to allow rendering of captcha form
     $controller->fireAs('captcha')->fireEvent('render');
     return null;
 }
开发者ID:R-J,项目名称:vanilla,代码行数:17,代码来源:class.captcha.php

示例2: insertForBasic

 /**
  * To be used for basic registration, and captcha registration.
  *
  * @param array $FormPostValues
  * @param bool $CheckCaptcha
  * @param array $Options
  * @return bool|int|string
  * @throws Exception
  */
 public function insertForBasic($FormPostValues, $CheckCaptcha = true, $Options = [])
 {
     $RoleIDs = RoleModel::getDefaultRoles(RoleModel::TYPE_MEMBER);
     if (!is_array($RoleIDs) || count($RoleIDs) == 0) {
         throw new Exception(t('The default role has not been configured.'), 400);
     }
     if (val('SaveRoles', $Options)) {
         $RoleIDs = val('RoleID', $FormPostValues);
     }
     $UserID = false;
     // Define the primary key in this model's table.
     $this->defineSchema();
     // Add & apply any extra validation rules.
     if (val('ValidateEmail', $Options, true)) {
         $this->Validation->applyRule('Email', 'Email');
     }
     // TODO: DO I NEED THIS?!
     // Make sure that the checkbox val for email is saved as the appropriate enum
     if (array_key_exists('ShowEmail', $FormPostValues)) {
         $FormPostValues['ShowEmail'] = forceBool($FormPostValues['ShowEmail'], '0', '1', '0');
     }
     if (array_key_exists('Banned', $FormPostValues)) {
         $FormPostValues['Banned'] = forceBool($FormPostValues['Banned'], '0', '1', '0');
     }
     $this->addInsertFields($FormPostValues);
     if ($this->validate($FormPostValues, true) === true) {
         $Fields = $this->Validation->validationFields();
         // All fields on the form that need to be validated (including non-schema field rules defined above)
         $Username = val('Name', $Fields);
         $Email = val('Email', $Fields);
         $Fields = $this->Validation->schemaValidationFields();
         // Only fields that are present in the schema
         $Fields['Roles'] = $RoleIDs;
         unset($Fields[$this->PrimaryKey]);
         // If in Captcha registration mode, check the captcha value.
         if ($CheckCaptcha && Captcha::enabled()) {
             $captchaIsValid = Captcha::validate();
             if ($captchaIsValid !== true) {
                 $this->Validation->addValidationResult('Garden.Registration.CaptchaPublicKey', 'The captcha was not completed correctly. Please try again.');
                 return false;
             }
         }
         if (!$this->validateUniqueFields($Username, $Email)) {
             return false;
         }
         // Check for spam.
         if (val('ValidateSpam', $Options, true)) {
             $ValidateSpam = $this->validateSpamRegistration($FormPostValues);
             if ($ValidateSpam !== true) {
                 return $ValidateSpam;
             }
         }
         // Define the other required fields:
         $Fields['Email'] = $Email;
         // And insert the new user
         $UserID = $this->insertInternal($Fields, $Options);
         if ($UserID > 0 && !val('NoActivity', $Options)) {
             $ActivityModel = new ActivityModel();
             $ActivityModel->save(['ActivityUserID' => $UserID, 'ActivityType' => 'Registration', 'HeadlineFormat' => t('HeadlineFormat.Registration', '{ActivityUserID,You} joined.'), 'Story' => t('Welcome Aboard!')], false, ['GroupBy' => 'ActivityTypeID']);
         }
     }
     return $UserID;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:72,代码来源:class.usermodel.php


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