diff --git a/app/Controllers/LinkController.php b/app/Controllers/LinkController.php index 670c0812..5d37586b 100644 --- a/app/Controllers/LinkController.php +++ b/app/Controllers/LinkController.php @@ -453,6 +453,10 @@ class LinkController extends BaseController } } if ($quantumult == 1) { + $extend = isset($opts['extend']) ? $opts['extend'] : 0; + $v2ray_group .= ($extend == 0 + ? '' + : URL::getUserInfo($user, 'quantumult_v2', 0) . PHP_EOL); return base64_encode($v2ray_group); } elseif ($quantumult == 3) { $ss_group = ''; @@ -762,6 +766,10 @@ class LinkController extends BaseController . PHP_EOL . 'REMARKS=' . Config::get('appName') . PHP_EOL); + + $extend = isset($opts['extend']) ? $opts['extend'] : 0; + $return .= ($extend == 0 ? '' : URL::getUserInfo($user, 'ssr', 0) . PHP_EOL); + // v2ray $items = URL::getAllVMessUrl($user, 1); foreach ($items as $item) { @@ -877,7 +885,7 @@ class LinkController extends BaseController // 账户到期时间以及流量信息 $extend = isset($opts['extend']) ? (int) $opts['extend'] : 0; - $return .= $extend == 0 ? '' : URL::getUserTraffic($user, 2) . PHP_EOL; + $return .= $extend == 0 ? '' : URL::getUserInfo($user, 'ss', 1) . PHP_EOL; // v2ray $items = URL::getAllVMessUrl($user, 1, $emoji); @@ -953,12 +961,13 @@ class LinkController extends BaseController public static function getSub($user, $sub, $opts, $Rule, $find, $emoji) { $extend = isset($opts['extend']) ? $opts['extend'] : 0; + $traffic_class_expire = 1; $getV2rayPlugin = 1; $return_url = ''; // Quantumult 则不显示账户到期以及流量信息 if (strpos($_SERVER['HTTP_USER_AGENT'], 'Quantumult') !== false) { - $extend = 0; + $traffic_class_expire = 0; } // 如果是 Kitsunebi 不输出 SS V2rayPlugin 节点 @@ -967,24 +976,24 @@ class LinkController extends BaseController } switch ($sub) { case 1: // SSR - $return_url .= $extend == 0 ? '' : URL::getUserTraffic($user, 1) . PHP_EOL; + $return_url .= $extend == 0 ? '' : URL::getUserInfo($user, 'ssr', $traffic_class_expire) . PHP_EOL; $return_url .= URL::get_NewAllUrl($user, 0, $getV2rayPlugin, $Rule, $find, $emoji) . PHP_EOL; break; case 2: // SS - $return_url .= $extend == 0 ? '' : URL::getUserTraffic($user, 2) . PHP_EOL; + $return_url .= $extend == 0 ? '' : URL::getUserInfo($user, 'ss', $traffic_class_expire) . PHP_EOL; $return_url .= URL::get_NewAllUrl($user, 1, $getV2rayPlugin, $Rule, $find, $emoji) . PHP_EOL; break; case 3: // V2 - $return_url .= $extend == 0 ? '' : URL::getUserTraffic($user, 3) . PHP_EOL; + $return_url .= $extend == 0 ? '' : URL::getUserInfo($user, 'v2ray', $traffic_class_expire) . PHP_EOL; $return_url .= URL::getAllVMessUrl($user, 0, $emoji) . PHP_EOL; break; case 4: // V2 + SS - $return_url .= $extend == 0 ? '' : URL::getUserTraffic($user, 3) . PHP_EOL; + $return_url .= $extend == 0 ? '' : URL::getUserInfo($user, 'v2ray', $traffic_class_expire) . PHP_EOL; $return_url .= URL::getAllVMessUrl($user, 0, $emoji) . PHP_EOL; $return_url .= URL::get_NewAllUrl($user, 1, $getV2rayPlugin, $Rule, $find, $emoji) . PHP_EOL; break; case 5: // V2 + SS + SSR - $return_url .= $extend == 0 ? '' : URL::getUserTraffic($user, 1) . PHP_EOL; + $return_url .= $extend == 0 ? '' : URL::getUserInfo($user, 'ssr', $traffic_class_expire) . PHP_EOL; $return_url .= URL::getAllVMessUrl($user, 0, $emoji) . PHP_EOL; $return_url .= URL::get_NewAllUrl($user, 1, $getV2rayPlugin, $Rule, $find, $emoji) . PHP_EOL; $return_url .= URL::get_NewAllUrl($user, 0, $getV2rayPlugin, $Rule, $find, $emoji) . PHP_EOL; diff --git a/app/Utils/URL.php b/app/Utils/URL.php index 65657343..91b65584 100644 --- a/app/Utils/URL.php +++ b/app/Utils/URL.php @@ -754,36 +754,49 @@ class URL return clone $user; } - public static function getUserTraffic($user, $type) + public static function getUserInfo($user, $type, $traffic_class_expire) { - $group_name = Config::get('appName'); - if (strtotime($user->expire_in) > time()) { - if ($user->transfer_enable == 0) { - $userTraffic = '剩余流量:0.00%'; + $return = ''; + + // 订阅信息 + $info_array = (count(Config::get('sub_message')) != 0 + ? (array) Config::get('sub_message') + : []); + + if ($traffic_class_expire !== 0) { + // 用户账户及流量信息 + if (strtotime($user->expire_in) > time()) { + if ($user->transfer_enable == 0) { + $info_array[] = '剩余流量:0.00%'; + } else { + $info_array[] = '剩余流量:' . number_format(($user->transfer_enable - $user->u - $user->d) / $user->transfer_enable * 100, 2) . '% ' . $user->unusedTraffic(); + } + $info_array[] = '过期时间:' . $user->class_expire; } else { - $userTraffic = '剩余流量:' . number_format(($user->transfer_enable - $user->u - $user->d) / $user->transfer_enable * 100, 2) . '% ' . $user->unusedTraffic(); + $info_array[] = '账户已过期,请续费后使用'; } - $userClassExpire = '过期时间:' . $user->class_expire; - } else { - $userTraffic = '账户已过期,请续费后使用'; - $userClassExpire = '账户已过期,请续费后使用'; - } - switch ($type) { - case 1: // SSR - $getUserTraffic = 'ssr://' . Tools::base64_url_encode('www.google.com:1:auth_chain_a:chacha20:tls1.2_ticket_auth:YnJlYWt3YWxs/?obfsparam=&protoparam=&remarks=' . Tools::base64_url_encode($userTraffic) . '&group=' . Tools::base64_url_encode($group_name)) . PHP_EOL; - $getUserClassExpiration = 'ssr://' . Tools::base64_url_encode('www.google.com:1:auth_chain_a:chacha20:tls1.2_ticket_auth:YnJlYWt3YWxs/?obfsparam=&protoparam=&remarks=' . Tools::base64_url_encode($userClassExpire) . '&group=' . Tools::base64_url_encode($group_name)) . PHP_EOL; - break; - case 2: // SS - $getUserTraffic = 'ss://' . Tools::base64_url_encode('chacha20:YnJlYWt3YWxs@www.google.com:2') . '#' . rawurlencode($userTraffic) . PHP_EOL; - $getUserClassExpiration = 'ss://' . Tools::base64_url_encode('chacha20:YnJlYWt3YWxs@www.google.com:2') . '#' . rawurlencode($userClassExpire) . PHP_EOL; - break; - case 3: // V2 - $userTrafficArray = ['v' => '2', 'ps' => $userTraffic, 'add' => 'www.google.com', 'port' => '3', 'id' => '2661b5f8-8062-34a5-9371-a44313a75b6b', 'aid' => '16', 'net' => 'tcp', 'type' => 'none', 'host' => '', 'tls' => '']; - $userClassExpirationArray = ['v' => '2', 'ps' => $userClassExpire, 'add' => 'www.google.com', 'port' => '3', 'id' => '2661b5f8-8062-34a5-9371-a44313a75b6b', 'aid' => '16', 'net' => 'tcp', 'type' => 'none', 'host' => '', 'tls' => '']; - $getUserTraffic = 'vmess://' . base64_encode(json_encode($userTrafficArray, JSON_UNESCAPED_UNICODE)) . PHP_EOL; - $getUserClassExpiration = 'vmess://' . base64_encode(json_encode($userClassExpirationArray, JSON_UNESCAPED_UNICODE)) . PHP_EOL; - break; - } - return $getUserTraffic . $getUserClassExpiration; + } + + $group_name = Config::get('appName'); + foreach ($info_array as $item) { + switch ($type) { + case 'ss': + $return .= 'ss://' . Tools::base64_url_encode('chacha20:YnJlYWt3YWxs@www.google.com:10086') . '#' . rawurlencode($item) . PHP_EOL; + break; + case 'ssr': + $return .= 'ssr://' . Tools::base64_url_encode('www.google.com:10086:auth_chain_a:chacha20:tls1.2_ticket_auth:YnJlYWt3YWxs/?obfsparam=&protoparam=&remarks=' . Tools::base64_url_encode($item) . '&group=' . Tools::base64_url_encode($group_name)) . PHP_EOL; + break; + case 'v2ray': + $v2ray = ['v' => '2', 'ps' => $item, 'add' => 'www.google.com', 'port' => '10086', 'id' => '2661b5f8-8062-34a5-9371-a44313a75b6b', 'aid' => '2', 'net' => 'tcp', 'type' => 'none', 'host' => '', 'tls' => '']; + $return .= 'vmess://' . base64_encode(json_encode($v2ray, JSON_UNESCAPED_UNICODE)) . PHP_EOL; + break; + case 'quantumult_v2': + $quantumult_v2 = base64_encode($item . ' = vmess, ' . 'www.google.com' . ', ' . '10086' . ', chacha20-ietf-poly1305, "2661b5f8-8062-34a5-9371-a44313a75b6b", group=' . $group_name . '_v2') . PHP_EOL; + $return .= 'vmess://' . base64_encode($quantumult_v2) . PHP_EOL; + break; + } + } + + return $return; } } diff --git a/config/.config.example.php b/config/.config.example.php index 9762e5a8..ff940910 100644 --- a/config/.config.example.php +++ b/config/.config.example.php @@ -27,9 +27,14 @@ $System_Config['db_database'] = 'sspanel'; //数据库名 $System_Config['db_username'] = 'root'; //数据库用户名 $System_Config['db_password'] = 'sspanel'; //用户名对应的密码 -//新旧首页设置-------------------------------------------------------------------------------------------- +// 新旧首页设置-------------------------------------------------------------------------------------------- $System_Config['newIndex'] = 'true'; //使用新的 Node.js 开发的首页请填写 true,其他值为使用先前的首页,如您使用其他主题请保持 true +// 订阅中的公告信息 +// 使用数组形式,将会添加在订阅列表的顶端 +// 可用于为用户推送最新地址等信息,尽可能简短且数量不宜太多 +$System_Config['sub_message'] = []; + //邮件设置-------------------------------------------------------------------------------------------- $System_Config['mailDriver'] = 'none'; //发送邮件方式:none / mailgun / smtp / sendgrid $System_Config['sendPageLimit']= 50; //发信分页 解决大站发公告超时问题