Website ๐ contributte.org | Contact ๐จ๐ปโ๐ป f3l1x.io | Twitter ๐ฆ @contributte
| This project is no longer being maintained. |
|---|
| Composer | contributte/seznamcaptcha |
|---|---|
| Version | |
| PHP | |
| License |
To install latest version of contributte/seznamcaptcha use Composer.
composer require contributte/seznamcaptchaextensions:
captcha: Contributte\SeznamCaptcha\DI\SeznamCaptchaExtensionBy 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 | xmlrpcJust 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;
}{control form}It needs a CaptchaContainer consists of 2 inputs image and code.
<form n:name="form">
{input captcha-image}
{input captcha-code}
</form>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.
| 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 |
This package was maintained by these authors.
Consider to support contributte development team. Also thank you for using this package.
Seznam captcha (security) for Nette Framework \ Forms