13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Captcha |
16 * @package Zend_Captcha |
17 * @subpackage Adapter |
17 * @subpackage Adapter |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 */ |
20 */ |
21 |
21 |
22 /** @see Zend_Captcha_Base */ |
22 /** @see Zend_Captcha_Base */ |
23 require_once 'Zend/Captcha/Base.php'; |
23 require_once 'Zend/Captcha/Base.php'; |
28 * Generates random word which user should recognise |
28 * Generates random word which user should recognise |
29 * |
29 * |
30 * @category Zend |
30 * @category Zend |
31 * @package Zend_Captcha |
31 * @package Zend_Captcha |
32 * @subpackage Adapter |
32 * @subpackage Adapter |
33 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
33 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
34 * @license http://framework.zend.com/license/new-bsd New BSD License |
34 * @license http://framework.zend.com/license/new-bsd New BSD License |
35 * @version $Id: Word.php 21793 2010-04-08 00:51:31Z stas $ |
35 * @version $Id: Word.php 24593 2012-01-05 20:35:02Z matthew $ |
36 */ |
36 */ |
37 abstract class Zend_Captcha_Word extends Zend_Captcha_Base |
37 abstract class Zend_Captcha_Word extends Zend_Captcha_Base |
38 { |
38 { |
39 /**#@+ |
39 /**#@+ |
40 * @var array Character sets |
40 * @var array Character sets |
215 public function getTimeout() |
215 public function getTimeout() |
216 { |
216 { |
217 return $this->_timeout; |
217 return $this->_timeout; |
218 } |
218 } |
219 |
219 |
220 /** |
220 /** |
221 * Sets if session should be preserved on generate() |
221 * Sets if session should be preserved on generate() |
222 * |
222 * |
223 * @param $keepSession Should session be kept on generate()? |
223 * @param bool $keepSession Should session be kept on generate()? |
224 * @return Zend_Captcha_Word |
224 * @return Zend_Captcha_Word |
225 */ |
225 */ |
226 public function setKeepSession($keepSession) |
226 public function setKeepSession($keepSession) |
227 { |
227 { |
228 $this->_keepSession = $keepSession; |
228 $this->_keepSession = $keepSession; |
229 return $this; |
229 return $this; |
230 } |
230 } |
231 |
231 |
232 /** |
232 /** |
233 * Numbers should be included in the pattern? |
233 * Numbers should be included in the pattern? |
234 * |
234 * |
235 * @return bool |
235 * @return bool |
236 */ |
236 */ |
237 public function getUseNumbers() |
237 public function getUseNumbers() |
238 { |
238 { |
239 return $this->_useNumbers; |
239 return $this->_useNumbers; |
240 } |
240 } |
241 |
241 |
242 /** |
242 /** |
243 * Set if numbers should be included in the pattern |
243 * Set if numbers should be included in the pattern |
244 * |
244 * |
245 * @param $_useNumbers numbers should be included in the pattern? |
245 * @param bool $_useNumbers numbers should be included in the pattern? |
246 * @return Zend_Captcha_Word |
246 * @return Zend_Captcha_Word |
247 */ |
247 */ |
248 public function setUseNumbers($_useNumbers) |
248 public function setUseNumbers($_useNumbers) |
249 { |
249 { |
250 $this->_useNumbers = $_useNumbers; |
250 $this->_useNumbers = $_useNumbers; |
251 return $this; |
251 return $this; |
252 } |
252 } |
253 |
253 |
254 /** |
254 /** |
255 * Get session object |
255 * Get session object |
256 * |
256 * |
257 * @return Zend_Session_Namespace |
257 * @return Zend_Session_Namespace |
258 */ |
258 */ |
259 public function getSession() |
259 public function getSession() |
346 * @return string session ID |
346 * @return string session ID |
347 */ |
347 */ |
348 public function generate() |
348 public function generate() |
349 { |
349 { |
350 if(!$this->_keepSession) { |
350 if(!$this->_keepSession) { |
351 $this->_session = null; |
351 $this->_session = null; |
352 } |
352 } |
353 $id = $this->_generateRandomId(); |
353 $id = $this->_generateRandomId(); |
354 $this->_setId($id); |
354 $this->_setId($id); |
355 $word = $this->_generateWord(); |
355 $word = $this->_generateWord(); |
356 $this->_setWord($word); |
356 $this->_setWord($word); |