* @since Version 1.0 */ class cGoogleReCaptcha { // https://www.google.com/recaptcha/admin/ << create site and get site key, secret key // Site key enters in js ( tpl where is captcha ) // secret key is used when getting response const SITE_KEY = "6LcEvekUAAAAAGY6BVihUPnPtViJkF-MwVd6hCKS"; public $SECRET_KEY = "6LcEvekUAAAAAEqWlHXzEQTwBvRt_yn9EAWxd-0Q"; public $url = 'https://www.google.com/recaptcha/api/siteverify'; /** * Class constructor */ public function __construct() { } public function checkCaptcha($gReCaptchaResponse) { $response = file_get_contents("{$this->url}?secret={$this->SECRET_KEY}&response={$gReCaptchaResponse}&remoteip={$_SERVER['REMOTE_ADDR']}"); $data = json_decode($response); if (isset($data->success) && $data->success == true) return true; return false; } }