web/lib/Zend/Captcha/Word.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    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
    91      * Session lifetime for the captcha data
    91      * Session lifetime for the captcha data
    92      *
    92      *
    93      * @var integer
    93      * @var integer
    94      */
    94      */
    95     protected $_timeout = 300;
    95     protected $_timeout = 300;
    96     
    96 
    97     /**
    97     /**
    98      * Should generate() keep session or create a new one?
    98      * Should generate() keep session or create a new one?
    99      * 
    99      *
   100      * @var boolean
   100      * @var boolean
   101      */
   101      */
   102     protected $_keepSession = false;
   102     protected $_keepSession = false;
   103 
   103 
   104     /**#@+
   104     /**#@+
   129     /**
   129     /**
   130      * Retrieve session class to utilize
   130      * Retrieve session class to utilize
   131      *
   131      *
   132      * @return string
   132      * @return string
   133      */
   133      */
   134 	public function getSessionClass()
   134     public function getSessionClass()
   135     {
   135     {
   136         return $this->_sessionClass;
   136         return $this->_sessionClass;
   137     }
   137     }
   138 
   138 
   139     /**
   139     /**
   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);