Files
botlimiter/botlimiter.php
2025-12-07 13:58:49 +02:00

56 lines
1.6 KiB
PHP

<?php
/**
* BotLimiter - Smart Traffic Control
* @author Panariga
*/
if (!defined('_PS_VERSION_')) {
exit;
}
require_once dirname(__FILE__) . '/classes/RuleManager.php';
require_once dirname(__FILE__) . '/classes/BotLogger.php';
class BotLimiter extends Module
{
public function __construct()
{
$this->name = 'botlimiter';
$this->tab = 'administration';
$this->version = '1.0.0';
$this->author = 'Panariga';
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Bot Limiter & Firewall');
$this->description = $this->l('Intelligent protection against faceted search scrapers.');
}
public function install()
{
return parent::install() &&
$this->registerHook('actionFrontControllerInitBefore');
}
public function hookActionFrontControllerInitBefore($params)
{
// 1. Skip if we are currently ON the verification page to avoid loops
if ($this->context->controller instanceof BotLimiterVerifyModuleFrontController) {
return;
}
// 2. Initialize Manager
$manager = new RuleManager($this->context);
// 3. Register Rules (Add more here in future)
$manager->addRule(new HeadRequestRule());
$manager->addRule(new FilterTrapRule());
// 4. Execute Rules
// If a rule returns FALSE, it means traffic is blocked or redirected.
// The rule is responsible for the redirect/exit.
$manager->process();
}
}