';
return '';
} else if ($config['captcha']==2) {
return '';
} else {
return '';
}
}
function validate($response){
global $config;
if($config['captcha']==1) {
var_dump($response);
if(isset($response['mcaptcha__token']) && $response['mcaptcha__token']!=''){
$token = $response['mcaptcha__token'];
} else {
return false;
}
$data = array(
'token' => $token,
'key' => $config['mcaptcha_sitekey'],
'secret' => $config['mcaptcha_secret']
);
$json = json_encode($data);
$url = 'https://'.$config['mcaptcha_url'].'/api/v1/pow/siteverify';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($json)
));
$fh=curl_exec($ch);
// schließe den cURL-Handle und gebe die Systemresourcen frei
curl_close($ch);
var_dump($fh);
if(!$fh){
return false;
}else{
$response = json_decode($fh, true);
if($response["valid"] !== true){
return true;
}else{
return false;
}
}
}else if($config['captcha']==2) {
var_dump($response);
if(isset($response['g-recaptcha-response']) && $response['g-recaptcha-response']!=''){
$data = $response['g-recaptcha-response'];
} else {
return false;
}
$ch = curl_init();
// setze die URL und andere Optionen
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify?secret=".$config['recaptcha_secret']."&response=".$data."&remoteip=".$functions->get_ip());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// führe die Aktion aus und gebe die Daten an den Browser weiter
$fh=curl_exec($ch);
// schließe den cURL-Handle und gebe die Systemresourcen frei
curl_close($ch);
if(!$fh){
return false;
}else{
$response = json_decode($fh, true);
if($response["success"] !== true){
return true;
}else{
return false;
}
}
} else {
return true;
}
}
}
?>