Welcome Guest, Not a member yet? Register   Sign In
Implementing reCAPTCHA in CI
#3

[eluser]tkyy[/eluser]
i find the best way to implement recaptcha is to actually do a curl call to the noscript version of the page (using your public key as the get parameter) and then parsing the challenge id out of the text. you then display the challenge id using the recaptcha url to get images (the parameter in that url is "c=").

this way you can avoid having a ton of crappy "powered by recaptcha" images all over your page and you can display the image itself in any way you see fit. make sure to store the challenge id as a hidden variable and pass it to your form submission function for validating.

here is an exact example of how i do it on a live social networking site

Code:
//grab the recaptcha page
$page = file_get_contents('http://api.recaptcha.net/challenge?k=recaptcha_public_key');

//split the document into lines
$lines = explode("\n",$page);

//find the line containing the challenge code
foreach($lines as $line){
    if(strstr($line,"challenge : '")){
        $url = str_replace("challenge : '",null,$line);
        $url = str_replace("',",null,$url);
        $url = trim($url);
        break;
    }
}

//create the html for displaying the image and store the challenge code into a variable
$recaptcha = '<img src="http://api.recaptcha.net/image?c='.$url.'" title="Prove you are human!">';
$challenge = $url;
?&gt;

i find this is better like i said because you can manipulate it anyway you want.


Messages In This Thread
Implementing reCAPTCHA in CI - by El Forum - 08-11-2010, 01:11 AM
Implementing reCAPTCHA in CI - by El Forum - 08-27-2010, 03:46 AM
Implementing reCAPTCHA in CI - by El Forum - 08-27-2010, 05:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB