验证码功能封装!
This commit is contained in:
parent
ba94ea7b7f
commit
985272db6a
|
@ -6,6 +6,7 @@ class Captcha extends \Zend_Controller_Plugin_Abstract
|
|||
public $captcha;
|
||||
|
||||
private $sessionName = "captcha";
|
||||
private $imgDir = "images/captcha";
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
|
@ -16,7 +17,7 @@ class Captcha extends \Zend_Controller_Plugin_Abstract
|
|||
{
|
||||
$this->captcha = new \Zend_Captcha_Image(array(
|
||||
'captcha' => 'Image',
|
||||
'wordLen' => 4,
|
||||
'wordLen' => 6,
|
||||
'fontsize'=>16,
|
||||
'width' => 100,
|
||||
'height' => 38,
|
||||
|
@ -24,12 +25,17 @@ class Captcha extends \Zend_Controller_Plugin_Abstract
|
|||
'lineNoiseLevel'=>1,
|
||||
'timeout' => 300,
|
||||
'font' => '../data/fonts/ggbi.ttf',
|
||||
'imgDir' => 'vdimg/',
|
||||
'imgUrl' => '/vdimg',
|
||||
'imgDir' => $this->imgDir,
|
||||
'imgUrl' => '/images/captcha',
|
||||
));
|
||||
}
|
||||
|
||||
public function setCaptcha(){
|
||||
if(!is_dir($this->imgDir))
|
||||
{
|
||||
mkdir($this->imgDir);
|
||||
}
|
||||
|
||||
$this->captcha->generate();
|
||||
$_SESSION[$this->sessionName] = $this->captcha->getWord();
|
||||
$url = $this->captcha->getImgUrl()
|
||||
|
|
|
@ -26,10 +26,8 @@ class Local extends \Zend_Controller_Plugin_Abstract
|
|||
$this->db = $db;
|
||||
}
|
||||
|
||||
$this->config = \Zend_Registry::get('config');
|
||||
$this->config = \Zend_Registry::get('6config');
|
||||
|
||||
# $Listener = new ReferenceListener();
|
||||
# @$this->events()->attachAggregate($Listener);
|
||||
|
||||
$this->table = new \Helpers\Table();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue