1 <?php defined('SYSPATH') OR die('No direct access allowed.');
3 * Captcha driver for "math" style.
5 * $Id: Math.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_Math_Driver extends Captcha_Driver {
14 private $math_exercice;
17 * Generates a new Captcha challenge.
19 * @return string the challenge answer
21 public function generate_challenge()
24 if (Captcha::$config['complexity'] < 4)
26 $numbers[] = mt_rand(1, 5);
27 $numbers[] = mt_rand(1, 4);
30 elseif (Captcha::$config['complexity'] < 7)
32 $numbers[] = mt_rand(10, 20);
33 $numbers[] = mt_rand(1, 10);
35 // Difficult, well, not really ;)
38 $numbers[] = mt_rand(100, 200);
39 $numbers[] = mt_rand(10, 20);
40 $numbers[] = mt_rand(1, 10);
43 // Store the question for output
44 $this->math_exercice = implode(' + ', $numbers).' = ';
47 return array_sum($numbers);
51 * Outputs the Captcha riddle.
53 * @param boolean html output
56 public function render($html)
58 return $this->math_exercice;
61 } // End Captcha Math Driver Class