Browse Source

add vip for any url share

master
filesite 6 months ago
parent
commit
e8e68dede7
  1. 19
      plugins/Common.php
  2. 7
      themes/tajian/controller/FrontapiController.php
  3. 10
      themes/tajian/views/site/new.php

19
plugins/Common.php

@ -95,8 +95,8 @@ Class Common {
public static function getMappedUsername($cellphone){ public static function getMappedUsername($cellphone){
$username = $cellphone; $username = $cellphone;
if (!empty(FSC::$app['config']['tajia_user_map']) && !empty(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']['tajia_user_map'][$username]; $username = FSC::$app['config']['tajian_user_map'][$username];
}else { }else {
$username = self::getUserId($cellphone); $username = self::getUserId($cellphone);
} }
@ -135,7 +135,7 @@ Class Common {
//用户注册或登录成功时保存用户信息到session //用户注册或登录成功时保存用户信息到session
//login_time, username, friends_code //login_time, username, friends_code
//增加账号映射支持,配置项:tajia_user_map //增加账号映射支持,配置项:tajian_user_map
public static function saveUserIntoSession($cellphone, $friends_code = '') { public static function saveUserIntoSession($cellphone, $friends_code = '') {
if(session_status() !== PHP_SESSION_ACTIVE) { if(session_status() !== PHP_SESSION_ACTIVE) {
session_start(); session_start();
@ -150,6 +150,7 @@ Class Common {
$_SESSION['login_time'] = $login_time; $_SESSION['login_time'] = $login_time;
$_SESSION['username'] = $username; $_SESSION['username'] = $username;
$_SESSION['cellphone'] = $cellphone;
$_SESSION['friends_code'] = $friends_code; $_SESSION['friends_code'] = $friends_code;
//cookie保存 1 年 //cookie保存 1 年
@ -157,7 +158,7 @@ Class Common {
setcookie('friends_code', $friends_code, $login_time + 86400*365, '/'); 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里获取用户数据 //从session里获取用户数据
@ -168,6 +169,7 @@ Class Common {
$login_time = !empty($_SESSION['login_time']) ? $_SESSION['login_time'] : 0; $login_time = !empty($_SESSION['login_time']) ? $_SESSION['login_time'] : 0;
$username = !empty($_SESSION['username']) ? $_SESSION['username'] : ''; $username = !empty($_SESSION['username']) ? $_SESSION['username'] : '';
$cellphone = !empty($_SESSION['cellphone']) ? $_SESSION['cellphone'] : '';
$friends_code = !empty($_SESSION['friends_code']) ? $_SESSION['friends_code'] : ''; $friends_code = !empty($_SESSION['friends_code']) ? $_SESSION['friends_code'] : '';
//尝试从cookie中获取 //尝试从cookie中获取
@ -175,7 +177,14 @@ Class Common {
$friends_code = $_COOKIE['friends_code']; $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() { public static function logoutUserFromSession() {

7
themes/tajian/controller/FrontapiController.php

@ -47,6 +47,7 @@ Class FrontApiController extends SiteController {
* tag: 分类名称 * tag: 分类名称
* tagid: 分类id * tagid: 分类id
* 其中title、tag和tagid为可选值。 * 其中title、tag和tagid为可选值。
* 针对任意网址增加权限控制,只允许特殊用户可以使用。
*/ */
public function actionAddfav() { public function actionAddfav() {
$ip = $this->getUserIp(); $ip = $this->getUserIp();
@ -94,6 +95,12 @@ Class FrontApiController extends SiteController {
$err = '目前只支持抖音、快手、西瓜视频和Bilibili的分享网址哦!'; $err = '目前只支持抖音、快手、西瓜视频和Bilibili的分享网址哦!';
} }
//支持平台之外的网址分享权限控制
if ($platform == '其它' && Common::isVipUser($loginedUser) == false) {
$code = 0;
$err = '你还不是VIP哦,不能分享支持平台之外的网址哦!如需开通特权,请联系客服邮箱。';
}
$tagName = ''; $tagName = '';
if ($code == 1 && (!empty($tag) || !empty($tagid))) { //检查分类名称或id是否存在 if ($code == 1 && (!empty($tag) || !empty($tagid))) { //检查分类名称或id是否存在
$scanner = new DirScanner(); $scanner = new DirScanner();

10
themes/tajian/views/site/new.php

@ -3,8 +3,16 @@
<div class=""> <div class="">
<label for="text_input_link" class="form-label">视频分享网址/文字</label> <label for="text_input_link" class="form-label">视频分享网址/文字</label>
<textarea rows="5" id="text_input_link" name="share_content" placeholder="请粘贴从视频App或网站复制的分享网址/文字(例如在抖音App里,先点击视频的分享图标,再点:复制链接,然后在这里粘贴)"></textarea> <textarea rows="5" id="text_input_link" name="share_content" placeholder="请粘贴从视频App或网站复制的分享网址/文字(例如在抖音App里,先点击视频的分享图标,再点:复制链接,然后在这里粘贴)"></textarea>
<p class="mt10">
目前只支持:
<?php
$supportPlatforms = FSC::$app['config']['tajian']['supportedPlatforms'];
echo implode(',', array_slice($supportPlatforms, 0, -1));
?>
,如需支持其它平台或任意网址,请<a href="mailto://[email protected]">Email联系</a>
</p>
</div> </div>
<div class="mb-3"> <div class="mb-3 mt20">
<label class="form-label">视频分类</label> <label class="form-label">视频分类</label>
<select name="tag"> <select name="tag">
<option value="">选分类</option> <option value="">选分类</option>

Loading…
Cancel
Save