Part of the EllisLab Network
x
 
Create New Page
 View Previous Changes    ( Last updated by JayTee )

ReCAPTCHA

Category:Libraries
Category:Libraries -> reCAPTCHA

Description

This a CI 1.7.x implementation of the ReCAPTCHA API (http://www.recaptcha.net)
Forum Discussion:Here

Features:

* Uses config file for saving your reCaptcha keys and theme
* Uses an editable view for the reCaptcha form that can be inserted anywhere in your code
* Logs errors and messages to your log files rather than to the user’s screen
* Multilingual support.  Check http://recaptcha.net/apidocs/captcha/client.html for supported languages and codes.  English is the only language included (other language contributions welcome)
* Uploaded needed files as a zip rather than copy/paste from the wiki
* Download includes a sample that only requires you to include your API Keys from recaptcha.net

Download:

File:recaptcha 1.7.x.a.zip

Files Included

(These all go under your system/application folder)
* config/form_validation - enables you to add/edit any rules you may need to include if the reCaptcha is part of a larger form
* config/recaptcha - configuration of the reCaptcha parameters
* controllers/recaptchademo - a quick demonstration page you can use for testing
* views/recaptcha_demo - a view to help in testing
* views/recaptcha - the form snippet used to generate the reCaptcha to the user
* libraries/recaptcha - The reCaptcha library
* language/english/recaptcha_lang - language entries

Configuration

config/recaptcha

$config['recaptcha'] = array(
  
'public'=>'YOUR PUBLIC KEY',
  
'private'=>'YOUR PRIVATE KEY',
  
'RECAPTCHA_API_SERVER' =>'http://api.recaptcha.net',
  
'RECAPTCHA_API_SECURE_SERVER'=>'https://api-secure.recaptcha.net',
  
'RECAPTCHA_VERIFY_SERVER' =>'api-verify.recaptcha.net',
  
'theme' => 'white'
);

controller

function index()
  
{
    $this
->load->library('recaptcha');
    
$this->load->library('form_validation');
    
$this->lang->load('recaptcha');
    
$this->load->helper('form');
    
    if (
$this->form_validation->run())
    
{
      $this
->load->view('recaptcha_demo',array('recaptcha'=>'Yay! You got it right!'));
    
}
    
else
    
{
      
//the desired language code string can be passed to the get_html() method
      //"en" is the default if you don't pass the parameter
      //valid codes can be found here:http://recaptcha.net/apidocs/captcha/client.html
      
$this->load->view('recaptcha_demo',array('recaptcha'=>$this->recaptcha->get_html()));
    
}
  }

That’s it!

Categories: