Skip to content

Kollarovic/CaptchaControl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CaptchaControl

Captcha Control for Nette Framework

Requirements

  • **Nette Framework 2.0 Beta
  • PHP 5.3 ( or PHP 5.2 if you remove namespace)

Documentation and Examples

First you must register method addCapcha to Nette\Forms\FormContainer (best place is bootstrap.php)

PavelMaca\Captcha\CaptchaControl::register(Nette\Http\Session $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 text 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) //ms, 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;  
etc...  

Default font file is /fonts/Vera.ttf You can change it by $form['captcha']->setFontFile($path) (or as global CaptchaControl::$defaultFontFile = $path)

About

Captcha Control for Nette Framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%