public function indexAction()
 {
     $this->codeSession = new Zend_Session_Namespace('code');
     //在默认构造函数里实例化
     $captcha = new Zend_Captcha_Image(array('font' => APPLICATION_PATH . '/../public/fonts/ShadowsAroundUs.ttf', 'fontsize' => 24, 'imgdir' => './images/', 'session' => $this->codeSession, 'width' => 100, 'height' => 50, 'wordlen' => 5, 'LineNoiseLevel' => 0, 'DotNoiseLevel' => 20));
     //字母数
     $captcha->setExpiration(1);
     $captcha->setGcFreq(3);
     //设置删除生成的旧的验证码图片的随机几率
     $captcha->generate();
     //生成图片
     $this->view->ImgDir = $captcha->getImgDir();
     $this->view->captchaId = $captcha->getId();
     //获取文件名,md5编码
     $this->codeSession->code = $captcha->getWord();
     //获取当前生成的验证字符串
     $this->view->code = $this->codeSession->code;
 }
Ejemplo n.º 2
0
 /**
  *
  * @return \Zend_Captcha_Image
  */
 private function getImageCaptcha()
 {
     self::initSessionConfig();
     $appPath = APP_PATH;
     $captcha = new \Zend_Captcha_Image();
     $captcha->setSession($this->getSession());
     $captcha->setKeepSession(true);
     $captcha->setFont($appPath . '/data/fonts/consola.ttf');
     $captcha->setImgDir(dirname($appPath) . '/public/_captcha');
     $captcha->setImgUrl('/_captcha');
     $captcha->setExpiration(600);
     $captcha->setWordlen(5);
     $captcha->setUseNumbers(false);
     return $captcha;
 }