From e8e68dede7dc36c6aaed6577018a390e91ee1324 Mon Sep 17 00:00:00 2001 From: filesite Date: Mon, 20 May 2024 07:19:51 +0800 Subject: [PATCH] add vip for any url share --- plugins/Common.php | 19 ++++++++++++++----- .../tajian/controller/FrontapiController.php | 7 +++++++ themes/tajian/views/site/new.php | 10 +++++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/plugins/Common.php b/plugins/Common.php index 45e03ff..de13db1 100644 --- a/plugins/Common.php +++ b/plugins/Common.php @@ -95,8 +95,8 @@ Class Common { public static function getMappedUsername($cellphone){ $username = $cellphone; - if (!empty(FSC::$app['config']['tajia_user_map']) && !empty(FSC::$app['config']['tajia_user_map'][$username])) { - $username = FSC::$app['config']['tajia_user_map'][$username]; + if (!empty(FSC::$app['config']['tajian_user_map']) && !empty(FSC::$app['config']['tajian_user_map'][$username])) { + $username = FSC::$app['config']['tajian_user_map'][$username]; }else { $username = self::getUserId($cellphone); } @@ -135,7 +135,7 @@ Class Common { //用户注册或登录成功时保存用户信息到session //login_time, username, friends_code - //增加账号映射支持,配置项:tajia_user_map + //增加账号映射支持,配置项:tajian_user_map public static function saveUserIntoSession($cellphone, $friends_code = '') { if(session_status() !== PHP_SESSION_ACTIVE) { session_start(); @@ -150,6 +150,7 @@ Class Common { $_SESSION['login_time'] = $login_time; $_SESSION['username'] = $username; + $_SESSION['cellphone'] = $cellphone; $_SESSION['friends_code'] = $friends_code; //cookie保存 1 年 @@ -157,7 +158,7 @@ Class Common { setcookie('friends_code', $friends_code, $login_time + 86400*365, '/'); } - return compact('login_time', 'username', 'friends_code'); + return compact('login_time', 'username', 'friends_code', 'cellphone'); } //从session里获取用户数据 @@ -168,6 +169,7 @@ Class Common { $login_time = !empty($_SESSION['login_time']) ? $_SESSION['login_time'] : 0; $username = !empty($_SESSION['username']) ? $_SESSION['username'] : ''; + $cellphone = !empty($_SESSION['cellphone']) ? $_SESSION['cellphone'] : ''; $friends_code = !empty($_SESSION['friends_code']) ? $_SESSION['friends_code'] : ''; //尝试从cookie中获取 @@ -175,7 +177,14 @@ Class Common { $friends_code = $_COOKIE['friends_code']; } - return compact('login_time', 'username', 'friends_code'); + return compact('login_time', 'username', 'friends_code', 'cellphone'); + } + + public static function isVipUser($loginedUser) { + $vipUsers = FSC::$app['config']['tajian_vip_user']; + if (empty($vipUsers)) {return false;} + + return !empty($loginedUser['cellphone']) && in_array($loginedUser['cellphone'], $vipUsers); } public static function logoutUserFromSession() { diff --git a/themes/tajian/controller/FrontapiController.php b/themes/tajian/controller/FrontapiController.php index 149a094..9b766c3 100644 --- a/themes/tajian/controller/FrontapiController.php +++ b/themes/tajian/controller/FrontapiController.php @@ -47,6 +47,7 @@ Class FrontApiController extends SiteController { * tag: 分类名称 * tagid: 分类id * 其中title、tag和tagid为可选值。 + * 针对任意网址增加权限控制,只允许特殊用户可以使用。 */ public function actionAddfav() { $ip = $this->getUserIp(); @@ -94,6 +95,12 @@ Class FrontApiController extends SiteController { $err = '目前只支持抖音、快手、西瓜视频和Bilibili的分享网址哦!'; } + //支持平台之外的网址分享权限控制 + if ($platform == '其它' && Common::isVipUser($loginedUser) == false) { + $code = 0; + $err = '你还不是VIP哦,不能分享支持平台之外的网址哦!如需开通特权,请联系客服邮箱。'; + } + $tagName = ''; if ($code == 1 && (!empty($tag) || !empty($tagid))) { //检查分类名称或id是否存在 $scanner = new DirScanner(); diff --git a/themes/tajian/views/site/new.php b/themes/tajian/views/site/new.php index 8a13b25..b6ef41b 100644 --- a/themes/tajian/views/site/new.php +++ b/themes/tajian/views/site/new.php @@ -3,8 +3,16 @@
+

+ 目前只支持: + + ,如需支持其它平台或任意网址,请Email联系。 +

-
+