From d8a2c8c82b9ed98c9e7ccee359cad414579797ca Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Sat, 7 Oct 2023 14:14:25 +0300 Subject: [PATCH] =?UTF-8?q?[+]=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=84=D0=B3=D0=B0=D0=BB=20=D0=B8=D1=81=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?DDoS=20Guard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/config.php | 7 +++++++ core/lib/Core/Helpers/DDosProtection.class.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/config.php b/core/config.php index b884ed4..144af13 100644 --- a/core/config.php +++ b/core/config.php @@ -215,3 +215,10 @@ if (!defined('USE_CAPTCHA')) { define('USE_CAPTCHA', true); } + + /** + * Флаг использования защиты от DDoS + */ + if (!defined('USE_DDOS_PROTECTION')) { + define('USE_DDOS_PROTECTION', false); + } diff --git a/core/lib/Core/Helpers/DDosProtection.class.php b/core/lib/Core/Helpers/DDosProtection.class.php index d9d2cac..9a84c28 100644 --- a/core/lib/Core/Helpers/DDosProtection.class.php +++ b/core/lib/Core/Helpers/DDosProtection.class.php @@ -94,7 +94,7 @@ $DB = DB::getInstance(); $item = $DB->getItem(self::TABLE, ['observed_key' => $this->observedKey]); if ($item) { - if ($item['attempts'] >= $item['attempts_limit'] && (time() - $item['last_active']) <= $item['time_interval']) { + if (USE_DDOS_PROTECTION && $item['attempts'] >= $item['attempts_limit'] && (time() - $item['last_active']) <= $item['time_interval']) { echo '
'; echo 'You are temporarily blocked (DDoS Guard))
'; echo 'Due to a large number of requests, you are temporarily blocked.
If this happened by mistake, contact the resource administrator.
';