Welcome Guest, Not a member yet? Register   Sign In
The Securimage library - an open-source free PHP CAPTCHA script
#1

[eluser]sankai[/eluser]
Hi,guys,
The original source from http://www.phpcaptcha.org/
It seems light and simple to use,so I try to fixed it up for CI framework

Install:

* Download the Securimage Library from http://doublekai.org/files/Securimage_For_CI.zip
* Copy file libraries / Securimage.php to application / libraries
* Copy file config / Securimage.php to application / config
* Copy dir views / fonts to application / views

if you want to quickstart test

* Copy file controlls / welcome.php to application / controlls
* Copy file controlls / image.php to application / controlls
* Copy file views / test.html to application / views


Example:

Controlls

- controllers / welcome.php
Code:
class Welcome extends Controller {
    function Welcome(){
        parent::Controller();
        $this->load->library('securimage');
        $this->load->helper('url');
        $this->load->helper('html');
    }
    function index(){
        $this->load->view('test.html');
    }
    function check(){
        $inputCode = $this->input->post('imagecode');
        if($this->securimage->check($inputCode) == true){
            $data['result'] = '<h1>=v= PASS!</h1>';
            $this->load->view('test.html',$data);
        } else {
            $data['result'] = '<h1>/_\ FAILURE</h1>';
            $this->load->view('test.html',$data);        
        }
    }
}
- controllers / image.php
Code:
class Image extends Controller {
    function Image(){
        parent::Controller();
        $this->load->library('securimage');        
    }
    function securimage(){
        $this->securimage->show();
    }
}


Views

- views / test.html
Code:
&lt;?php echo $result?&gt;
&lt;form action="&lt;?php echo site_url('welcome/check')?&gt;" method="post"&gt;
   &lt;?php echo img('image/securimage', TRUE)?&gt;<br/>
   &lt;input type="text" name="imagecode" /&gt;
   &lt;input type="submit" value="check" /&gt;
&lt;/form&gt;
#2

[eluser]jimdoescode[/eluser]
Awesome, works great. Thanks!
#3

[eluser]Shiro[/eluser]
::thumb_up::
Thx for sharing, it really useful!

FYI: This Securimage is using Version 1.0.3.1 (Mar 23, 2008)
#4

[eluser]Unknown[/eluser]
I got it working with the exception of the reload link. What is your code for that?

Edit: got it working. This is what I sent to my view:

$data = array('onclick'=>"document.getElementById('captcha').src = 'captcha/index/' + Math.random(); return false");
#5

[eluser]Unknown[/eluser]
I got it working with the exception of the reload link. What is your code for that?

Edit: got it working. This is what I sent to my view:
#6

[eluser]alaminx[/eluser]
thanks for sharing. I really useful for me.
#7

[eluser]ShoeLace1291[/eluser]
Is there a function that displays only the code? I would like to use this in form validation so there would be a hidden input with the actual text code in it. Then I would use a rule like 'required|matches[actualcode]' for the security text input.

Also, mine is only displaying the image, not the character string. Here's my code:

Code:
function index(){
    
        $this->template->head();
        
        if($this->form_validation->run('register') == FALSE){
        
            $data = array(
                          'FORM_OPEN' => form_open('register'),
                          'VALIDATION_ERRORS' => validation_errors(),
                          'SECURITY_IMAGE' => img('image/securimage', TRUE),
                          'SECURITY_CODE' => $this->securimage->getCode()
                          );
            
            $this->parser->parse('form_register.tpl', $data);
            
        }
        
        $this->template->foot();
        
    }
#8

[eluser]Unknown[/eluser]
This is probably really obvious, but this library requires the html helper to be loaded for the img() function in the view. Also I had issues with it loading a session library when I was autoloading db_session. Commenting out line 476 in the library seemed to do the trick.




Theme © iAndrew 2016 - Forum software by © MyBB