Changeset 3010 for trunk/system/controllers/captcha.php
- Timestamp:
- 07/08/2008 04:09:39 PM (5 months ago)
- Files:
-
- 1 modified
-
trunk/system/controllers/captcha.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/controllers/captcha.php
r2206 r3010 16 16 */ 17 17 class Captcha_Controller extends Controller { 18 19 public $session; 18 20 public $captcha; 19 public $session;20 21 21 22 protected $captcha_code; … … 24 25 { 25 26 $this->session = Session::instance(); 26 27 27 $this->captcha = new Captcha; 28 28 29 // Create a random text string for captcha code.29 // Create and store a random captcha string 30 30 $this->captcha_code = $this->create_code(); 31 $this->captcha->set_code($this->captcha_code) ; 31 $this->captcha->set_code($this->captcha_code); 32 $this->session->set('captcha_code', $this->captcha_code); 32 33 33 // Set the session to store the security code 34 $this->session->set('captcha_code', $this->captcha_code); 35 // Call the library to output the image 34 // Output the image 36 35 $this->captcha->render(); 37 36 } … … 39 38 private function create_code() 40 39 { 41 $num_chars = Config::item('captcha.num_chars'); 42 43 if (Config::item('captcha.style') == 'math') 40 if (Config::item('captcha.style') === 'math') 44 41 { 45 42 $code = (string) mt_rand(101, 991); … … 47 44 else 48 45 { 49 // Character set to use, similar characters removed. 50 $charset = '@2345#6BCDF$GH789KMNPQRT%VWXYZ'; 51 $code = ''; 52 for ($i = 0; $i < $num_chars; $i++) 53 { 54 $code .= substr($charset, mt_rand(0, strlen($charset)-1), 1); 55 } 46 $code = text::random('distinct', Config::item('captcha.num_chars')); 56 47 } 57 48 … … 59 50 } 60 51 61 } 52 } // End Captcha_Controller
