EN | CS | Login | Register

(this page is translated by Google; We're working hard on a human translation)

Captcha Form Control

With this plugin you can insert a simple form Turing test .

Also try the 3D version of this component .

Version 0.1
Download Captcha-v0.1.zip (5 KB)
Forum Thread http://forum.nette.org/-control form ...
Author Vitezslav Plachy
License WTFPL

Installation

Application must add the following files:

Captcha.php
main body of the definition of control forms
Example location: libs/Nette.Extras/Captcha
CaptchaPresenter.php
presenter pictures with letters
Place the directory with the presenter, such as app/presenters
font.ttf
font used for text in the image (try the Bitstream Vera )
normally be looking at app/font.ttf

Example Usage

Parameters can be set for each instance separately, or globally:

 // soubor s použitým písmem 
Captcha:: $defaultFont = '%appDir%/Vera.ttf' ;

// velikost fontu pro písmena v obrázku
Captcha:: $defaultFontSize = 30 ;

// počet písmen v obrázku
Captcha:: $defaultLength = 5 ;

// šířka obrázku v pixelech
Captcha:: $defaultWidth = 200 ;

// výšku obrázku svěříme autodetekci
Captcha:: $defaultHeight = 0 ;

// černý text
Captcha:: $defaultTextColor = Image::rgb( 0 , 0 , 0 );

// na bílém pozadí
Captcha:: $defaultBgColor = Image::rgb( 255 , 255 , 255 );

// v případě AppForm nastavíme masku odkazu na presenter obrázků
Captcha:: $defaultLinkMask = 'Captcha:show' ;

After loading the class can use the method Form::addCaptcha :

 // class_exists("Captcha"); 

$form = new AppForm( $this , 'captcha' );
$form ->addCaptcha( 'captcha' , 'Antispam' )
->setTextColor(Image::rgb( 255 , 0 , 0 ))
->addRule( 'Captcha::validateValid' , 'Opište správně písmena z obrázku.' );

Before rendering, you can access individual elements of the prototypes:

 // obalovací div 
$container = $form [ 'captcha' ]->getContainerPrototype();

// HTML element obrázku
$image = $form [ 'captcha' ]->getImagePrototype();

// textovému poli přidáme třídu 'captcha'
$form [ 'captcha' ]->getControlPrototype()-> class ( 'captcha' );

In the progressive form may render an image and text box to process separately:

 Obrázek: { != $form [ 'captcha' ]->getImage() } 
Pole: { != $form [ 'captcha' ]->getInput() }

Obojí najednou: { != $form [ 'captcha' ]->getControl() }

Připojené soubory


Login to submit a comment