if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])) {
$url = "https://www.google.com/recaptcha/api/siteverify";
$secret = '********';
$ip = $_SERVER['REMOTE_ADDR'];
$data = array('secret' => $secret, 'response' => $_POST['g-recaptcha-response'], 'remoteip' => $ip);
include("curl-controller.php");
$res = json_decode($verifyResponse, true);
} else {
$errBox = ($lang['form_err_8']);
}
} else {
$res['success'] = true;
}
Сам curl.php
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36");
$verifyResponse = curl_exec($curl);
curl_close($curl);
if ($config['recaptcha'] === true) {
$recaptcha = $_POST['g-recaptcha-response'];
if (!empty($recaptcha)) {
include("curl-controller.php");
$google_url = "https://www.google.com/recaptcha/api/siteverify";
$secret = '********';
$ip = $_SERVER['REMOTE_ADDR'];
$url = $google_url . "?secret=" . $secret . "&response=" . $recaptcha . "&remoteip=" . $ip;
$res = getCurlData($url);
$res = json_decode($res, true);
} else {
$errBox = ($lang['form_err_8']);
}
} else {
$res['success'] = true;
}
if ($res['success']) {
// Код формы
}