Ver Mensaje Individual
  #4 (permalink)  
Antiguo 24/03/2013, 18:49
Avatar de doctork
doctork
 
Fecha de Ingreso: marzo-2013
Ubicación: México
Mensajes: 2
Antigüedad: 11 años, 1 mes
Puntos: 0
Respuesta: Capcha con cakephp

Actualmente existe una libreria proporcionada por el propio Google.
La puedes encontrar aqui:
[URL="http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest"]http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest[/URL]

Un ejemplo facil seria:
Código PHP:
Ver original
  1. require_once('recaptchalib.php');
  2.   $publickey = "your_public_key"; // you got this from the signup page
  3.   echo recaptcha_get_html($publickey);

La línea echo recaptcha_get_html($publickey) antes del cierre del Form, con el formhelper.
Código PHP:
Ver original
  1. echo $this->Form->create(....);
  2. //tus campos aqui....
  3. echo recaptcha_get_html(RECAPTCHA_PUBLIC_KEY);
  4. echo $this->Form->end('Submit');

Y donde recibas los datos via POST, implementas esta función:
Código PHP:
Ver original
  1. <?php
  2.   require_once('recaptchalib.php');
  3.   $privatekey = "your_private_key";
  4.   $resp = recaptcha_check_answer ($privatekey,
  5.                                 $_SERVER["REMOTE_ADDR"],
  6.                                 $_POST["recaptcha_challenge_field"],
  7.                                 $_POST["recaptcha_response_field"]);
  8.  
  9.   if (!$resp->is_valid) {
  10.     // What happens when the CAPTCHA was entered incorrectly
  11.     die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
  12.          "(reCAPTCHA said: " . $resp->error . ")");
  13.   } else {
  14.     // Your code here to handle a successful verification
  15.   }
  16.   ?>