示例#1
0
 public function index01Action()
 {
     echo "<h3 style='color:red;font-weight:bold'>" . __METHOD__ . "</h3>";
     //Tạo đối tượng chaptcha Image
     $captchaImg = new \Zend\Captcha\Image();
     //Thiết lập đường dẫn đấn thư mục hình ảnh chứa captcha
     $captchaImg->setImgDir(CAPTCHA_PATH . "images");
     //Thiết lập url cho hình ảnh captcha
     $captchaImg->setImgUrl(CAPTCHA_URL . "images");
     //Thiết lập font
     $captchaImg->setFont(CAPTCHA_PATH . "fonts/Vharis.ttf");
     //font-size
     $captchaImg->setFontSize(30);
     //length-char
     $captchaImg->setWordlen(5);
     //width-height cho captcha
     $captchaImg->setWidth(180);
     $captchaImg->setHeight(70);
     //set dấu chấm và đường chéo
     $captchaImg->setDotNoiseLevel(70);
     $captchaImg->setLineNoiseLevel(5);
     //Thiết lập ký tự xuất hiện
     AbstractWord::$VN = array("t");
     AbstractWord::$CN = array("r");
     //Phát sinh captcha
     $captchaImg->generate();
     $imgUrl = $captchaImg->getImgUrl() . $captchaImg->getId() . $captchaImg->getSuffix();
     return new ViewModel(array("imgUrl" => $imgUrl));
 }
示例#2
0
 /**
  * Generate captcha
  *
  * @return string captcha ID
  */
 public function generate()
 {
     $id = parent::generate();
     $tries = 5;
     // If there's already such file, try creating a new ID
     while ($tries-- && file_exists($this->getImgDir() . $id . $this->getSuffix())) {
         $id = $this->generateRandomId();
         $this->setId($id);
     }
     $this->generateImage($id, $this->getWord());
     if (mt_rand(1, $this->getGcFreq()) == 1) {
         $this->gc();
     }
     return $id;
 }
示例#3
0
文件: Figlet.php 项目: ninahuanca/zf2
 /**
  * Generate new captcha
  *
  * @return string
  */
 public function generate()
 {
     $this->useNumbers = false;
     return parent::generate();
 }
 /**
  * @param \Zend\Captcha\AbstractWord $oCaptcha
  * @return \BoilerAppAccessControl\Form\RegisterForm
  */
 public function setCaptcha(\Zend\Captcha\AbstractWord $oCaptcha)
 {
     $this->captcha = $oCaptcha->setName('auth_access_captcha');
     return $this;
 }