PluginProbe
User Submitted Posts – Enable Users to Submit Posts from the Front End / 20251121
User Submitted Posts – Enable Users to Submit Posts from the Front End v20251121
20260916 20260810 20260608 20230806 20230809 20230811 20230901 20230902 20230914 20231102 20240319 20240516 20240703 20241026 20250327 20250329 20251121 20251210 20260110 20260113 20260207 20260217 20260407 20260422 trunk All 59 releases
user-submitted-posts / recaptcha / connect.php

connect.php in User Submitted Posts – Enable Users to Submit Posts from the Front End 20251121, at recaptcha/connect.php

67 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // Google reCAPTCHA for PHP >= 5.3.0
2
3 // PHP Global space backslash class requires >= 5.3.0
4
5 // Google reCAPTCHA 1.1.3 @ https://github.com/google/recaptcha
6
7 // Supports allow_url_fopen/file_get_contents and cURL
8
9 if (!defined('ABSPATH')) die();
10
11 require_once('autoload.php');
12
13 if (ini_get('allow_url_fopen')) {
14
15 // file_get_contents: allow_url_fopen = on
16 $recaptcha = new \ReCaptcha\ReCaptcha($private);
17
18 } elseif (extension_loaded('curl')) {
19
20 // cURL: allow_url_fopen = off
21 $recaptcha = new \ReCaptcha\ReCaptcha($private, new \ReCaptcha\RequestMethod\CurlPost());
22
23 } else {
24
25 $recaptcha = null;
26
27 error_log('WP Plugin USP: Google reCAPTCHA: allow_url_fopen and curl both disabled!', 0);
28
29 }
30
31 if (isset($recaptcha)) {
32
33 $response = $recaptcha->verify($_POST['g-recaptcha-response'], usp_get_ip_address());
34
35 } else {
36
37 $response = null;
38
39 error_log('WP Plugin USP: Google reCAPTCHA: $recaptcha variable not set!', 0);
40
41 }
42
43 if ($response->isSuccess()) {
44
45 return true;
46
47 } else {
48
49 $errors = $response->getErrorCodes();
50
51 if (!empty($errors) && is_array($errors)) {
52
53 foreach ($errors as $error) {
54
55 // error_log('WP Plugin USP: Google reCAPTCHA: '. $error, 0);
56
57 }
58
59 } else {
60
61 // error_log('WP Plugin USP: Google reCAPTCHA: '. $errors, 0);
62
63 }
64
65 }
66
67 return false;