ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

The Securimage library - an open-source free PHP CAPTCHA script

March 17, 2009 10:47pm

Subscribe [7]
  • #1 / Mar 17, 2009 10:47pm

    sankai

    17 posts

    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

    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

    class Image extends Controller {
        function Image(){
            parent::Controller();
            $this->load->library('securimage');        
        }
        function securimage(){
            $this->securimage->show();
        }
    }


    Views

    - views / test.html

    <?php echo $result?>
    <form action="<?php echo site_url('welcome/check')?>" method="post">
       <?php echo img('image/securimage', TRUE)?><br>
       <input type="text" name="imagecode" />
       <input type="submit" value="check" />
    </form>
  • #2 / Feb 16, 2010 3:27am

    jimdoescode

    19 posts

    Awesome, works great.  Thanks!

  • #3 / Mar 03, 2010 12:22am

    Shiro

    30 posts

    ::thumb_up::
    Thx for sharing, it really useful!

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

  • #4 / Oct 10, 2010 5:57pm

    kriskd

    1 posts

    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 / Oct 11, 2010 5:51am

    real123

    1 posts

    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 / Oct 14, 2010 12:13pm

    alaminx

    22 posts

    thanks for sharing. I really useful for me.

  • #7 / Oct 14, 2010 5:08pm

    ShoeLace1291

    49 posts

    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:

    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 / Apr 30, 2011 11:35am

    shadylane

    1 posts

    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.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases