From fbdaa4322ab36d57b840c1463e2fe1f000b91805 Mon Sep 17 00:00:00 2001 From: filesite Date: Thu, 9 May 2024 15:33:47 +0000 Subject: [PATCH] add current user exist check --- plugins/Common.php | 7 +++++++ themes/tajian/controller/SiteController.php | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/plugins/Common.php b/plugins/Common.php index 8bfddec..89c0f7b 100644 --- a/plugins/Common.php +++ b/plugins/Common.php @@ -109,6 +109,13 @@ Class Common { return is_dir($userDir) ? $userDir : false; } + //判断当前用户数据目录是否存在 + public static function existCurrentUser() { + $rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory']; + + return is_dir($rootDir); + } + //检查朋友的邀请码是否存在 public static function existFriendsCode($code) { if (self::isFriendsCode($code) == false) {return false;} diff --git a/themes/tajian/controller/SiteController.php b/themes/tajian/controller/SiteController.php index d46f3d1..0b0364f 100644 --- a/themes/tajian/controller/SiteController.php +++ b/themes/tajian/controller/SiteController.php @@ -15,6 +15,11 @@ Class SiteController extends Controller { //如果没有开启多用户支持,或者当前用户不为空 if (empty(FSC::$app['config']['multipleUserUriParse']) || !empty(FSC::$app['user_id'])) { + if (!empty(FSC::$app['user_id']) && Common::existCurrentUser() == false) { + $user_id = FSC::$app['user_id']; + throw new Exception("你要访问的用户 {$user_id} 收藏夹不存在!", 404); + } + return $this->renderFavVideos(); }else { return $this->renderTajianIndex();