承接 expl0it3r/kirby-uniform-recaptcha 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

expl0it3r/kirby-uniform-recaptcha

Composer 安装命令:

composer require expl0it3r/kirby-uniform-recaptcha

包简介

Kirby 3/4/5 reCAPTCHA guard for the Uniform plugin

README 文档

README

A Kirby 3, 4 & 5 plugin implementing a Google reCAPTCHA v3 guard for the Uniform plugin.

Installation

Download

  • Download the repository
  • Extract the content to site/plugins/uniform-recaptcha

Git Submodule

Add the plugin as Git submodule:

git submodule add https://github.com/eXpl0it3r/kirby-uniform-recaptcha.git site/plugins/uniform-recaptcha

Composer

Add the plugin to your repository:

composer require expl0it3r/kirby-uniform-recaptcha

Configuration

Set the configuration in your config.php file:

return [
  'expl0it3r.uniform-recaptcha.siteKey' => 'my-site-key',
  'expl0it3r.uniform-recaptcha.secretKey' => 'my-secret-key',
  'expl0it3r.uniform-recaptcha.acceptableScore' => 0.5
];
  • siteKey & secretKey can be found on the reCAPTCHA admin page
  • acceptableScore is the minimum score in range 0.0 to 1.0 (default 0.5) required to accept the form submission, see the reCAPTCHA documentation
  • hostname is optional (default empty / disabled). When set, the guard additionally checks that the hostname returned by Google matches this value.

Usage

Template

reCAPTCHA v3 runs invisibly and requires the form submission to happen through JavaScript. Add the recaptchaField() helper inside your <form> and the recaptchaScript() helper somewhere on the page (e.g. before </body>):

<?= recaptchaField() ?>

recaptchaField() outputs a hidden input and a small script that, on submit, obtains a reCAPTCHA token and resubmits the form. It binds to its own form via the submit event, so:

  • It works no matter how the form is submitted (button click or the Enter key).
  • You keep full control over your markup — use any <button type="submit"> you like.
  • No form id is required, and it can be used for multiple forms on the same page.
  • The original submit button's name/value is preserved (via requestSubmit()), so server-side form routing keeps working.

In order for reCAPTCHA to work, you need to load the reCAPTCHA JavaScript file from Google. Either include the script yourself (with the render parameter set to your site key) or use the helper function recaptchaScript().

Example

<form action="<?= $page->url() ?>" method="post">
    <label for="name" class="required">Name</label>
    <input<?php if ($form->error('name')): ?> class="erroneous"<?php endif; ?> name="name" type="text" value="<?= $form->old('name') ?>">

    <!-- ... -->

    <?= csrf_field() ?>
    <?= recaptchaField() ?>
    <button type="submit">Submit</button>
</form>
<?= recaptchaScript() ?>

Deprecated: recaptchaButton('Submit', 'btn', 'ContactForm') is still available for backwards compatibility but no longer recommended. It relies on reCAPTCHA's data-callback flow, which does not trigger on Enter-key submits and requires knowing the form id. Use recaptchaField() instead.

Controller

In your controller you can use the magic method recaptchaGuard() to enable the reCAPTCHA guard:

$form = new Form(/* ... */);

if ($kirby->request()->is('POST'))
{
    $form->recaptchaGuard()
         ->emailAction(/* ... */);
}

Credits

  • Thanks to Johannes Pichler for the Kirby 2 plugin!
  • A million thanks to the whole Kirby Team! ❤

统计信息

  • 总下载量: 181
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固