PHP code example of radekdostal / nette-captchacontrol

1. Go to this page and download the library: Download radekdostal/nette-captchacontrol library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

radekdostal / nette-captchacontrol example snippets


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

$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

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