32 lines
1.3 KiB
PHP
32 lines
1.3 KiB
PHP
<?php
|
|
/**+
|
|
* Class qui vérfie si l'utilisateur est un robot (Google reCAPTCHA v3)
|
|
* Source: https://phpkishan.blogspot.com/2018/11/recaptcha-v3-example-in-php.html
|
|
* Modifié par Jean-Sébastien Proulx
|
|
* Date: 2020-07-07
|
|
* Time: 17:03
|
|
*/
|
|
namespace clsRecaptcha;
|
|
|
|
define('RECAPTCHA_SITE_KEY', '6LeSZ7EZAAAAAIy1H6ZaRS3sqt_ZP2Kgz5EzIgav'); // define here reCAPTCHA_site_key
|
|
define('RECAPTCHA_SECRET_KEY', '6LeSZ7EZAAAAAFjaox-SS0Rhb5Rn4vIXQHczSJYS'); // define here reCAPTCHA_secret_key
|
|
|
|
class clsRecaptcha {
|
|
public function fxGetCaptcha($strResponse) {
|
|
$data = array(
|
|
'secret' => RECAPTCHA_SECRET_KEY,
|
|
'response' => $strResponse
|
|
);
|
|
$sesVerify = curl_init();
|
|
curl_setopt($sesVerify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
|
|
curl_setopt($sesVerify, CURLOPT_POST, true);
|
|
curl_setopt($sesVerify, CURLOPT_POSTFIELDS, http_build_query($data));
|
|
curl_setopt($sesVerify, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($sesVerify, CURLOPT_RETURNTRANSFER, true);
|
|
$objResponse = curl_exec($sesVerify);
|
|
$objResponse = json_decode($objResponse);
|
|
curl_close($sesVerify);
|
|
//echo "<pre>"; print_r($objResponse); echo "</pre>";x
|
|
return $objResponse;
|
|
}
|
|
} |