generate word

This commit is contained in:
Claude 2012-06-10 18:06:12 +02:00
parent e84a1e1451
commit 3dd8dcf323
2 changed files with 20 additions and 2 deletions

View File

@ -388,7 +388,25 @@ class Main extends CI_Controller
function captcha() function captcha()
{ {
$this->load->helper('captcha'); $this->load->helper('captcha');
$this->load->view('view/captcha');
//get "word"
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$str = '';
for ($i = 0;$i < 4;$i++)
{
$str.= substr($pool, mt_rand(0, strlen($pool) - 1) , 1);
}
$word = $str;
//save
$this->db_session->set_userdata(array(
'captcha' => $word
));
//view
$this->load->view('view/captcha', array(
'word' => $word
));
} }
function _valid_lang($lang) function _valid_lang($lang)

View File

@ -1,3 +1,3 @@
<?php <?php
header('Content-type: image/jpeg'); header('Content-type: image/jpeg');
display_captcha(); display_captcha($word);