Git Product home page Git Product logo

captcha-control's Introduction

CaptchaControl

Captcha Control for Nette Framework

Requirements

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

Installation

The best way to install is using Composer. Add the following repository to composer.json:

"repositories": [
	{
		"type": "vcs",
		"url": "https://github.com/PavelMaca/CaptchaControl.git"
	}
]

and run:

$ composer require pavelmaca/captcha-control:@dev

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)

captcha-control's People

Contributors

pavelmaca avatar mariancerny avatar peterpp avatar radekdostal avatar matej116 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.