コード例 #1
0
 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;
 }