Skip to content

Bot Blocker plugin for Flowaxy CMS provides automatic blocking of bots and automated scripts from accessing your website. The plugin analyzes User-Agent headers and blocks suspicious requests while allowing legitimate search engine crawlers.

Notifications You must be signed in to change notification settings

flowaxy/bot-blocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bot Blocker Plugin

Version: 1.0.0
Author: FlowAxy
Developer: iTeffa (iteffa@flowaxy.com)
Studio: FlowAxy
Website: https://flowaxy.com
License: Proprietary

Description

Bot Blocker plugin for Flowaxy CMS provides automatic blocking of bots and automated scripts from accessing your website. The plugin analyzes User-Agent headers and blocks suspicious requests while allowing legitimate search engine crawlers.

Features

Core Features

  • πŸ›‘οΈ Automatic Bot Detection β€” Analyzes User-Agent strings to identify bots
  • 🚫 Blocking System β€” Blocks suspicious requests with 403 Forbidden
  • βœ… Allowed Bots List β€” Configure which bots should have access (e.g., Google, Bing, Yandex)
  • πŸ“Š Statistics β€” View blocking statistics and top blocked IPs
  • πŸ“ Logging β€” All blocked requests are logged to the database
  • βš™οΈ Settings Page β€” Easy configuration through admin panel
  • πŸ”’ Admin Panel Protected β€” Admin panel and API are always accessible

Technical Capabilities

  • Early request interception via handle_early_request hook
  • Pattern-based bot detection
  • Database-backed settings and logging
  • Integration with Flowaxy CMS access control system

Requirements

  • PHP >= 8.4.0
  • Flowaxy CMS with plugin support
  • MySQL/MariaDB database
  • Admin access for configuration

Installation

  1. Copy the plugin directory to plugins/bot-blocker/.
  2. Activate the plugin via the admin panel (Settings β†’ Plugins).
  3. The plugin will automatically create necessary database tables.

The plugin will automatically register its route and menu item upon activation.

Usage

Accessing the Settings Page

  1. Log in to the admin panel.
  2. Navigate to System β†’ Блокування Π±ΠΎΡ‚Ρ–Π² in the menu.
  3. Or go directly to /admin/bot-blocker.

Configuration

Enable/Disable Blocking

  • Toggle the "Π£Π²Ρ–ΠΌΠΊΠ½ΡƒΡ‚ΠΈ блокування Π±ΠΎΡ‚Ρ–Π²" switch to enable or disable bot blocking.

Allowed Bots

Add bots that should have access to your website (one per line):

googlebot
bingbot
yandexbot
baiduspider

These bots will bypass the blocking system.

How It Works

  1. Request Interception β€” All incoming requests (except admin/API) are intercepted early in the request lifecycle.

  2. User-Agent Analysis β€” The plugin analyzes the User-Agent header to identify bots.

  3. Pattern Matching β€” Known bot patterns are checked:

    • Social media bots (Facebook, Twitter, LinkedIn, etc.)
    • Scrapers and crawlers
    • Automated tools (curl, wget, Python requests, etc.)
    • Archive bots
  4. Allowed Bots Check β€” If the bot is in your allowed list, it's permitted.

  5. Blocking β€” Suspicious bots receive a 403 Forbidden response and are logged.

Statistics

The plugin provides:

  • Today's Blocks β€” Number of bots blocked today
  • Total Blocks β€” Total number of blocked requests
  • Top Blocked IPs β€” IP addresses with the most blocked attempts

Plugin Structure

bot-blocker/
β”œβ”€β”€ assets/
β”‚   └── styles/
β”‚       └── bot-blocker.css    # Styles for the settings page
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   └── pages/
β”‚   β”‚       └── BotBlockerAdminPage.php  # Admin settings page
β”‚   └── Services/
β”‚       └── BotBlockerService.php        # Core blocking service
β”œβ”€β”€ templates/
β”‚   └── bot-blocker.php                  # Settings page template
β”œβ”€β”€ init.php                             # Plugin initialization
β”œβ”€β”€ plugin.json                          # Plugin metadata
└── README.md                            # Documentation

Technical Details

Architecture

The plugin uses a service-oriented architecture:

  • BotBlockerService β€” Core service for bot detection and blocking
  • BotBlockerAdminPage β€” Admin panel page for configuration
  • Templates β€” PHP templates for HTML rendering

Database Tables

bot_blocker_logs

Logs all blocked requests:

  • id β€” Unique identifier
  • ip_address β€” IP address of blocked request
  • user_agent β€” User-Agent string
  • url β€” Requested URL
  • blocked_at β€” Block timestamp
  • created_at β€” Creation timestamp

Security

  • βœ… CSRF protection for all write operations
  • βœ… Access permission checks before executing operations
  • βœ… Admin panel and API are always accessible
  • βœ… SQL injection protection via prepared statements
  • βœ… XSS protection via output sanitization

Bot Detection Patterns

The plugin detects bots by checking for common patterns in User-Agent strings:

  • Social media bots: facebookexternalhit, twitterbot, linkedinbot, etc.
  • Scrapers: scrape, crawl, spider, bot
  • Automated tools: curl, wget, python-requests, java, etc.
  • Archive bots: archive, wayback, ia_archiver

Hooks

The plugin uses the following hooks:

  • handle_early_request (priority: 1) β€” Early request interception for blocking
  • admin_register_routes β€” Register admin route
  • admin_menu β€” Add menu item

Configuration

Default Behavior

By default, the plugin:

  • Blocks all bots except those in the allowed list
  • Allows admin panel and API access
  • Logs all blocked requests
  • Blocks empty User-Agent strings

Customization

You can customize bot detection by:

  1. Adding allowed bots in the admin panel
  2. Modifying bot patterns in BotBlockerService::initializeBotPatterns()
  3. Adjusting blocking logic in BotBlockerService::isBot()

Development

Dependencies

The plugin uses the following components from the Engine:

  • engine/core/support/base/BasePlugin.php
  • engine/core/support/helpers/DatabaseHelper.php
  • engine/interface/admin-ui/includes/AdminPage.php
  • engine/core/support/helpers/UrlHelper.php
  • engine/core/support/helpers/SecurityHelper.php

Extending Functionality

To extend the plugin:

  1. Add new bot patterns β€” Edit initializeBotPatterns() in BotBlockerService.php
  2. Customize blocking logic β€” Modify isBot() method
  3. Add new statistics β€” Extend getBlockStats() method
  4. Customize UI β€” Edit templates/bot-blocker.php and assets/styles/bot-blocker.css

Support

If you find a bug or have questions:

  1. Check log files for errors
  2. Verify database tables are created
  3. Ensure PHP has proper permissions

Testing Bot Blocking

Quick Visual Test

The easiest way to test bot blocking is using curl:

# Test 1: Normal browser (should pass)
curl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" http://your-domain.com/
# Expected: HTTP 200

# Test 2: Bot (should be blocked)
curl -A "TestBot/1.0" http://your-domain.com/
# Expected: HTTP 403

# Test 3: Empty User-Agent (should be blocked)
curl -A "" http://your-domain.com/
# Expected: HTTP 403

License

Proprietary. All rights reserved.

Version History

1.0.0 (2025-11-29)

  • ✨ Initial release
  • βœ… Bot detection and blocking
  • βœ… Admin settings page
  • βœ… Statistics and logging
  • βœ… Allowed bots configuration
  • βœ… Integration with Flowaxy CMS Engine
  • βœ… Database timezone support

Author

FlowAxy
Developer: iTeffa
Email: iteffa@flowaxy.com
Studio: flowaxy.com
Website: https://flowaxy.com


Developed with ❀️ for Flowaxy CMS

About

Bot Blocker plugin for Flowaxy CMS provides automatic blocking of bots and automated scripts from accessing your website. The plugin analyzes User-Agent headers and blocks suspicious requests while allowing legitimate search engine crawlers.

Topics

Resources

Stars

Watchers

Forks