radekdostal/nette-captchacontrol

Captcha Control for Nette Framework

1.0.0 2016-04-01 06:45 UTC

This package is auto-updated.

Last update: 2024-12-20 04:52:51 UTC


README

Captcha Control for Nette Framework

Requirements

Example

Registration

Registration to bootstrap.php file.

RadekDostal\NetteComponents\CaptchaControl::register($container->getByType('Nette\Http\Session'));

Usage

$form = new \Nette\Application\UI\Form;  

$form->addCaptcha('captcha')
  ->addRule(\Nette\Forms\Form::FILLED, 'Rewrite text from image.')
  ->addRule($form['captcha']->getValidator(), 'Try it again.')
  ->setFontSize(25)
  ->setLength(10)  // word length  
  ->setTextMargin(20)  // px, set margin on left and right side
  ->setTextColor(\Nette\Image::rgb(0, 0, 0))  // array('red' => 0-255, 'green' => 0-255, 'blue' => 0-255)  
  ->setBackgroundColor(\Nette\Image::rgb(240,240,240))  // array('red' => 0-255, 'green' => 0-255, 'blue' => 0-255)  
  ->setImageHeight(50)  // px, if not set (0), image height will be generated by font size
  ->setImageWidth(0)  // px, if not set (0), image width will be generated by font size
  ->setExpire(10)  // seconds, set expiration time to session
  ->setFilterSmooth(FALSE)  // int or FALSE (disable)
  ->setFilterContrast(FALSE)  // int or FALSE (disable)
  ->useNumbers(FALSE);  // bool or void

Global setting

CaptchaControl::$defaultFontSize = 30;
CaptchaControl::$defaultFilterSmooth = 10;
...