'https://www.google.com/recaptcha/api/siteverify', CURLOPT_POST => true, CURLOPT_POSTFIELDS => ['secret' => $recaptcha_secret, 'response' => $recaptcha_response], CURLOPT_RETURNTRANSFER => true ]); $recaptcha = curl_exec($ch); curl_close($ch); } else { $recaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $recaptcha_secret . '&response=' . $recaptcha_response); } $recaptcha_result = json_decode($recaptcha); if ($recaptcha_result->success && $recaptcha_result->action == 'indexCaptcha1' && $recaptcha_result->score >= 0.5) { $recaptcha_valid = true; } } if (!$recaptcha_valid) { $errorcode = file_get_contents('./contact/form-error.html'); $errorcode = str_replace('##error##', 'CAPTCHA verification failed.', $errorcode); echo $errorcode; exit; } } ?>