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())); }
public function __construct($useOldPassword = true) { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'panel-body'); if ($useOldPassword) { $oldPassword = new Password('oldPassword'); $oldPassword->setLabel('old.password'); $oldPassword->setAttribute('class', 'form-control'); $this->add($oldPassword); } $password = new Password('password'); $password->setLabel('password'); $password->setAttribute('class', 'form-control'); $this->add($password); $password2 = new Password('password2'); $password2->setLabel('repeat.password'); $password2->setAttribute('class', 'form-control'); $this->add($password2); $captcha = new Captcha('register_captcha'); $imageAdapter = new Image(['font' => __DIR__ . '/../../fonts/arial.ttf']); $imageAdapter->setHeight(100); $imageAdapter->setWidth(400); $imageAdapter->setFontSize(48); $imageAdapter->setDotNoiseLevel(400); $imageAdapter->setLineNoiseLevel(40); $captcha->setCaptcha($imageAdapter); $captcha->setLabel('enter.text.from.the.picture'); $captcha->setAttribute('class', 'form-control'); $this->add($captcha); $submit = new Submit('save'); $submit->setValue('save'); $submit->setAttribute('class', 'btn btn-primary'); $this->add($submit); }
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'))); }
public function __construct() { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'panel-body'); $mail = new Email('email'); $mail->setLabel('email'); $mail->setAttribute('class', 'form-control'); $this->add($mail); $captcha = new Captcha('register_captcha'); $imageAdapter = new Image(['font' => __DIR__ . '/../../fonts/arial.ttf']); $imageAdapter->setHeight(100); $imageAdapter->setWidth(400); $imageAdapter->setFontSize(48); $imageAdapter->setDotNoiseLevel(400); $imageAdapter->setLineNoiseLevel(40); $captcha->setCaptcha($imageAdapter); $captcha->setLabel('enter.text.from.the.picture'); $captcha->setAttribute('class', 'form-control'); $this->add($captcha); $submit = new Submit('send'); $submit->setValue('send'); $submit->setAttribute('class', 'btn btn-primary'); $this->add($submit); }
/** * {@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' => "")); }