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)); }
public function captcha2() { $path = BASEPATH . '../resources/captcha/' . (date('Y') . '/' . date('m') . '/' . date('d')); if (!file_exists($path)) { mkdir($path, 0777, TRUE); } $session = new Zend\Session\Container('ZEND_PARANGARI'); $session->offsetSet('text1', 'value1'); //$session->set $obj = new Zend\Captcha\Image(); $obj->setImgDir($path); $obj->setFont(BASEPATH . '../application/third_party/fonts/LesJoursHeureux.otf'); $obj->setFontSize(40); $obj->setWidth(250); $obj->setHeight(100); $obj->setDotNoiseLevel(40); $obj->setLineNoiseLevel(3); $obj->setWordlen(6); $obj->setSession($session); $string_captcha_ID = $obj->generate(); echo $string_captcha_ID . "<br/>"; echo $obj->getWord(); $obj->isValid($string_captcha_ID); Helper_Log::write($_SESSION); }
public function __construct($name = null) { parent::__construct(); // FORM Attribute $this->setAttributes(array('action' => '', 'method' => 'POST', 'class' => 'form-horizontal', 'role' => 'form', 'name' => 'login-form', 'id' => 'login-form')); // Fullname $this->add(array('name' => 'fullname', 'type' => 'Text', 'attributes' => array('class' => 'form-control', 'id' => 'inputFullname', 'placeholder' => 'Họ tên'), 'options' => array('label' => 'Họ tên', 'label_attributes' => array('for' => 'inputEmail3', 'class' => 'col-sm-3 control-label')))); // Username $this->add(array('name' => 'username', 'type' => 'Text', 'attributes' => array('class' => 'form-control', 'id' => 'inputUsername', 'placeholder' => 'Tên đăng nhập'), 'options' => array('label' => 'Tên đăng nhập', 'label_attributes' => array('for' => 'inputEmail3', 'class' => 'col-sm-3 control-label')))); // Email $this->add(array('name' => 'email', 'type' => 'Text', 'attributes' => array('class' => 'form-control', 'id' => 'inputEmail', 'placeholder' => 'Email'), 'options' => array('label' => 'Email', 'label_attributes' => array('for' => 'inputEmail3', 'class' => 'col-sm-3 control-label')))); // Password $this->add(array('name' => 'password', 'type' => 'Password', 'attributes' => array('class' => 'form-control', 'id' => 'inputPassword', 'placeholder' => 'Password'), 'options' => array('label' => 'Password', 'label_attributes' => array('for' => 'inputPassword3', 'class' => 'col-sm-3 control-label')))); //Confirm Password $this->add(array('name' => 'confirm-password', 'type' => 'Password', 'attributes' => array('class' => 'TextInput', 'id' => 'inputConfirmPassword', 'placeholder' => 'Nhập lại mật khẩu'), 'options' => array('label' => 'Nhập lại mật khẩu', 'label_attributes' => array('for' => 'inputEmail3', 'class' => 'col-sm3 control-label')))); // Password $this->add(array('name' => 'phone', 'type' => 'Text', 'attributes' => array('class' => 'form-control', 'id' => 'inputPhone', 'placeholder' => 'Di động'), 'options' => array('label' => 'Di động', 'label_attributes' => array('for' => 'inputPassword3', 'class' => 'col-sm-3 control-label')))); $captchaObj = new \Zend\Captcha\Image(); $captchaObj->setImgDir(CAPTCHA_PATH . '/images'); $captchaObj->setImgUrl(CAPTCHA_URL . '/images'); $captchaObj->setFont(CAPTCHA_PATH . '/fonts/times.ttf'); $captchaObj->setFontSize(25); $captchaObj->setWordlen(5); $captchaObj->setWidth(200); $captchaObj->setHeight(50); $captchaObj->setDotNoiseLevel(100); $captchaObj->setLineNoiseLevel(5); // Captcha $this->add(array('name' => 'captcha', 'type' => 'Captcha', 'attributes' => array('class' => 'form-control', 'id' => 'inputCaptcha'), 'options' => array('label' => 'Mã an toàn', 'captcha' => $captchaObj))); $this->add(array('name' => 'my-button-submit', 'type' => 'Button', 'attributes' => array('type' => 'submit', 'class' => 'actionButton'), 'options' => array('label' => 'Tạo tài khoản'))); }