Initial Kohana install
[speedfreak] / Server / system / libraries / drivers / Captcha / Riddle.php
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3  * Captcha driver for "riddle" style.
4  *
5  * $Id: Riddle.php 3769 2008-12-15 00:48:56Z zombor $
6  *
7  * @package    Captcha
8  * @author     Kohana Team
9  * @copyright  (c) 2007-2008 Kohana Team
10  * @license    http://kohanaphp.com/license.html
11  */
12 class Captcha_Riddle_Driver extends Captcha_Driver {
13
14         private $riddle;
15
16         /**
17          * Generates a new Captcha challenge.
18          *
19          * @return  string  the challenge answer
20          */
21         public function generate_challenge()
22         {
23                 // Load riddles from the current language
24                 $riddles = Kohana::lang('captcha.riddles');
25
26                 // Pick a random riddle
27                 $riddle = $riddles[array_rand($riddles)];
28
29                 // Store the question for output
30                 $this->riddle = $riddle[0];
31
32                 // Return the answer
33                 return $riddle[1];
34         }
35
36         /**
37          * Outputs the Captcha riddle.
38          *
39          * @param   boolean  html output
40          * @return  mixed
41          */
42         public function render($html)
43         {
44                 return $this->riddle;
45         }
46
47 } // End Captcha Riddle Driver Class