1 <?php defined('SYSPATH') OR die('No direct access allowed.');
3 * Captcha driver for "word" style.
5 * $Id: Word.php 3769 2008-12-15 00:48:56Z zombor $
9 * @copyright (c) 2007-2008 Kohana Team
10 * @license http://kohanaphp.com/license.html
12 class Captcha_Word_Driver extends Captcha_Basic_Driver {
15 * Generates a new Captcha challenge.
17 * @return string the challenge answer
19 public function generate_challenge()
21 // Load words from the current language and randomize them
22 $words = Kohana::lang('captcha.words');
25 // Loop over each word...
26 foreach ($words as $word)
28 // ...until we find one of the desired length
29 if (abs(Captcha::$config['complexity'] - strlen($word)) < 2)
30 return strtoupper($word);
33 // Return any random word as final fallback
34 return strtoupper($words[array_rand($words)]);
37 } // End Captcha Word Driver Class