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


PHP ReCaptcha::recaptcha_check_answer方法代码示例

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


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

示例1: validateUserInput

 public function validateUserInput()
 {
     if (Str::nullOrEmpty($this->name)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'name'), 'name');
     }
     if (Str::nullOrEmpty($this->contents)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'contents'), 'contents');
     }
     if (Str::nullOrEmpty($this->blogId)) {
         $this->addError("generic.error.missingRequiredField", array('field' => 'blogId'));
     }
     // check captcha
     if (!Str::nullOrEmpty($this->captchaChallenge)) {
         $resp = ReCaptcha::recaptcha_check_answer(self::CAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $this->captchaChallenge, $this->captchaResponse);
         if ($resp->is_valid) {
             // DAY is in milliseconds, convert to seconds and multiply by 14 for 2 weeks
             $expireTime = time() + GlobalConstants::DAY / 10 * 14;
             setcookie(self::CAPTCHA_COOKIE_NAME, true, $expireTime, '/');
         } else {
             $this->addError($resp->error);
         }
     } elseif (!isset($_COOKIE[self::CAPTCHA_COOKIE_NAME])) {
         $this->addError("Captcha does not appear to be functioning properly, please contact site administrator.");
     }
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:25,代码来源:PostBlogComment.php

示例2: check

 /**
  * Check if a captcha value is valid
  *
  * @access  public
  * @return  bool    return validity of captcha value
  */
 function check()
 {
     $recaptcha = jaws()->request->fetch(array('recaptcha_challenge_field', 'recaptcha_response_field'), 'post');
     if ($recaptcha['recaptcha_response_field']) {
         $privatekey = $GLOBALS['app']->Registry->fetch('reCAPTCHA_private_key', 'Policy');
         $objReCaptcha = new ReCaptcha();
         $objReCaptcha->recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha['recaptcha_challenge_field'], $recaptcha['recaptcha_response_field']);
         return $objReCaptcha->is_valid;
     }
     return false;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:17,代码来源:ReCaptcha.php


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