Exemplo n.º 1
0
 public function novoAction()
 {
     $this->captcha = new Captcha();
     $this->captcha->setFont(getcwd() . "/../www/imobiliaria/fonts/Ubuntu-C.ttf");
     $this->captcha->setImgDir(getcwd() . "/../www/imobiliaria/img");
     $this->captcha->setWordlen(3);
     $this->captcha->setDotNoiseLevel(0);
     //echo "captcha ".  $this->captcha->getSession()->word;
     return new ViewModel(array("captcha" => $this->captcha->generate(), "idCaptcha" => $this->captcha->getWord()));
 }
Exemplo n.º 2
0
 public function __construct()
 {
     parent::__construct('login');
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $this->setAttribute('enctype', 'multipart/form-data');
     $this->add(array('name' => 'username', 'attributes' => array('type' => 'text', 'class' => 'form-control', 'placeholder' => 'nombre de usuario'), 'options' => array('label' => 'username', 'label_attributes' => array('class' => 'col-sm-3 control-label'))));
     $this->add(array('name' => 'password', 'attributes' => array('type' => 'password', 'id' => 'password', 'maxlength' => 20, 'class' => 'form-control', 'placeholder' => 'Contraseña'), 'options' => array('label' => 'password', 'label_attributes' => array('class' => 'col-sm-3 control-label'))));
     $captchaImage = new CaptchaImage();
     $captchaImage->setFont("public/resource/fonts/arial.ttf");
     $captchaImage->setImgDir("public/resource/images");
     $captchaImage->setImgUrl("/resource/images");
     $captchaImage->setImgAlt("Captcha");
     $captchaImage->setWidth(250);
     $captchaImage->setHeight(80);
     $captchaImage->setDotNoiseLevel(50);
     $captchaImage->setLineNoiseLevel(5);
     $captchaImage->setFontSize(38);
     $captchaImage->setExpiration(1);
     $captchaImage->setWordlen(6);
     $captchaImage->setMessage("El código no coincide, actualízalo y vuelve a intentarlo", $captchaImage::BAD_CAPTCHA);
     $this->add(array('type' => 'Zend\\Form\\Element\\Captcha', 'attributes' => array('type' => 'password', 'class' => 'form-control', 'placeholder' => 'captcha'), 'name' => 'captcha', 'options' => array('captcha' => $captchaImage, 'id' => 'captcha', 'label' => 'captcha', 'label_attributes' => array('class' => 'col-sm-2 control-label'))));
     $this->add(array('type' => 'Zend\\Form\\Element\\Csrf', 'name' => 'csrf', 'options' => array('csrf_options' => array('timeout' => 600))));
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Ingresar', 'class' => 'btn btn-primary btn-sm btn-sm')));
 }
Exemplo n.º 3
0
 public function getForm($hasCaptcha, $url = '', $captchaPath = '')
 {
     if (!$this->form) {
         $form = new Form();
         $txtUser = new Element\Text('username');
         $txtUser->setLabel('User Name')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'User name');
         $password = new Element\Password('password');
         $password->setLabel('Password')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'Password');
         $remember = new Element\Checkbox('remember');
         $remember->setLabel('Save authentication?')->setAttribute('class', 'form-control');
         if ($hasCaptcha) {
             $captchaImage = new Image();
             $captchaImage->setFont('./data/font/CAMBRIA.TTC')->setWidth(200)->setHeight(60)->setDotNoiseLevel(40)->setLineNoiseLevel(4)->setExpiration(90);
             $captchaImage->setImgUrl($url);
             $captchaImage->setImgDir($captchaPath);
             $captcha = new Element\Captcha('isHuman');
             $captcha->setCaptcha($captchaImage)->setAttributes(array('class' => 'form-control'));
             $form->add($captcha);
         }
         $form->setAttribute('class', 'form-horizontal');
         $form->add($txtUser);
         $form->add($password);
         $form->add($remember);
         $this->form = $form;
     }
     return $this->form;
 }
Exemplo n.º 4
0
 /**
  * Init Module form
  *
  * @return void
  */
 public function init()
 {
     $showEmail = new Element\Checkbox('show_email');
     $showEmail->setLabel('Show email');
     $showEmail->setAttribute('required', 'required')->setAttribute('id', 'show-email');
     $username = new Element\Text('username');
     $username->setLabel('Username');
     $username->setAttribute('required', 'required')->setAttribute('id', 'username');
     $email = new Element\Text('email');
     $email->setLabel('Email');
     $email->setAttribute('required', 'required')->setAttribute('id', 'email');
     $message = new Element\Textarea('message');
     $message->setLabel('Message');
     $message->setAttribute('required', 'required')->setAttribute('id', 'message');
     $captchaImage = new CaptchaImage(array('font' => GC_PUBLIC_PATH . '/backend/fonts/arial.ttf', 'width' => 250, 'height' => 50, 'dotNoiseLevel' => 40, 'lineNoiseLevel' => 3));
     $captchaImage->setImgDir(GC_PUBLIC_PATH . '/frontend/tmp');
     $captchaImage->setImgUrl('/frontend/tmp');
     $captcha = new Element\Captcha('captcha');
     $captcha->setLabel('Please verify you are human')->setCaptcha($captchaImage)->setAttribute('required', 'required')->setAttribute('id', 'captcha');
     $this->add($showEmail);
     $this->add($username);
     $this->add($email);
     $this->add($message);
     $this->add($captcha);
     $inputFilterFactory = new InputFilterFactory();
     $inputFilter = $inputFilterFactory->createInputFilter(array('show_email' => array('name' => 'show_email', 'required' => false), 'username' => array('name' => 'username', 'required' => true), 'email' => array('name' => 'email', 'required' => true, 'validators' => array(array('name' => 'email_address'))), 'message' => array('name' => 'message', 'required' => true), 'captcha' => $captcha->getInputSpecification()));
     $this->setInputFilter($inputFilter);
 }
Exemplo n.º 5
0
 /**
  * Add form elements and attributes
  */
 public function init()
 {
     $this->setName('Login');
     $this->setAttribute('method', 'post');
     $this->add(array('name' => 'email', 'type' => 'text', 'options' => array('label' => $this->translate('E-Mail Address')), 'validators' => array(array('name' => 'EmailAddress'))));
     $captchaImage = new CaptchaImage(array('font' => $_SERVER['DOCUMENT_ROOT'] . '/fonts/arial.ttf', 'width' => 200, 'height' => 80, 'dotNoiseLevel' => 40, 'lineNoiseLevel' => 3));
     $captchaImage->setImgDir($_SERVER['DOCUMENT_ROOT'] . '/captcha');
     $captchaImage->setImgUrl('/captcha');
     $this->add(array('type' => 'Zend\\Form\\Element\\Captcha', 'name' => 'captcha', 'options' => array('label' => $this->translate('Please verify you are human'), 'captcha' => $captchaImage)));
     $this->add(new Element\Csrf('security'));
     $this->add(array('name' => 'submit', 'attributes' => array('class' => 'btn btn-large btn-primary', 'type' => 'submit', 'value' => $this->translate('Request password reset'))));
 }
Exemplo n.º 6
0
 public function __construct($urlcaptcha = null)
 {
     parent::__construct('contact');
     $this->setAttribute('method', 'post');
     $dirdata = './data';
     $captchaImage = new CaptchaImage(array('font' => $dirdata . '/fonts/arial.ttf', 'width' => 250, 'height' => 100, 'dotNoiseLevel' => 40, 'lineNoiseLevel' => 3));
     $captchaImage->setImgDir($dirdata . '/captcha');
     $captchaImage->setImgUrl($urlcaptcha);
     $this->add(array('type' => 'Zend\\Form\\Element\\Captcha', 'name' => 'captcha', 'options' => array('label' => 'Retape ce que tu vois dans la photo', 'captcha' => $captchaImage)));
     $this->add(array('name' => 'message', 'type' => 'textarea', 'options' => array('label' => 'Votre message'), 'attributes' => array('class' => "ckeditor")));
     $this->add(['name' => 'email', 'type' => 'Zend\\Form\\Element\\Text', 'attributes' => ['class' => 'form-control'], 'options' => ['type' => 'text', 'label' => 'E-mail']]);
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'commenter', "class" => "btn btn-info")));
 }
Exemplo n.º 7
0
 public function init()
 {
     $this->setAttribute('method', 'post');
     $this->setAttribute('role', 'form');
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'name', 'options' => ['label' => 'NAME', 'object_manager' => $this->objectManager], 'attributes' => ['required' => true, 'min' => 3, 'max' => 30, 'size' => 30, 'placeholder' => 'ENTER_NAME']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Email', 'name' => 'email', 'options' => ['label' => 'EMAIL', 'object_manager' => $this->objectManager], 'attributes' => ['required' => true, 'min' => 3, 'size' => 30, 'placeholder' => '*****@*****.**']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'subject', 'options' => ['label' => 'SUBJECT', 'object_manager' => $this->objectManager], 'attributes' => ['required' => true, 'min' => 3, 'size' => 30, 'placeholder' => 'ENTER_SUBJECT']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Textarea', 'name' => 'message', 'options' => ['label' => 'MESSAGE', 'object_manager' => $this->objectManager], 'attributes' => ['required' => true, 'rows' => 8, 'cols' => 70, 'placeholder' => 'ENTER_MESSAGE']]);
     $captchaImage = new CaptchaImage(['font' => 'public/layouts/default/front/fonts/arial.ttf', 'width' => 180, 'height' => 50, 'size' => 30, 'fsize' => 20, 'dotNoiseLevel' => 10, 'lineNoiseLevel' => 2]);
     $captchaImage->setImgDir('./public/userfiles/captcha');
     $captchaImage->setImgUrl('/userfiles/captcha');
     $this->add(['type' => 'Zend\\Form\\Element\\Captcha', 'name' => 'captcha', 'attributes' => ['class' => 'captcha-input', 'size' => 30, 'placeholder' => 'ENTER_CAPTCHA'], 'options' => ['label' => 'CAPTCHA', 'captcha' => $captchaImage]]);
     $this->add(['name' => 'submit', 'attributes' => ['type' => 'submit', 'id' => 'submitbutton', 'value' => 'SEND']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Csrf', 'name' => 's', 'options' => ['csrf_options' => ['timeout' => 320]]]);
 }
Exemplo n.º 8
0
 public function init()
 {
     $this->setAttribute('method', 'post');
     $this->setAttribute('action', '/registration/processregistration');
     $this->setAttribute('role', 'form');
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'name', 'options' => ['label' => 'NAME', 'object_manager' => $this->objectManager], 'attributes' => ['required' => true, 'placeholder' => 'ENTER_NAME', 'min' => 3, 'max' => 20, 'size' => 30]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Password', 'name' => 'password', 'options' => ['label' => 'PASSWORD', 'object_manager' => $this->objectManager], 'attributes' => ['required' => true, 'placeholder' => 'PASSWORD', 'min' => 8, 'size' => 30]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Password', 'name' => 'repeatpw', 'options' => ['label' => 'REPEAT_PASSWORD', 'object_manager' => $this->objectManager], 'attributes' => ['required' => true, 'placeholder' => 'REPEAT_PASSWORD', 'size' => 30]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Email', 'name' => 'email', 'options' => ['label' => 'EMAIL', 'object_manager' => $this->objectManager], 'attributes' => ['required' => true, 'min' => 3, 'size' => 30, 'placeholder' => '*****@*****.**']]);
     $captchaImage = new CaptchaImage(['font' => 'public/layouts/default/front/fonts/arial.ttf', 'width' => 180, 'height' => 50, 'size' => 30, 'fsize' => 20, 'dotNoiseLevel' => 10, 'lineNoiseLevel' => 2]);
     $captchaImage->setImgDir('./public/userfiles/captcha');
     $captchaImage->setImgUrl('/userfiles/captcha');
     $this->add(['type' => 'Zend\\Form\\Element\\Captcha', 'name' => 'captcha', 'attributes' => ['class' => 'captcha-input', 'placeholder' => 'ENTER_CAPTCHA', 'size' => 30], 'options' => ['label' => 'CAPTCHA', 'captcha' => $captchaImage]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Csrf', 'name' => 's', 'options' => ['csrf_options' => ['timeout' => 320]]]);
     $this->add(['name' => 'register', 'attributes' => ['type' => 'submit', 'id' => 'submitbutton', 'value' => 'SIGN_UP']]);
 }
Exemplo n.º 9
0
 public function __construct($urlcaptcha = null)
 {
     parent::__construct('User Register Form');
     $this->setAttribute('method', 'post');
     $this->add(array('name' => 'username', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => '帳號'), 'attributes' => array('type' => 'text')));
     $this->add(array('name' => 'first_name', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => '姓')));
     $this->add(array('name' => 'last_name', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => '名')));
     $this->add(array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'birthday', 'options' => array('label' => '生日', 'description' => '請輸入西元年月日,例: 2000-1-1')));
     $this->add(array('name' => 'sex', 'type' => 'Zend\\Form\\Element\\Select', 'options' => array('label' => '性別', 'value_options' => array('' => '請選擇', 'male' => '男', 'female' => '女'))));
     $this->add(array('type' => 'Zend\\Form\\Element\\Email', 'name' => 'email', 'options' => array('label' => '電子郵件')));
     $this->add(array('name' => 'password', 'options' => array('label' => '密碼'), 'attributes' => array('type' => 'password', 'placeholder' => '請輸入您的密碼')));
     $this->add(array('name' => 're_password', 'options' => array('label' => '確認密碼'), 'attributes' => array('type' => 'password', 'placeholder' => '再輸入一次密碼')));
     $this->add(new Element\Csrf('security'));
     $dirdata = './data';
     $captchaImage = new CaptchaImage(array('font' => $dirdata . '/fonts/arial.ttf', 'width' => 200, 'height' => 80, 'wordlen' => 5, 'dotNoiseLevel' => 40, 'lineNoiseLevel' => 8));
     $captchaImage->setImgDir($dirdata . '/captcha');
     $captchaImage->setImgUrl($urlcaptcha);
     $captcha = new Element\Captcha('captcha');
     $captcha->setCaptcha($captchaImage);
     $captcha->setLabel('請輸入驗證碼');
     $this->add($captcha);
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => '註冊', 'class' => 'btn btn-primary')));
 }
Exemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $sessionKey = sprintf('%s_zend_captcha_session_key_%s', $form->getParent()->getName(), $form->getName());
     $captcha = new Image();
     if (isset($options['suffix'])) {
         $captcha->setSuffix($options['suffix']);
     }
     if (isset($options['height'])) {
         $captcha->setHeight($options['height']);
     }
     if (isset($options['width'])) {
         $captcha->setWidth($options['width']);
     }
     if (isset($options['img_alt'])) {
         $captcha->setImgAlt($options['img_alt']);
     }
     if (isset($options['font_size'])) {
         $captcha->setFontSize($options['font_size']);
     }
     if (isset($options['dot_noise_level'])) {
         $captcha->setDotNoiseLevel($options['dot_noise_level']);
     }
     if (isset($options['line_noise_level'])) {
         $captcha->setLineNoiseLevel($options['line_noise_level']);
     }
     if (isset($options['word_len'])) {
         $captcha->setWordlen($options['word_len']);
     }
     if (isset($options['expiration'])) {
         $captcha->setExpiration($options['expiration']);
     }
     if (isset($options['gc_freq'])) {
         $captcha->setGcFreq($options['gc_freq']);
     }
     $captcha->setImgDir($this->options['img_dir']);
     $captcha->setFont($this->options['font']);
     $captcha->setImgUrl($this->options['img_url']);
     $captcha->getWord();
     $captcha->generate();
     $this->session->set($sessionKey, $captcha->getSession()->getName());
     $view->vars = array_merge($view->vars, array('img_url' => $captcha->getImgUrl() . $captcha->getId() . $captcha->getSuffix(), 'height' => $captcha->getHeight(), 'width' => $captcha->getWidth(), 'img_alt' => $captcha->getImgAlt(), 'img_id' => $captcha->getId(), 'value' => ""));
 }
 /**
  * Add captcha
  *
  * @param string $name
  * @param string $label
  * @param string $category
  * @return void
  */
 protected function addCaptcha($name, $label = null, $category = null)
 {
     // pass captcha image options
     $captchaImage = new CaptchaImage(['font' => CaptchaService::getCaptchaFontPath(), 'width' => SettingService::getSetting('application_captcha_width'), 'height' => SettingService::getSetting('application_captcha_height'), 'dotNoiseLevel' => SettingService::getSetting('application_captcha_dot_noise'), 'lineNoiseLevel' => SettingService::getSetting('application_captcha_line_noise')]);
     $captchaImage->setImgDir(CaptchaService::getCaptchaPath());
     $captchaImage->setImgUrl(CaptchaService::getCaptchaUrl());
     $this->add(['type' => self::FIELD_CAPTCHA, 'name' => $name, 'options' => ['label' => '*' . $this->translator->translate($label ? $label : 'Please verify you are human'), 'captcha' => $captchaImage, 'category' => $category ? $category : null], 'attributes' => ['id' => 'captcha', 'class' => 'form-control', 'required' => 'required']]);
 }