zima/laravel-antibot 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

zima/laravel-antibot

最新稳定版本:1.0.0

Composer 安装命令:

composer require zima/laravel-antibot

包简介

Antibot middleware for site forms

关键字:

README 文档

README

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist zima/laravel-antibot "*"

or add

"zima/laravel-antibot": "*"

Publish config

php artisan vendor:publish --tag=antibot-config

Usage

In published config file, you are able to change names of antibot fields, define list of stop words and decide whether to allow links in your content fields.

    // List of antibot fields which will be added to form
    'fields' => [
        'telephone' => Antibot::TYPE_FIELD_INPUT,
        'verify' => Antibot::TYPE_FIELD_CHECKBOX,
    ],
    // Whether to allow links in form fields
    'allow_links' => false,
    // List of words for detecting bot
    'stop_list' => [
        'погиб', 'плен', 'украин', 'акци', 'скидк', 'всу', 'вооружен',
        'вооруж', 'силы', 'сил', 'солдат', 'биткоин', 'помощь', 'помощ', 'боев',
        'деньг', 'денег', 'free', 'sale', 'porn',
    ],

Please configure your presets if necessary

    'feedback' => [
        'required_fields' => ['name', 'email'], // bot is detected if these fields are empty
        'content_fields' => ['description'],    // fields in which spam is searched (ignored if empty or not specified)
        'allow_links' => true,                  // use it if you need to overwrite global 'allow_links
    ],

Use parameter required_fields when you need to define fields that should not be empty.

Use parameter content_fields when you need to define the fields where words form config "stop_list" will be searched for.

Use parameter allow links when you need to overwrite global param allow_links for special preset.

All params within preset are optional, if they are not defined or empty this level of bot-check will be ignored.

Use dot notation for nested fields e.g. for fields named MyForm['text'] use 'MyForm.text'.

Assign middleware to route

Route::match(['get', 'post'], '/test', [TestController::class, 'index'])
    ->name('test')
    ->middleware('antibot:feedback');

# or without preset for base level of antibot detecting only

Route::match(['get', 'post'], '/test', [TestController::class, 'index'])
    ->name('test')
    ->middleware('antibot');

Output the Antibot use Blade Component

You can use the output component, please add it inside form tags:

<form>
    <x-zima-antibot/>

    <button type="submit">Save</button>
</form>

License

MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-21