Makes a request to recaptcha service and checks if recaptcha field is valid.

@param string $challengeField
@param string $responseField
@return boolean
11038
protected function check($challengeField, $responseField) {
        
        $server = $this->request->server;
        
        $data = array(
            'privatekey' => $this->options['private_key'],
            'remoteip'   =>  $server->get('REMOTE_ADDR') ,
            'challenge'  => $challengeField,
            'response'   => $responseField     
        );
        
        $curl = curl_init($this->options['verify_url']);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
        curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
        curl_setopt($curl, CURLOPT_USERAGENT, 'reCAPTCHA/PHP');
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl, CURLOPT_HEADER, true);
        $response = curl_exec($curl);

        $response = explode("\r\n\r\n", $response, 2);

        return (isset($response[1]) && preg_match('/true/', $response[1]));       
    }
230043
public function respondToAuthChallenge($challengeName, array $challengeResponses, $session)
    {
        try {
            $response = $this->client->respondToAuthChallenge([
                'ChallengeName' => $challengeName,
                'ChallengeResponses' => $challengeResponses,
                'ClientId' => $this->appClientId,
                'Session' => $session,
            ]);

            return $this->handleAuthenticateResponse($response->toArray());
        } catch (CognitoIdentityProviderException $e) {
            throw CognitoResponseException::createFromCognitoException($e);
        }
    }
958995
private function verifyRecaptcha()
    {
        if (!isset($this->recaptchaClientKey)) {
            return true;
        }

        $recaptcha = $this->request->input('g-recaptcha-response');
        if (!$recaptcha) {
            return false;
        }

        $request = new Request();
        $request->setUrl('https://www.google.com/recaptcha/api/siteverify');
        $request->setBody([
            'secret' => $this->recaptchaClientSecret,
            'response' => $recaptcha,
            'remoteip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null
        ]);

        $client = Client::getInstance();

        $response = $client->post($request);
        if (!$response->getBody()) {
            return false;
        }

        $responseData = json_decode($response->getBody(), true);
        return isset($responseData['success']) && $responseData['success'];
    }
1041533
public function html()
    {
        if (!$this->getPublicKey()) {
            throw new Exception('You must set public key provided by reCaptcha');
        }

        $error = ($this->getError() ? '&amp;error=' . $this->getError() : null);

        $theme = null;

        // If user specified a reCaptcha theme, output it as one of the options
        if ($this->theme) {
            $theme = '<script> var RecaptchaOptions = {theme: "' . $this->theme . '"};</script>';
        }

        return $theme . '<script type="text/javascript" src="' . self::SERVER . '/challenge?k=' . $this->getPublicKey() . $error . '"></script>

        <noscript>
            <iframe src="' . self::SERVER . '/noscript?k=' . $this->getPublicKey() . $error . '" height="300" width="500" frameborder="0"></iframe><br/>
            <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
            <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
        </noscript>';
    }
536463
static public function verifyCaptcha($token=null, $code)
    {
        if (!$token) {
            $token = isset($_POST['_form_token']) ? $_POST['_form_token'] : null;
        }
        
        return Captcha::instance()->verify($token, $code);
    }
666189
public function recaptchaSiteKey()
    {
        $recaptcha = $this->apiConfig('google.recaptcha');

        if (!empty($recaptcha['public_key'])) {
            return $recaptcha['public_key'];
        } elseif (!empty($recaptcha['key'])) {
            return $recaptcha['key'];
        }

        return null;
    }
782966
function redirectToLoginOnBadRecaptcha(req, res, next) {
    if (!req.requireRecaptcha || req.isValidRecaptcha.success) {
        next();
    } else {
        req.session.error = 'Authentication failed. Bad captcha';
        loginBruteForce.ban(req);
        res.redirect('login');
    }
}
842022
public function load(Request $request, Response $response) {
        $config = $this->app->package('global')->service('captcha-main');

        //if no config
        if(!$config
            || !isset($config['token'], $config['secret'])
            || $config['token'] === '<GOOGLE CAPTCHA TOKEN>'
            || $config['secret'] === '<GOOGLE CAPTCHA SECRET>'
        )
        {
            return $this;
        }

        //render the key
        $key = $config['token'];

        $response->setResults('captcha', $key);

        return $this;
    }
483684
private function captchaResponse($response)
    {
        $errors = ['g-recaptcha-response' => ['Oops, something went wrong']];
        foreach ($response->getErrorCodes() as $k => $code) {
            if ($code == 'missing-input-response') {
                $code = 'Please confirm you are not a robot.';
            }
            $errors['g-recaptcha-response'][$k] = $code;
        }

        return new JsonResponse($errors, 422);
    }
543193
public function check(Request $request, Response $response) {
        $actual = $request->getStage('g-recaptcha-response');
        $config = $this->app->package('global')->service('captcha-main');

        //if no config
        if(!$config
            || !isset($config['token'], $config['secret'])
            || $config['token'] === '<GOOGLE CAPTCHA TOKEN>'
            || $config['secret'] === '<GOOGLE CAPTCHA SECRET>'
        )
        {
            //let it pass
            $this->app->subflow($this->yes, $request, $response);
            return $this;
        }

        $result = CurlHandler::i()
            ->setUrl(self::END_POINT)
            ->verifyHost(false)
            ->verifyPeer(false)
            ->setPostFields(http_build_query(array(
                'secret' => $config['secret'],
                'response' => $actual
            )))
            ->getJsonResponse();

        if(!isset($result['success']) || !$result['success']) {
            //prepare to error
            $message = $this->app->package('global')->translate(static::ATTACK);
            $response->setError(true, $message);

            //and trigger a subflow
            $this->app->subflow($this->no, $request, $response);
            return $this;
        }

        //it passed
        $this->app->subflow($this->yes, $request, $response);
        return $this;
    }
930626
public function validate($field, $input, array $params = array())
    {
        try {
            if ($input == '' || empty($params['0'])) {
                return false;
            }
            $params = $params['0'];
            if (empty($params['gcs_access_key']) || empty($params['gcs_secret_key'])) {
                return false;
            }
            
            $client = m62Gcs::getRemoteClient($params['gcs_access_key'], $params['gcs_secret_key']);
            $client->listBuckets();
            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
723538
public function check(Request $request)
    {
        $this->response = $this->verify($request->input('g-recaptcha-response'), $request->ip());

        return $this;
    }
716105
public function verify($response)
    {
        if (!$this->secretKey) {
            throw new Exception('Missing secret key');
        }

        $params = array(
            'secret' => $this->secretKey,
            'response' => $response,
        );

        if ($this->ip !== null) {
            $params['remoteip'] = $this->ip;
        }

        $this->httpClient->setUri(self::VERIFY_SERVER);
        $this->httpClient->setParameterPost($params);

        if ($this->options) {
            $this->httpClient->setOptions($this->options);
        }

        $this->httpClient->setMethod('POST');
        $response = $this->httpClient->send();

        return new CaptchaResponse($response);
    }
882720
public function recaptchaSecretKey()
    {
        $recaptcha = $this->apiConfig('google.recaptcha');

        if (!empty($recaptcha['private_key'])) {
            return $recaptcha['private_key'];
        } elseif (!empty($recaptcha['secret'])) {
            return $recaptcha['secret'];
        }

        return null;
    }
1194971
public function validate($field, $input, array $params = array())
    {
        try {
            if ($input == '' || empty($params['0'])) {
                return false;
            }
            $params = $params['0'];
            if (empty($params['rcf_username']) || empty($params['rcf_api'])) {
                return false;
            }
            
            return m62Rcf::getRemoteClient($params, false);
        } catch (\Exception $e) {
            return false;
        }
    }
513478
protected function validateInput(array $context, array $requiredFields = [])
    {
        foreach ($requiredFields as $requiredField) {
            if (empty($context[$requiredField])) {
                throw new InvalidArgumentException('Missing required field ' . $requiredField);
            }
        }
        return true;
    }
501896
def recaptcha_tags(options = {})
      if options.key?(:stoken)
        raise(RecaptchaError, "Secure Token is deprecated. Please remove 'stoken' from your calls to recaptcha_tags.")
      end
      if options.key?(:ssl)
        raise(RecaptchaError, "SSL is now always true. Please remove 'ssl' from your calls to recaptcha_tags.")
      end

      noscript = options.delete(:noscript)

      html, tag_attributes, fallback_uri = Recaptcha::ClientHelper.recaptcha_components(options)
      html << %(<div #{tag_attributes}></div>\n)

      if noscript != false
        html << <<-HTML
          <noscript>
            <div>
              <div style="width: 302px; height: 422px; position: relative;">
                <div style="width: 302px; height: 422px; position: absolute;">
                  <iframe
                    src="#{fallback_uri}"
                    name="ReCAPTCHA"
                    style="width: 302px; height: 422px; border-style: none; border: 0; overflow: hidden;">
                  </iframe>
                </div>
              </div>
              <div style="width: 300px; height: 60px; border-style: none;
                bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px;
                background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px;">
                <textarea id="g-recaptcha-response" name="g-recaptcha-response"
                  class="g-recaptcha-response"
                  style="width: 250px; height: 40px; border: 1px solid #c1c1c1;
                  margin: 10px 25px; padding: 0px; resize: none;">
                </textarea>
              </div>
            </div>
          </noscript>
        HTML
      end

      html.respond_to?(:html_safe) ? html.html_safe : html
    end