refbw / uniform-simple-captcha
Simple captcha guard for 'mzur/kirby-uniform' & Kirby v3
Installs: 36
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:kirby-plugin
Requires
- getkirby/composer-installer: ^1.1
- mzur/kirby-uniform: ^5.0
- s1syphos/php-simple-captcha: ^2.1
README
This plugin implements a simple captcha guard for Martin Zurowietz' kirby-uniform
plugin for Kirby v3 - dependency-free & GDPR-friendly, powered by php-simple-captcha
, a fork of Gregwar/Captcha
.
Note: The generated image uses a data URI as its src
attribute, everything else is handled by Kirby's session object.
Getting started
Use one of the following methods to install & use refbw/uniform-simple-captcha
:
Git submodule
If you know your way around Git, you can download this plugin as a submodule:
git submodule add https://codeberg.org/refbw/uniform-simple-captcha.git site/plugins/uniform-simple-captcha
Composer
composer require s1syphos/refbw/uniform-simple-captcha
Clone or download
Usage
Template
There are two helper functions:
simpleCaptcha()
for the captchaimg
tagsimpleCaptchaField()
for itsinput
field
You may use them in your template like so:
# Captcha image # Vanilla <?= simpleCaptcha() ?> # Custom attributes <?= simpleCaptcha(['class' => 'some-class', 'title' => 'solve me!' ]) ?> # Input field <?= simpleCaptchaField() ?> # Custom `id` (eg for use with a label) <label for="my-captcha">Not so fast!</label> <?= simpleCaptchaField('my-captcha', ['class' => 'some-class']) ?>
Controller
After that, you have to enable the guard by calling simplecaptchaGuard()
on the $form
object.
For more information, check out the kirby-uniform
docs on its magic methods:
$form = new Form(); if ($kirby->request()->is('POST')) { # Call security $form->simplecaptchaGuard(); # .. more code }
Configuration
You may change certain options from your config.php
globally ('simple-captcha.optionName'
):
Note:
- RGB = array with RGB values, eg
[0, 255, 0]
- HEX = hexadecimal notation, eg
'#fafafa'
License
This plugin is licensed under the MIT License, but using Kirby in production requires you to buy a license.