Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 18 revisions

Category:Libraries Category:Libraries::reCAPTCHA

Description

This a CI 1.7.x implementation of the ReCAPTCHA API (http://www.recaptcha.net) Forum Discussion:[url=http://codeigniter.com/forums/viewthread/67250/]Here[/url]

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 [url]http://recaptcha.net/apidocs/captcha/client.html[/url] 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) * [b]config/form_validation[/b] - enables you to add/edit any rules you may need to include if the reCaptcha is part of a larger form * [b]config/recaptcha[/b] - configuration of the reCaptcha parameters * [b]controllers/recaptchademo[/b] - a quick demonstration page you can use for testing * [b]views/recaptcha_demo[/b] - a view to help in testing * [b]views/recaptcha[/b] - the form snippet used to generate the reCaptcha to the user * [b]libraries/recaptcha[/b] - The reCaptcha library * [b]language/english/recaptcha_lang[/b] - language entries

Configuration

config/recaptcha

[code]$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' );[/code]

controller

[code] 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()));
}

}[/code]

That's it!

Clone this wiki locally