From ee0c2b8a8b4374307303df3f38f810c856fac85a Mon Sep 17 00:00:00 2001 From: filesite Date: Mon, 7 Oct 2024 15:43:27 +0800 Subject: [PATCH] bug fix --- themes/beauty/controller/SiteController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index da32ef9..fa5ef08 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -901,7 +901,7 @@ Class SiteController extends Controller { $expireSeconds = 600; //缓存 10 分钟 $maxFailNum = 5; //最多失败次数 $ipTryData = Common::getCacheFromFile($ipLockKey, $expireSeconds, $lockCacheDir); - if (!empty($ipTryData) && $ipTryData['fail'] >= $maxFailNum) { + if (!empty($ipTryData) && $ipTryData['fail'] >= $maxFailNum && time() - $ipTryData['at'] < $expireSeconds) { $authed = false; $minutes = $expireSeconds/60; $errorMsg = "密码错误已达 {$maxFailNum} 次,请 {$minutes} 分钟后再试!"; @@ -916,7 +916,12 @@ Class SiteController extends Controller { 'fail' => 1, ); }else { - $ipTryData['fail'] ++; + if (time() - $ipTryData['at'] < $expireSeconds) { + $ipTryData['fail'] ++; + }else { + $ipTryData['fail'] = 1; + } + $ipTryData['at'] = time(); } Common::saveCacheToFile($ipLockKey, $ipTryData, $lockCacheDir);