Obsah
Captcha form control
With this plugin you can insert a simple form Turing test.
Try a 3D version of this component.
| Release | 0.1 |
| Download | Captcha-v0.1.zip (5 KB) |
| Forum thread | http://forum.nettephp.com/-control form ... |
| Author | Vítězslav Plachy |
| License | WTFPL |
Installation
Ke is necessary to add the following files:
-
Captcha.php - main body of the definition of control form
- 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)
- By default, looks in the
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, we 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' ); When the form is gradually drawing a picture and text box to process separately:
Obrázek: { != $form [ 'captcha' ]->getImage() }
Pole: { != $form [ 'captcha' ]->getInput() }
Obojí najednou: { != $form [ 'captcha' ]->getControl() }
Připojené soubory
- captcha-v0.1.zip 5 kB



