| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/comecondo/plugins/user-submitted-posts/recaptcha/ |
Upload File : |
<?php // Google reCAPTCHA for PHP >= 5.3.0
// PHP Global space backslash class requires >= 5.3.0
// Google reCAPTCHA 1.1.3 @ https://github.com/google/recaptcha
// Supports allow_url_fopen/file_get_contents and cURL
if (!defined('ABSPATH')) die();
require_once('autoload.php');
if (ini_get('allow_url_fopen')) {
// file_get_contents: allow_url_fopen = on
$recaptcha = new \ReCaptcha\ReCaptcha($private);
} elseif (extension_loaded('curl')) {
// cURL: allow_url_fopen = off
$recaptcha = new \ReCaptcha\ReCaptcha($private, new \ReCaptcha\RequestMethod\CurlPost());
} else {
$recaptcha = null;
error_log('WP Plugin USP: Google reCAPTCHA: allow_url_fopen and curl both disabled!', 0);
}
if (isset($recaptcha)) {
$response = $recaptcha->verify($_POST['g-recaptcha-response'], usp_get_ip_address());
} else {
$response = null;
error_log('WP Plugin USP: Google reCAPTCHA: $recaptcha variable not set!', 0);
}
if ($response->isSuccess()) {
return true;
} else {
$errors = $response->getErrorCodes();
if (!empty($errors) && is_array($errors)) {
foreach ($errors as $error) {
// error_log('WP Plugin USP: Google reCAPTCHA: '. $error, 0);
}
} else {
// error_log('WP Plugin USP: Google reCAPTCHA: '. $errors, 0);
}
}
return false;