minetro / seznamcaptcha
SeznamCaptcha to Nette Framework
Fund package maintenance!
f3l1x
contributte.org/partners.html
Installs: 4 034
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 2
Open Issues: 0
pkg:composer/minetro/seznamcaptcha
Requires
- php: >=7.2
- nette/di: ^3.0.6
- nette/forms: ^3.0.7
Requires (Dev)
- ninjify/nunjuck: ^0.4
- ninjify/qa: ^0.12
- phpstan/phpstan: ^0.12
- phpstan/phpstan-deprecation-rules: ^0.12
- phpstan/phpstan-nette: ^0.12
- phpstan/phpstan-strict-rules: ^0.12
README
Website 🚀 contributte.org | Contact 👨🏻💻 f3l1x.io | Twitter 🐦 @contributte
Disclaimer
| ⚠️ | This project is no longer being maintained. |
|---|
| Composer | contributte/seznamcaptcha |
|---|---|
| Version | |
| PHP | |
| License |
Usage
To install latest version of contributte/seznamcaptcha use Composer.
composer require contributte/seznamcaptcha
Configuration
Extension Registration
extensions: captcha: Contributte\SeznamCaptcha\DI\SeznamCaptchaExtension
Options
By default is auto: on and method: http, you can disable it and bind addCaptcha to your forms by yourself.
captcha: auto: off # on | off method: xmlrpc # http | xmlrpc
Form
Just register an extension and keep auto argument as it is.
use Nette\Application\UI\Form; protected function createComponentForm() { $form = new Form(); $form->addCaptcha('captcha') ->setRequired('Are you robot?'); $form->addSubmit('send'); $form->onSuccess[] = function (Form $form) { dump($form['captcha']); }; return $form; }
Rendering
Automatic
{control form}
Manual
It needs a CaptchaContainer consists of 2 inputs image and code.
<form n:name="form"> {input captcha-image} {input captcha-code} </form>
Advanced Example
use Minetro\SeznamCaptcha\Forms\CaptchaHash; use Minetro\SeznamCaptcha\Forms\CaptchaImage; use Minetro\SeznamCaptcha\Forms\CaptchaInput; use Minetro\SeznamCaptcha\Provider\CaptchaValidator; use Minetro\SeznamCaptcha\Provider\ProviderFactory; use Nette\Application\UI\Form; /** @var ProviderFactory @inject */ public $providerFactory; protected function createComponentForm() { $form = new Form(); $provider = $this->providerFactory->create(); $form['image'] = new CaptchaImage('Captcha', $provider); $form['hash'] = new CaptchaHash($provider); $form['code'] = new CaptchaInput('Code'); $form->addSubmit('send'); $form->onValidate[] = function (Form $form) use ($provider) { $validator = new CaptchaValidator($provider); $hash = $form['hash']->getHttpHash(); $code = $form['code']->getHttpCode(); if ($validator->validate($code, $hash) !== TRUE) { $form->addError('Are you robot?'); } }; $form->onSuccess[] = function (Form $form) { dump($form); }; return $form; }
For better usability add this functionality to your BaseForms, BaseFormFactory or
something like this. You can also create a trait for it.
Versions
| State | Version | Branch | Nette | PHP |
|---|---|---|---|---|
| dev | ^0.6 |
master |
3.0+ | >=7.2 |
| stable | ^0.5 |
master |
3.0+ | >=7.2 |
| stable | ^0.4 |
master |
2.4+ | >=5.6 |
Development
This package was maintained by these authors.
Consider to support contributte development team. Also thank you for using this package.