add admin cookie check
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* BotLimiter - Smart Traffic Control
|
||||
* @author Panariga
|
||||
@@ -8,9 +9,18 @@ if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/classes/RuleManager.php';
|
||||
require_once dirname(__FILE__) . '/classes/BotLogger.php';
|
||||
|
||||
spl_autoload_register(function ($className) {
|
||||
$classFile = _PS_MODULE_DIR_ . 'botlimiter/classes/' . $className . '.php';
|
||||
if (file_exists($classFile)) {
|
||||
require_once $classFile;
|
||||
}
|
||||
});
|
||||
spl_autoload_register(function ($className) {
|
||||
$classFile = _PS_MODULE_DIR_ . 'botlimiter/classes/rules' . $className . '.php';
|
||||
if (file_exists($classFile)) {
|
||||
require_once $classFile;
|
||||
}
|
||||
});
|
||||
class BotLimiter extends Module
|
||||
{
|
||||
public function __construct()
|
||||
@@ -30,12 +40,15 @@ class BotLimiter extends Module
|
||||
|
||||
public function install()
|
||||
{
|
||||
return parent::install() &&
|
||||
return parent::install() &&
|
||||
$this->registerHook('actionFrontControllerInitBefore');
|
||||
}
|
||||
|
||||
public function hookActionFrontControllerInitBefore($params)
|
||||
{
|
||||
if (!empty((new Cookie('psAdmin'))->id_employee)) {
|
||||
return; // Don't display the tag for logged-in administrators
|
||||
}
|
||||
// 1. Skip if we are currently ON the verification page to avoid loops
|
||||
if ($this->context->controller instanceof BotLimiterVerifyModuleFrontController) {
|
||||
return;
|
||||
@@ -47,10 +60,11 @@ class BotLimiter extends Module
|
||||
// 3. Register Rules (Add more here in future)
|
||||
$manager->addRule(new HeadRequestRule());
|
||||
$manager->addRule(new FilterTrapRule());
|
||||
|
||||
$manager->addRule(new ScanBotsRule());
|
||||
$manager->addRule(new RateLimitRule());
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user