ccc

Mostrando entradas con la etiqueta Captcha. Mostrar todas las entradas
Mostrando entradas con la etiqueta Captcha. Mostrar todas las entradas

Recaptcha Invisible Google

Hay que obtener una "key secrets" y una "api key" en:

https://www.google.com/recaptcha/admin

Por ejemplo en Wordpress el plugin es:

https://wordpress.org/plugins/cf7-invisible-recaptcha/

Para las webs normales seguir las indicaciones de la página de:

https://www.google.com/recaptcha/admin

Una vez que tienes ya el API KEY y el API SECRET en una web normal hay que poner en el form:
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="[API_KEY]"></div>

Y luego en el fichero que recibe los datos del form:
$recaptcha = $_POST["g-recaptcha-response"];
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = array(
'secret' => '[API_SECRET]',
'response' => $recaptcha
);
$options = array(
'http' => array (
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context  = stream_context_create($options);
$verify = file_get_contents($url, false, $context);
$captcha_success = json_decode($verify);
if ($captcha_success->success) {
   // todo bien: rescatar los datos del form
}

Más información en:
http://jonsegador.com/2017/05/configurar-recaptcha-2-0-con-php/

Para Wordpress más información en:

https://www.cloudways.com/blog/add-google-invisible-recaptcha-in-wordpress/

En wordpress después de configurar el plugin de "Advanced noCaptcha & invisible captcha" con el Site key y el site Secret que te proporciona Google ya solo tienes que añadir a tu formulario de contact form:

[anr_nocaptcha g-recaptcha-response]

Captcha: Crear tu propio captcha con PHP

header("Content-type: image/png");
$string = "abcdefghijklmnopqrstuvwxyz0123456789";
for($i=0;$i<5;$i++){
    $pos = rand(0,36);
    $str .= $string{$pos};
}
$img_handle = ImageCreate (60, 22) or die ("Es imposible crear la imagen");
$back_color = ImageColorAllocate($img_handle,102,102,153);
$txt_color = ImageColorAllocate($img_handle,255,255,255);
ImageString($img_handle, 31, 5, 0, $str, $txt_color);
Imagepng($img_handle);
session_start();
$_SESSION['img_number'] = $str;