A captcha is an image containing a code made of random alphanumeric characters.
They are integrated into websites, generaly in forms, to verify if the user is an human or not (robot).
So that the goal is also to scramble OCR detection, it contains generaly some jamming informations
(blur background, blur characters, jamming lines,...).
CI is a PHP based MVC (Model View Controller) framework.
You will find more about Code Igniter here.
sig.php | : the controller file |
---|---|
sig_model.php | : the model file |
sig_config.php | : the configuration file |
sig_read_me.html | : this file |
sig_captcha.png | : sample of background image |
arial.ttf | : sample of font file |
samples | : a folder containing the samples you can see here under |
sig.php | : save in CI "controllers" folder |
---|---|
sig_model.php | : save in CI "models" folder |
sig_config.php | : save in CI "config" folder |
sig_captcha.png | : save where ever you want if needed |
arial.ttf | : save where ever you want if needed |
It is very easy and all the configurable parameters, with their explanations, are in the file "sig_config.php".
What can you configure ?
When you want to generate a security image you just have to point it as http://domain/sig
In the form it would looks like this :
top<form headers ... >
...
Validation Code:
<img src="<?php echo base_url().'sig'; ?>" alt="CAPTCHA">
<input type="text" name="code" size="10">
...
</form>
To check the captcha agains the input form code, just add something like this :
if ($this->input->post('code') != $this->session->userdata('sig_key')) { echo 'error'; } else { echo 'success'; }
or like this :
if ($this->input->post('code') != $this->obj->db_session->userdata('sig_key')) { echo 'error'; } else { echo 'success'; }
on the controller/file that does your submit.
topFeel free to download it, use it and modify it like you want.
topSpecial thanks to Stupid Shrimp (Baka Ebi) who developped his captcha generator and on which this one is based.
top