Simple Captcha
Klub ships a lightweight captcha using php-simple-captcha and a dedicated endpoint. Use this page if you want a simple built-in challenge without third-party services.
Configuration
<?php
return [
'bnomei.klub.captcha.set' => function () {
$builder = new \SimpleCaptcha\Builder;
$builder->bgColor = '#FFFFFF';
$builder->lineColor = '#FFFFFF';
$builder->textColor = '#000000';
$builder->applyEffects = false;
$builder->build();
kirby()->session()->set('captcha', $builder->phrase);
return ['captcha' => $builder->inline()];
},
];
Render and validate
- Fetch the captcha image from
GET /klub/captcha. - Post the user input as
captchawith your form. klub()->captcha()compares the response with the stored phrase.
Keep CSRF checks enabled even when using captcha.