$secret,'response' => $_POST['g-recaptcha-response']); $verify = curl_init(); curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify"); curl_setopt($verify, CURLOPT_POST, true); curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($verify, CURLOPT_RETURNTRANSFER, true); $verifyResponse = curl_exec($verify); $responseData = json_decode($verifyResponse); if($responseData->success) { if ($responseData->hostname == $_SERVER['SERVER_NAME']) { $alert = 'success'; $message = $lang{"recaptcha success"} . "
" . $_SERVER['REQUEST_URI'] . ""; file_put_contents($unblockfile, $_SERVER['REMOTE_ADDR'].";".$_SERVER['SERVER_NAME'].";".$_SERVER['SERVER_ADDR']."\n", FILE_APPEND | LOCK_EX); file_put_contents($logfile,$date . "*Success*, ReCaptcha (" . $_SERVER['REMOTE_ADDR'].": [".$_SERVER['SERVER_NAME']." (".$_SERVER['SERVER_ADDR'].")] requested unblock\n", FILE_APPEND | LOCK_EX); } else { $alert = "danger"; $message = $lang{"recaptcha hostfail"} . ' ['.$responseData->hostname.' != '.$_SERVER['SERVER_NAME'].']'; file_put_contents($logfile,$date . "*Failed*, ReCaptcha (" . $_SERVER['REMOTE_ADDR'].": [".$_SERVER['SERVER_NAME']." (".$_SERVER['SERVER_ADDR'].")] does not appear to be hosted on this server\n", FILE_APPEND | LOCK_EX); } } else { $alert = "danger"; $message = $lang{"recaptcha failure"}; file_put_contents($logfile,$date . "*Error*, ReCaptcha (" . $_SERVER['REMOTE_ADDR'].": $responseData\n", FILE_APPEND | LOCK_EX); } } else { $alert = "danger"; $message = $lang{"recaptcha error"}; } echo '

' . $message . '

'; } ?>