예제 #1
0
 /**
  * Check value with rule
  * Returns:
  *    - true if rule passed.
  *    - false if value doesn`t match the rule.
  *
  * @param mixed $value
  * @return bool
  */
 public function check($value)
 {
     $reCaptcha = \Magelight\Webform\Models\Captcha\ReCaptcha::forge();
     $request = \Magelight\Http\Request::getInstance();
     $challenge = $request->getPost(\Magelight\Webform\Models\Captcha\ReCaptcha::CHALLENGE_INDEX);
     $response = $request->getPost(\Magelight\Webform\Models\Captcha\ReCaptcha::RESPONSE_INDEX);
     return $reCaptcha->recaptchaCheckAnswer($_SERVER['HTTP_HOST'], $challenge, $response)->is_valid;
 }
예제 #2
0
 /**
  * Get captcha HTML code
  *
  * @return string
  */
 public function toHtml()
 {
     return $this->reCaptchaModel->recaptchaGetHtml();
 }