Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // URL pour générer des clés: https://www.google.com/recaptcha/admin
- // Affichage du bouton :
- // <script src='https://www.google.com/recaptcha/api.js'></script>
- // <div class="g-recaptcha" data-sitekey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"></div>
- // Vérification :
- $recaptcha_ok = -1;
- if (!empty($_REQUEST['g-recaptcha-response']))
- {
- $recaptcha_ok = 0;
- $url = 'https://www.google.com/recaptcha/api/siteverify';
- $myvars = 'secret=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY&response='.htmlspecialchars($_POST['g-recaptcha-response'],ENT_QUOTES);
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $response = curl_exec($ch);
- $json = json_decode($response);
- if ($json->success)
- $recaptcha_ok = 1;
- }
- // Si le reCAPTCHA est validé, alors $recaptcha_ok = 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement