Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 /**
  * Get captcha HTML code
  *
  * @return string
  */
 public function toHtml()
 {
     return $this->reCaptchaModel->recaptchaGetHtml();
 }