From 95065ceb3f899926b5e784c6075bc48dc43f7eb8 Mon Sep 17 00:00:00 2001 From: filesite Date: Mon, 7 Oct 2024 18:42:49 +0800 Subject: [PATCH] bug fix for pwd authed dirs --- themes/beauty/controller/ListController.php | 27 ++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/themes/beauty/controller/ListController.php b/themes/beauty/controller/ListController.php index 6598cc0..3cf9080 100644 --- a/themes/beauty/controller/ListController.php +++ b/themes/beauty/controller/ListController.php @@ -39,16 +39,34 @@ Class ListController extends Controller { }else if (!empty($cachedParentData)) { $currentDir = $cachedParentData[$cateId]; + //扫描当前目录 + $scanner->setWebRoot($this->getCurrentWebroot($currentDir['realpath'])); + $scanner->setRootDir($currentDir['realpath']); + //密码授权检查 $isAllowed = Common::isUserAllowedToDir($currentDir['directory']); if (!$isAllowed) { $goUrl = "/site/pwdauth/?dir=" . urlencode($currentDir['directory']) . "&back=" . urlencode(FSC::$app['requestUrl']); return $this->redirect($goUrl); } + } - //扫描当前目录 - $scanner->setWebRoot($this->getCurrentWebroot($currentDir['realpath'])); - $scanner->setRootDir($currentDir['realpath']); + //获取目录面包屑 + $breadcrumbs = $this->getBreadcrumbs($currentDir, $cachedParentData, $scanner); + + //父目录密码授权检查 + $isAllowed = true; + $needAuthDir = ''; + foreach($breadcrumbs as $subdir) { + $isAllowed = Common::isUserAllowedToDir($subdir['name']); + if (!$isAllowed) { + $needAuthDir = $subdir['name']; + break; + } + } + if (!$isAllowed && !empty($needAuthDir)) { + $goUrl = "/site/pwdauth/?dir=" . urlencode($needAuthDir) . "&back=" . urlencode(FSC::$app['requestUrl']); + return $this->redirect($goUrl); } @@ -268,9 +286,6 @@ Class ListController extends Controller { } - //获取目录面包屑 - $breadcrumbs = $this->getBreadcrumbs($currentDir, $cachedParentData, $scanner); - $isAdminIp = Common::isAdminIp($this->getUserIp()); //判断是否拥有管理权限 $viewName = '//site/index'; //共享视图