"
//
// client side code uses only a response token, it cant verify the token because the secret key has to be server side
function FormCaptchaValidateClientSide_HTML($test = 0)
{
return 'if(grecaptcha.getResponse().length!=0)return true;alert(\'Please complete Human Verification\');return false';
}
// FormCaptchaValidate()
// verify the response token server side using the secret key sent to the Google server
// if the function doesnt set an error then we know validation was successfull
//
// $error - existing $error array
function FormCaptchaValidate(&$error)
{
// secret key for reCaptcha "skyscraperpage.com key"
$key_secret = '6LcnhQQuAAAAAAu50rdog937K0FqiPLWRHYmZAiF';
// error for incomplete
if ($_POST['g-recaptcha-response'] == '')
$error[] = 'Human verification box was not completed';
// validate
else
{
// to send request to google server
$curl = curl_init();
curl_setopt_array($curl, [
// return the transfer as a string of the return value of curl_exec()
CURLOPT_RETURNTRANSFER => true,
//
//CURLOPT_SSL_VERIFYPEER => false, // if ssl certificates outdated try this
// url to fetch
CURLOPT_URL => 'https://www.google.com/recaptcha/api/siteverify',
// request method
CURLOPT_POST => true,
// post fields
CURLOPT_POSTFIELDS => http_build_query([
'secret' => $key_secret,
'response' => $_POST['g-recaptcha-response'] ?? '',
'remoteip' => $_SERVER['REMOTE_ADDR'] ?? ''
])
]);
$response = curl_exec($curl);
curl_close($curl);
if ($response === false) {
// if needed, curl_error($curl) would have the error message (and probably need to get it before curl_close() above)
$error[] = 'System error';
return;
}
$response = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) {
$error[] = 'System error';
return;
}
// error if fail
if (
(!$response)
||
(!$response['success'])
)
$error[] = 'Human verification failed';
}
}
// returns html for session token form field and sets $doc->bodyOnload with timeout message
function SessionTokenField_HTML()
{
global $doc, $member;
// JavaScript alert about form timeout, the value comes from Session class UpdateSession() timeout for session token
// 21600000 milliseconds is 21600 seconds or 6 hours
$doc->bodyOnload[] = 'setTimeout(function() { alert(\'This page was requested over six hours ago. Because of this, when you submit the form it may return an error. You will then be able to submit the form, with your changes retained, a second time.\'); }, 21600000)';
return '';
}
// validate $_POST['token'] as well as scheme and host
// $texttype indicates wording of error message
// return true/false
function SessionTokenValidate(&$errors, $texttype = 0)
{
global $doc, $member;
// $texttype indicates key
$text = array(
0 => 'data not updated',
1 => 'data not accepted',
2 => 'password not changed',
3 => 'message not accepted'
);
// clean up $_SERVER['HTTP_REFERER'] and set as array $referer
$referer = parse_url(filter_var($_SERVER['HTTP_REFERER'], FILTER_VALIDATE_URL));
// verify scheme and host: allows empty referer, current scheme and host to pass, fails on any other scheme or host
// verify session token
if (
((!empty($referer['scheme'])) && ($referer['scheme'] != $_SERVER['REQUEST_SCHEME']))
|| ((!empty($referer['host'])) && ($referer['host'] != $_SERVER['HTTP_HOST']))
|| (@$_POST['token'] != $member['token'])
) {
$errors[] = 'Suspicious request, '.$text[$texttype].'. Please try again. If this persists, please Contact Us to resolve.';
return false;
}
return true;
}
?>
Aerial View
Complete the Human Verification to display the map.
Do you see any incorrect data on this page? Please let our editors know of any corrections you can provide by posting them in the Database Corrections section of the discussion forum (open to the public).