N
N
NikoB2012-04-08 12:58:17
Google
NikoB, 2012-04-08 12:58:17

Error in reCAPTCHA documentation?

The reCAPTCHA documentation on the Displaying reCAPTCHA Without Plugins page contains the captcha embed code:

<script type="text/javascript"
     src="http://www.google.com/recaptcha/api/challenge?k=your_public_key">
  </script>
  <noscript>
     <iframe src="http://www.google.com/recaptcha/api/noscript?k=your_public_key"
         height="300" width="500" frameborder="0"></iframe>
     <textarea name="recaptcha_challenge_field" rows="3" cols="40">
     </textarea>
     <input type="hidden" name="recaptcha_response_field"
         value="manual_challenge">
  </noscript>


There are two input elements:
a Textarea called recaptcha_challenge_field , you can see where the captcha is entered, but there is also an invisible input recaptcha_response_field .

But at the bottom of this code is signed:
recaptcha_challenge_field is a hidden field that describes the CAPTCHA which the user is solving. It corresponds to the "challenge" parameter required by the reCAPTCHA verification API.
recaptcha_response_field is a text field where the user enters their solution. It corresponds to the "response" parameter required by the reCAPTCHA verification API.

And now two questions - where is it right? where to report?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gleb Starkov, 2012-04-16
@colonel

Where do you see the error or problem here?
Both values ​​of these fields are needed when passing for validation.
Here we have, for example:
Client side (js):

recaptcha_c = $('#recaptcha_challenge_field').val();
recaptcha_r = $('#recaptcha_response_field').val();

And server side (php, small class method for working with recaptcha):
public static function check()
{
  if ( Ts_App::getConfig('recaptcha_enabled') ) {
      $recaptchaC = Request::getVar('recaptcha_c');
      $recaptchaR = Request::getVar('recaptcha_r');
      
      if ( empty ($recaptchaC) || empty ($recaptchaR) ) {
    return false;
      } else {
    $privkey = Ts_App::getConfig('recaptcha_priv_key');
    $remoteip = Request::getIp();
    
    if( $curl = curl_init() ) {
        curl_setopt($curl, CURLOPT_URL, 'http://www.google.com/recaptcha/api/verify');
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, "privatekey={$privkey}&remoteip={$remoteip}&challenge={$recaptchaC}&response={$recaptchaR}");
        $out = curl_exec($curl);
        if ( !$out ) {
            return false;
        } else {
            $responses = explode("\n", $out);
            if ( $responses[0] != 'true' ) {
                return false;
            }
        }
        
        curl_close($curl);
    }
    
    return true;
      }
  } else {
      return true;
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question