Welcome Guest, Not a member yet? Register   Sign In
an enhanced captcha as helper
#1

[eluser]Christian Rößler[/eluser]
Hy folks,

having played around with CI (for the first time) in a new project i found out that the shipped captcha-plugin did not fit my needs.
so i wrote a new captcha (after i wasn't able to find one on this site) - as helper - with support for:

- random background-colors
- random char-colors
- multiple font-files (ttf as before)
- set the font-size via config

The return-value is exactly the same as CI's captcha-plugin's.
create_captcha($config) returns an array with the html-img-tag, a timestamp and the word itself.
put the captcha_helper.php into
Code:
/system/application/helpers/
a sample controller-snippet:
Code:
$this->load->helper('captcha');
        
        // create the captcha-config
        $aCaptchaCfg = array(
            //'word'          => 'myrandomword',    //default: random()
            'length'        => 6,                         //default: 5
            'img_path'   => './captcha/',   //no default !
            'img_url'       => site_url().'captcha/',  // no default!
            'font_path'  => './system/fonts/', // default: ./system/fonts/
            'fonts'         => array('texb.ttf', 'TSCu_Comic.ttf'), // default: texb.ttf
            'font_size'     => 25,      // default: 18
            'img_width'  => '180',  // default: 170
            'img_height' => '60',   // default: 60
            'expiration' => 7200 // default: 7200
            );
        
        // get captcha-stuff
    $aCaptcha = create_captcha($aCaptchaCfg);

you will find the helper here: captcha_helper.php.tar.gz
feel free to make changes / enhancements and share your work!

bye,
chris

PS: CI rocks!


Messages In This Thread
an enhanced captcha as helper - by El Forum - 09-27-2007, 07:39 AM
an enhanced captcha as helper - by El Forum - 09-27-2007, 01:01 PM
an enhanced captcha as helper - by El Forum - 09-30-2007, 03:13 PM
an enhanced captcha as helper - by El Forum - 10-27-2007, 10:06 AM
an enhanced captcha as helper - by El Forum - 10-27-2007, 10:29 AM
an enhanced captcha as helper - by El Forum - 10-27-2007, 08:26 PM
an enhanced captcha as helper - by El Forum - 10-29-2007, 04:27 AM
an enhanced captcha as helper - by El Forum - 10-29-2007, 04:40 AM
an enhanced captcha as helper - by El Forum - 05-08-2008, 02:21 AM
an enhanced captcha as helper - by El Forum - 05-20-2008, 02:21 AM
an enhanced captcha as helper - by El Forum - 05-20-2008, 02:54 AM
an enhanced captcha as helper - by El Forum - 05-20-2008, 05:36 AM
an enhanced captcha as helper - by El Forum - 06-04-2008, 09:52 AM
an enhanced captcha as helper - by El Forum - 09-25-2008, 10:01 PM
an enhanced captcha as helper - by El Forum - 01-11-2009, 08:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB