1
1
<?php
2
+
2
3
/**
3
4
* Created by Alex Zeng
4
5
* 2019-06-25
@@ -40,7 +41,7 @@ public static function verify($secret_key, $break_msg = null, $recaptcha_score =
40
41
* @param [type] $g_recaptcha_response
41
42
* @return void
42
43
*/
43
- public static function result ($ secret_key , $ g_recaptcha_response , $ recaptcha_score= 0.5 )
44
+ public static function result ($ secret_key , $ g_recaptcha_response , $ recaptcha_score = 0.5 )
44
45
{
45
46
$ google_recaptcha_uri = 'https://www.google.com/recaptcha/api/siteverify ' ;
46
47
@@ -53,6 +54,7 @@ public static function result($secret_key, $g_recaptcha_response, $recaptcha_sco
53
54
curl_setopt_array ($ curl , [
54
55
CURLOPT_RETURNTRANSFER => true ,
55
56
CURLOPT_POST => true ,
57
+ CURLOPT_SSL_VERIFYPEER => false ,
56
58
CURLOPT_URL => $ google_recaptcha_uri ,
57
59
CURLOPT_POSTFIELDS => [
58
60
'secret ' => $ secret_key ,
@@ -73,7 +75,7 @@ public static function result($secret_key, $g_recaptcha_response, $recaptcha_sco
73
75
74
76
if (!$ response || $ response ->success == false ) {
75
77
return false ;
76
- } else if ( isset ($ response ->score ) && $ response ->score < $ recaptcha_score ) {
78
+ } else if (isset ($ response ->score ) && $ response ->score < $ recaptcha_score ) {
77
79
return false ;
78
80
} else {
79
81
return true ;
@@ -92,20 +94,20 @@ public static function result($secret_key, $g_recaptcha_response, $recaptcha_sco
92
94
*/
93
95
public static function show ($ site_key , $ after_field_id = 'Form_ContactForm_Comment ' , $ debug = 'no_debug ' , $ extra_class = "mt-4 mb-4 " , $ please_tick_msg = "Please tick the I'm not robot checkbox " )
94
96
{
95
- if ( $ please_tick_msg == 'v3 ' ){
97
+ if ($ please_tick_msg == 'v3 ' ) {
96
98
return Self::showV3 ($ site_key , $ after_field_id , $ debug , $ extra_class );
97
99
}
98
100
99
- if ( strpos ($ extra_class , 'invisible ' ) !== false ) {
101
+ if (strpos ($ extra_class , 'invisible ' ) !== false ) {
100
102
return Self::showInvisible ($ site_key , $ after_field_id , $ debug , $ extra_class );
101
103
}
102
104
103
105
$ api_js_str = "<script src='https://www.google.com/recaptcha/api.js'></script> " ;
104
- if ( strpos ($ extra_class , 'no-api-js ' ) !== false ) {
106
+ if (strpos ($ extra_class , 'no-api-js ' ) !== false ) {
105
107
$ api_js_str = "" ;
106
108
}
107
109
$ data_theme = 'light ' ;
108
- if ( strpos ($ extra_class , 'theme-dark ' ) !== false ) {
110
+ if (strpos ($ extra_class , 'theme-dark ' ) !== false ) {
109
111
$ data_theme = "dark " ;
110
112
}
111
113
@@ -170,7 +172,7 @@ public static function showV3($site_key, $after_field_id = 'Form_ContactForm_Com
170
172
{
171
173
$ debug_mode = ($ debug == 'no_debug ' ) ? '' : 'return false; // debug mode is on ' ;
172
174
173
- if ( strpos ($ extra_class , 'show-inline-badge ' ) !== false ) {
175
+ if (strpos ($ extra_class , 'show-inline-badge ' ) !== false ) {
174
176
$ api_js = "https://www.google.com/recaptcha/api.js?render=explicit&onload=alexGetRecaptchaValue " ;
175
177
$ recaptcha_client = "var recaptchaClient = grecaptcha.render('CustomContactUsForm-inline-badge', {
176
178
'sitekey': ' $ site_key',
0 commit comments