Просмотр исходного кода

1.更加规范的定时任务命名
2.引入助手函数,本次更新需要手动执行一下 php composer.phar dumpautoload 引入助手文件
3.修正使用https提示不安全问题
4.更新readme,推荐使用我基于SSRR改进的更适合ssrpanel使用的SSRR后端

Administrator 8 лет назад
Родитель
Сommit
a42d8f6c6c
38 измененных файлов с 234 добавлено и 211 удалено
  1. 1 1
      app/Console/Commands/AutoBanSubscribeJob.php
  2. 1 1
      app/Console/Commands/AutoBanUserJob.php
  3. 1 1
      app/Console/Commands/AutoCheckNodeStatusJob.php
  4. 1 1
      app/Console/Commands/AutoClearLogJob.php
  5. 1 1
      app/Console/Commands/AutoDecGoodsTrafficJob.php
  6. 1 1
      app/Console/Commands/AutoDisableExpireUserJob.php
  7. 2 2
      app/Console/Commands/AutoDisableUserJob.php
  8. 1 1
      app/Console/Commands/AutoExpireCouponJob.php
  9. 1 1
      app/Console/Commands/AutoExpireInviteJob.php
  10. 2 2
      app/Console/Commands/AutoReleasePortJob.php
  11. 1 1
      app/Console/Commands/AutoReopenUserJob.php
  12. 2 2
      app/Console/Commands/AutoResetUserTrafficJob.php
  13. 1 1
      app/Console/Commands/AutoStatisticsNodeDailyTrafficJob.php
  14. 1 1
      app/Console/Commands/AutoStatisticsNodeHourlyTrafficJob.php
  15. 1 1
      app/Console/Commands/AutoStatisticsUserDailyTrafficJob.php
  16. 1 1
      app/Console/Commands/AutoStatisticsUserHourlyTrafficJob.php
  17. 1 1
      app/Console/Commands/UserExpireWarningJob.php
  18. 1 1
      app/Console/Commands/UserTrafficWarningJob.php
  19. 18 18
      app/Console/Kernel.php
  20. 28 28
      app/Http/Controllers/AdminController.php
  21. 7 94
      app/Http/Controllers/Controller.php
  22. 22 7
      app/Http/Controllers/CouponController.php
  23. 1 1
      app/Http/Controllers/LoginController.php
  24. 2 2
      app/Http/Controllers/RegisterController.php
  25. 1 1
      app/Http/Controllers/ShopController.php
  26. 8 8
      app/Http/Controllers/SubscribeController.php
  27. 13 13
      app/Http/Controllers/UserController.php
  28. 98 0
      app/helpers.php
  29. 3 0
      composer.json
  30. 4 10
      readme.md
  31. 1 1
      resources/views/403.blade.php
  32. 1 1
      resources/views/404.blade.php
  33. 1 1
      resources/views/login.blade.php
  34. 1 1
      resources/views/register.blade.php
  35. 1 1
      resources/views/user/active.blade.php
  36. 1 1
      resources/views/user/activeUser.blade.php
  37. 1 1
      resources/views/user/reset.blade.php
  38. 1 1
      resources/views/user/resetPassword.blade.php

+ 1 - 1
app/Console/Commands/AutoBanSubscribeJob.php

@@ -10,7 +10,7 @@ use Log;
 
 
 class AutoBanSubscribeJob extends Command
 class AutoBanSubscribeJob extends Command
 {
 {
-    protected $signature = 'command:autoBanSubscribeJob';
+    protected $signature = 'autoBanSubscribeJob';
     protected $description = '自动封禁异常订阅链接';
     protected $description = '自动封禁异常订阅链接';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/AutoBanUserJob.php

@@ -11,7 +11,7 @@ use Log;
 
 
 class AutoBanUserJob extends Command
 class AutoBanUserJob extends Command
 {
 {
-    protected $signature = 'command:autoBanUserJob';
+    protected $signature = 'autoBanUserJob';
     protected $description = '自动封禁用户';
     protected $description = '自动封禁用户';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/AutoCheckNodeStatusJob.php

@@ -15,7 +15,7 @@ use Log;
 
 
 class AutoCheckNodeStatusJob extends Command
 class AutoCheckNodeStatusJob extends Command
 {
 {
-    protected $signature = 'command:autoCheckNodeStatusJob';
+    protected $signature = 'autoCheckNodeStatusJob';
     protected $description = '自动监测节点是否宕机';
     protected $description = '自动监测节点是否宕机';
     protected $cacheKey = 'node_shutdown_warning_';
     protected $cacheKey = 'node_shutdown_warning_';
 
 

+ 1 - 1
app/Console/Commands/AutoClearLogJob.php

@@ -13,7 +13,7 @@ use Log;
 
 
 class AutoClearLogJob extends Command
 class AutoClearLogJob extends Command
 {
 {
-    protected $signature = 'command:autoClearLogJob';
+    protected $signature = 'autoClearLogJob';
     protected $description = '自动清除日志';
     protected $description = '自动清除日志';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/AutoDecGoodsTrafficJob.php

@@ -9,7 +9,7 @@ use Log;
 
 
 class AutoDecGoodsTrafficJob extends Command
 class AutoDecGoodsTrafficJob extends Command
 {
 {
-    protected $signature = 'command:autoDecGoodsTrafficJob';
+    protected $signature = 'autoDecGoodsTrafficJob';
     protected $description = '自动扣除用户到期流量包的流量';
     protected $description = '自动扣除用户到期流量包的流量';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/AutoDisableExpireUserJob.php

@@ -8,7 +8,7 @@ use Log;
 
 
 class autoDisableExpireUserJob extends Command
 class autoDisableExpireUserJob extends Command
 {
 {
-    protected $signature = 'command:autoDisableExpireUserJob';
+    protected $signature = 'autoDisableExpireUserJob';
     protected $description = '自动禁用到期用户';
     protected $description = '自动禁用到期用户';
 
 
     public function __construct()
     public function __construct()

+ 2 - 2
app/Console/Commands/AutoDisableUserJob.php

@@ -2,14 +2,14 @@
 
 
 namespace App\Console\Commands;
 namespace App\Console\Commands;
 
 
-use App\Http\Models\UserBanLog;
 use Illuminate\Console\Command;
 use Illuminate\Console\Command;
+use App\Http\Models\UserBanLog;
 use App\Http\Models\User;
 use App\Http\Models\User;
 use Log;
 use Log;
 
 
 class autoDisableUserJob extends Command
 class autoDisableUserJob extends Command
 {
 {
-    protected $signature = 'command:autoDisableUserJob';
+    protected $signature = 'autoDisableUserJob';
     protected $description = '自动禁用流量超限的用户';
     protected $description = '自动禁用流量超限的用户';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/AutoExpireCouponJob.php

@@ -8,7 +8,7 @@ use Log;
 
 
 class AutoExpireCouponJob extends Command
 class AutoExpireCouponJob extends Command
 {
 {
-    protected $signature = 'command:autoExpireCouponJob';
+    protected $signature = 'autoExpireCouponJob';
     protected $description = '优惠券到期自动置无效';
     protected $description = '优惠券到期自动置无效';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/AutoExpireInviteJob.php

@@ -8,7 +8,7 @@ use Log;
 
 
 class AutoExpireInviteJob extends Command
 class AutoExpireInviteJob extends Command
 {
 {
-    protected $signature = 'command:autoExpireInviteJob';
+    protected $signature = 'autoExpireInviteJob';
     protected $description = '邀请码过期自动置无效';
     protected $description = '邀请码过期自动置无效';
 
 
     public function __construct()
     public function __construct()

+ 2 - 2
app/Console/Commands/AutoReleasePortJob.php

@@ -2,14 +2,14 @@
 
 
 namespace App\Console\Commands;
 namespace App\Console\Commands;
 
 
-use App\Http\Models\User;
 use Illuminate\Console\Command;
 use Illuminate\Console\Command;
+use App\Http\Models\User;
 use App\Http\Models\Config;
 use App\Http\Models\Config;
 use Log;
 use Log;
 
 
 class AutoReleasePortJob extends Command
 class AutoReleasePortJob extends Command
 {
 {
-    protected $signature = 'command:autoReleasePortJob';
+    protected $signature = 'autoReleasePortJob';
     protected $description = '自动释放端口';
     protected $description = '自动释放端口';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/AutoReopenUserJob.php

@@ -9,7 +9,7 @@ use Log;
 
 
 class AutoReopenUserJob extends Command
 class AutoReopenUserJob extends Command
 {
 {
-    protected $signature = 'command:autoReopenUserJob';
+    protected $signature = 'autoReopenUserJob';
     protected $description = '自动解封用户';
     protected $description = '自动解封用户';
 
 
     public function __construct()
     public function __construct()

+ 2 - 2
app/Console/Commands/AutoResetUserTrafficJob.php

@@ -2,15 +2,15 @@
 
 
 namespace App\Console\Commands;
 namespace App\Console\Commands;
 
 
-use App\Http\Models\Order;
 use Illuminate\Console\Command;
 use Illuminate\Console\Command;
+use App\Http\Models\Order;
 use App\Http\Models\Config;
 use App\Http\Models\Config;
 use App\Http\Models\User;
 use App\Http\Models\User;
 use Log;
 use Log;
 
 
 class AutoResetUserTrafficJob extends Command
 class AutoResetUserTrafficJob extends Command
 {
 {
-    protected $signature = 'command:autoResetUserTrafficJob';
+    protected $signature = 'autoResetUserTrafficJob';
     protected $description = '自动重置用户可用流量';
     protected $description = '自动重置用户可用流量';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/AutoStatisticsNodeDailyTrafficJob.php

@@ -10,7 +10,7 @@ use Log;
 
 
 class AutoStatisticsNodeDailyTrafficJob extends Command
 class AutoStatisticsNodeDailyTrafficJob extends Command
 {
 {
-    protected $signature = 'command:autoStatisticsNodeDailyTrafficJob';
+    protected $signature = 'autoStatisticsNodeDailyTrafficJob';
     protected $description = '自动统计节点每日流量';
     protected $description = '自动统计节点每日流量';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/AutoStatisticsNodeHourlyTrafficJob.php

@@ -10,7 +10,7 @@ use Log;
 
 
 class AutoStatisticsNodeHourlyTrafficJob extends Command
 class AutoStatisticsNodeHourlyTrafficJob extends Command
 {
 {
-    protected $signature = 'command:autoStatisticsNodeHourlyTrafficJob';
+    protected $signature = 'autoStatisticsNodeHourlyTrafficJob';
     protected $description = '自动统计节点每小时流量';
     protected $description = '自动统计节点每小时流量';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/AutoStatisticsUserDailyTrafficJob.php

@@ -11,7 +11,7 @@ use Log;
 
 
 class AutoStatisticsUserDailyTrafficJob extends Command
 class AutoStatisticsUserDailyTrafficJob extends Command
 {
 {
-    protected $signature = 'command:autoStatisticsUserDailyTrafficJob';
+    protected $signature = 'autoStatisticsUserDailyTrafficJob';
     protected $description = '自动统计用户每日流量';
     protected $description = '自动统计用户每日流量';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/AutoStatisticsUserHourlyTrafficJob.php

@@ -11,7 +11,7 @@ use Log;
 
 
 class AutoStatisticsUserHourlyTrafficJob extends Command
 class AutoStatisticsUserHourlyTrafficJob extends Command
 {
 {
-    protected $signature = 'command:autoStatisticsUserHourlyTrafficJob';
+    protected $signature = 'autoStatisticsUserHourlyTrafficJob';
     protected $description = '自动统计用户每小时流量';
     protected $description = '自动统计用户每小时流量';
 
 
     public function __construct()
     public function __construct()

+ 1 - 1
app/Console/Commands/UserExpireWarningJob.php

@@ -12,7 +12,7 @@ use Log;
 
 
 class UserExpireWarningJob extends Command
 class UserExpireWarningJob extends Command
 {
 {
-    protected $signature = 'command:userExpireWarningJob';
+    protected $signature = 'userExpireWarningJob';
     protected $description = '自动发邮件提醒用户临近到期';
     protected $description = '自动发邮件提醒用户临近到期';
 
 
     protected static $config;
     protected static $config;

+ 1 - 1
app/Console/Commands/UserTrafficWarningJob.php

@@ -12,7 +12,7 @@ use Log;
 
 
 class UserTrafficWarningJob extends Command
 class UserTrafficWarningJob extends Command
 {
 {
-    protected $signature = 'command:userTrafficWarningJob';
+    protected $signature = 'userTrafficWarningJob';
     protected $description = '自动发邮件提醒用户流量超过警告阈值';
     protected $description = '自动发邮件提醒用户流量超过警告阈值';
 
 
     protected static $config;
     protected static $config;

+ 18 - 18
app/Console/Kernel.php

@@ -41,24 +41,24 @@ class Kernel extends ConsoleKernel
      */
      */
     protected function schedule(Schedule $schedule)
     protected function schedule(Schedule $schedule)
     {
     {
-        $schedule->command('command:autoBanSubscribeJob')->everyThirtyMinutes();
-        $schedule->command('command:autoBanUserJob')->everyTenMinutes();
-        $schedule->command('command:autoCheckNodeStatusJob')->everyMinute();
-        $schedule->command('command:autoClearLogJob')->everyThirtyMinutes();
-        $schedule->command('command:autoDecGoodsTrafficJob')->everyTenMinutes();
-        $schedule->command('command:autoDisableExpireUserJob')->everyMinute();
-        $schedule->command('command:autoDisableUserJob')->everyMinute();
-        $schedule->command('command:autoExpireCouponJob')->everyThirtyMinutes();
-        $schedule->command('command:autoExpireInviteJob')->everyThirtyMinutes();
-        $schedule->command('command:autoReleasePortJob')->everyMinute();
-        $schedule->command('command:autoReopenUserJob')->everyMinute();
-        $schedule->command('command:autoResetUserTrafficJob')->everyFiveMinutes();
-        $schedule->command('command:autoStatisticsNodeDailyTrafficJob')->dailyAt('04:30');
-        $schedule->command('command:autoStatisticsNodeHourlyTrafficJob')->hourly();
-        $schedule->command('command:autoStatisticsUserDailyTrafficJob')->dailyAt('03:00');
-        $schedule->command('command:autoStatisticsUserHourlyTrafficJob')->hourly();
-        $schedule->command('command:userExpireWarningJob')->daily();
-        $schedule->command('command:userTrafficWarningJob')->daily();
+        $schedule->command('autoBanSubscribeJob')->everyThirtyMinutes();
+        $schedule->command('autoBanUserJob')->everyTenMinutes();
+        $schedule->command('autoCheckNodeStatusJob')->everyMinute();
+        $schedule->command('autoClearLogJob')->everyThirtyMinutes();
+        $schedule->command('autoDecGoodsTrafficJob')->everyTenMinutes();
+        $schedule->command('autoDisableExpireUserJob')->everyMinute();
+        $schedule->command('autoDisableUserJob')->everyMinute();
+        $schedule->command('autoExpireCouponJob')->everyThirtyMinutes();
+        $schedule->command('autoExpireInviteJob')->everyThirtyMinutes();
+        $schedule->command('autoReleasePortJob')->everyMinute();
+        $schedule->command('autoReopenUserJob')->everyMinute();
+        $schedule->command('autoResetUserTrafficJob')->everyFiveMinutes();
+        $schedule->command('autoStatisticsNodeDailyTrafficJob')->dailyAt('04:30');
+        $schedule->command('autoStatisticsNodeHourlyTrafficJob')->hourly();
+        $schedule->command('autoStatisticsUserDailyTrafficJob')->dailyAt('03:00');
+        $schedule->command('autoStatisticsUserHourlyTrafficJob')->hourly();
+        $schedule->command('userExpireWarningJob')->daily();
+        $schedule->command('userTrafficWarningJob')->daily();
     }
     }
 
 
     /**
     /**

+ 28 - 28
app/Http/Controllers/AdminController.php

@@ -56,7 +56,7 @@ class AdminController extends Controller
         $view['onlineUserCount'] = User::query()->where('t', '>=', $online)->count();
         $view['onlineUserCount'] = User::query()->where('t', '>=', $online)->count();
         $view['nodeCount'] = SsNode::query()->count();
         $view['nodeCount'] = SsNode::query()->count();
         $flowCount = SsNodeTrafficDaily::query()->where('created_at', '>=', date('Y-m-d 00:00:00', strtotime("-30 days")))->sum('total');
         $flowCount = SsNodeTrafficDaily::query()->where('created_at', '>=', date('Y-m-d 00:00:00', strtotime("-30 days")))->sum('total');
-        $flowCount = $this->flowAutoShow($flowCount);
+        $flowCount = flowAutoShow($flowCount);
         $view['flowCount'] = $flowCount;
         $view['flowCount'] = $flowCount;
         $view['totalBalance'] = User::query()->sum('balance') / 100;
         $view['totalBalance'] = User::query()->sum('balance') / 100;
         $view['totalWaitRefAmount'] = ReferralLog::query()->whereIn('status', [0, 1])->sum('ref_amount') / 100;
         $view['totalWaitRefAmount'] = ReferralLog::query()->whereIn('status', [0, 1])->sum('ref_amount') / 100;
@@ -114,8 +114,8 @@ class AdminController extends Controller
 
 
         $userList = $query->orderBy('enable', 'desc')->orderBy('status', 'desc')->orderBy('id', 'desc')->paginate(10)->appends($request->except('page'));
         $userList = $query->orderBy('enable', 'desc')->orderBy('status', 'desc')->orderBy('id', 'desc')->paginate(10)->appends($request->except('page'));
         foreach ($userList as &$user) {
         foreach ($userList as &$user) {
-            $user->transfer_enable = $this->flowAutoShow($user->transfer_enable);
-            $user->used_flow = $this->flowAutoShow($user->u + $user->d);
+            $user->transfer_enable = flowAutoShow($user->transfer_enable);
+            $user->used_flow = flowAutoShow($user->u + $user->d);
             $user->expireWarning = $user->expire_time <= date('Y-m-d', strtotime("+ 30 days")) ? 1 : 0; // 临近过期提醒
             $user->expireWarning = $user->expire_time <= date('Y-m-d', strtotime("+ 30 days")) ? 1 : 0; // 临近过期提醒
 
 
             // 流量异常警告
             // 流量异常警告
@@ -142,7 +142,7 @@ class AdminController extends Controller
             // 密码为空时则生成随机密码
             // 密码为空时则生成随机密码
             $password = $request->get('password');
             $password = $request->get('password');
             if (empty($password)) {
             if (empty($password)) {
-                $str = $this->makeRandStr();
+                $str = makeRandStr();
                 $password = md5($str);
                 $password = md5($str);
             } else {
             } else {
                 $password = md5($password);
                 $password = md5($password);
@@ -152,8 +152,8 @@ class AdminController extends Controller
             $user->username = $request->get('username');
             $user->username = $request->get('username');
             $user->password = $password;
             $user->password = $password;
             $user->port = $request->get('port');
             $user->port = $request->get('port');
-            $user->passwd = empty($request->get('passwd')) ? $this->makeRandStr() : $request->get('passwd'); // SS密码为空时生成默认密码
-            $user->transfer_enable = $this->toGB($request->get('transfer_enable', 0));
+            $user->passwd = empty($request->get('passwd')) ? makeRandStr() : $request->get('passwd'); // SS密码为空时生成默认密码
+            $user->transfer_enable = toGB($request->get('transfer_enable', 0));
             $user->enable = $request->get('enable', 0);
             $user->enable = $request->get('enable', 0);
             $user->method = $request->get('method');
             $user->method = $request->get('method');
             $user->protocol = $request->get('protocol', '');
             $user->protocol = $request->get('protocol', '');
@@ -217,12 +217,12 @@ class AdminController extends Controller
                 $port = self::$config['is_rand_port'] ? $this->getRandPort() : $last_user->port + 1;
                 $port = self::$config['is_rand_port'] ? $this->getRandPort() : $last_user->port + 1;
 
 
                 $user = new User();
                 $user = new User();
-                $user->username = '批量生成-' . $this->makeRandStr();
-                $user->password = md5($this->makeRandStr());
+                $user->username = '批量生成-' . makeRandStr();
+                $user->password = md5(makeRandStr());
                 $user->enable = 1;
                 $user->enable = 1;
                 $user->port = $port;
                 $user->port = $port;
-                $user->passwd = $this->makeRandStr();
-                $user->transfer_enable = $this->toGB(1000);
+                $user->passwd = makeRandStr();
+                $user->transfer_enable = toGB(1000);
                 $user->enable_time = date('Y-m-d');
                 $user->enable_time = date('Y-m-d');
                 $user->expire_time = date('Y-m-d', strtotime("+365 days"));
                 $user->expire_time = date('Y-m-d', strtotime("+365 days"));
                 $user->reg_ip = $request->getClientIp();
                 $user->reg_ip = $request->getClientIp();
@@ -278,7 +278,7 @@ class AdminController extends Controller
                     'username'             => $username,
                     'username'             => $username,
                     'port'                 => $port,
                     'port'                 => $port,
                     'passwd'               => $passwd,
                     'passwd'               => $passwd,
-                    'transfer_enable'      => $this->toGB($transfer_enable),
+                    'transfer_enable'      => toGB($transfer_enable),
                     'enable'               => $status < 0 ? 0 : $enable, // 如果禁止登陆则同时禁用SSR
                     'enable'               => $status < 0 ? 0 : $enable, // 如果禁止登陆则同时禁用SSR
                     'method'               => $method,
                     'method'               => $method,
                     'protocol'             => $protocol,
                     'protocol'             => $protocol,
@@ -331,7 +331,7 @@ class AdminController extends Controller
         } else {
         } else {
             $user = User::query()->with(['label'])->where('id', $id)->first();
             $user = User::query()->with(['label'])->where('id', $id)->first();
             if ($user) {
             if ($user) {
-                $user->transfer_enable = $this->flowToGB($user->transfer_enable);
+                $user->transfer_enable = flowToGB($user->transfer_enable);
                 $user->balance = $user->balance / 100;
                 $user->balance = $user->balance / 100;
 
 
                 $label = [];
                 $label = [];
@@ -381,7 +381,7 @@ class AdminController extends Controller
 
 
             // 已产生流量
             // 已产生流量
             $totalTraffic = SsNodeTrafficDaily::query()->where('node_id', $node->id)->sum('total');
             $totalTraffic = SsNodeTrafficDaily::query()->where('node_id', $node->id)->sum('total');
-            $node->transfer = $this->flowAutoShow($totalTraffic);
+            $node->transfer = flowAutoShow($totalTraffic);
 
 
             // 负载(10分钟以内)
             // 负载(10分钟以内)
             $node_info = SsNodeInfo::query()->where('node_id', $node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->first();
             $node_info = SsNodeInfo::query()->where('node_id', $node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->first();
@@ -823,12 +823,12 @@ class AdminController extends Controller
         }
         }
 
 
         // 已使用流量
         // 已使用流量
-        $view['totalTraffic'] = $this->flowAutoShow($query->sum('u') + $query->sum('d'));
+        $view['totalTraffic'] = flowAutoShow($query->sum('u') + $query->sum('d'));
 
 
         $trafficLogList = $query->orderBy('id', 'desc')->paginate(20)->appends($request->except('page'));
         $trafficLogList = $query->orderBy('id', 'desc')->paginate(20)->appends($request->except('page'));
         foreach ($trafficLogList as &$trafficLog) {
         foreach ($trafficLogList as &$trafficLog) {
-            $trafficLog->u = $this->flowAutoShow($trafficLog->u);
-            $trafficLog->d = $this->flowAutoShow($trafficLog->d);
+            $trafficLog->u = flowAutoShow($trafficLog->u);
+            $trafficLog->d = flowAutoShow($trafficLog->d);
             $trafficLog->log_time = date('Y-m-d H:i:s', $trafficLog->log_time);
             $trafficLog->log_time = date('Y-m-d H:i:s', $trafficLog->log_time);
         }
         }
 
 
@@ -948,7 +948,7 @@ class AdminController extends Controller
                     'port'            => $port,
                     'port'            => $port,
                     'protocol'        => $protocol,
                     'protocol'        => $protocol,
                     'protocol_param'  => empty($protocol_param) ? "" : $protocol_param,
                     'protocol_param'  => empty($protocol_param) ? "" : $protocol_param,
-                    'transfer_enable' => $this->toGB($transfer_enable),
+                    'transfer_enable' => toGB($transfer_enable),
                     'u'               => 0,
                     'u'               => 0,
                     'user'            => date('Ymd') . '_IMPORT_' . $port,
                     'user'            => date('Ymd') . '_IMPORT_' . $port,
                 ];
                 ];
@@ -1104,21 +1104,21 @@ class AdminController extends Controller
             $ssr_str = '';
             $ssr_str = '';
             $ssr_str .= $node->server . ':' . ($node->single ? $node->single_port : $user->port);
             $ssr_str .= $node->server . ':' . ($node->single ? $node->single_port : $user->port);
             $ssr_str .= ':' . ($node->single ? $node->single_protocol : $user->protocol) . ':' . ($node->single ? $node->single_method : $user->method);
             $ssr_str .= ':' . ($node->single ? $node->single_protocol : $user->protocol) . ':' . ($node->single ? $node->single_method : $user->method);
-            $ssr_str .= ':' . ($node->single ? $node->single_obfs : $user->obfs) . ':' . ($node->single ? $this->base64url_encode($node->single_passwd) : $this->base64url_encode($user->passwd));
-            $ssr_str .= '/?obfsparam=' . ($node->single ? '' : $this->base64url_encode($obfs_param));
-            $ssr_str .= '&protoparam=' . ($node->single ? $this->base64url_encode($user->port . ':' . $user->passwd) : $this->base64url_encode($protocol_param));
-            $ssr_str .= '&remarks=' . $this->base64url_encode($node->name);
-            $ssr_str .= '&group=' . $this->base64url_encode('VPN');
+            $ssr_str .= ':' . ($node->single ? $node->single_obfs : $user->obfs) . ':' . ($node->single ? base64url_encode($node->single_passwd) : base64url_encode($user->passwd));
+            $ssr_str .= '/?obfsparam=' . ($node->single ? '' : base64url_encode($obfs_param));
+            $ssr_str .= '&protoparam=' . ($node->single ? base64url_encode($user->port . ':' . $user->passwd) : base64url_encode($protocol_param));
+            $ssr_str .= '&remarks=' . base64url_encode($node->name);
+            $ssr_str .= '&group=' . base64url_encode('VPN');
             $ssr_str .= '&udpport=0';
             $ssr_str .= '&udpport=0';
             $ssr_str .= '&uot=0';
             $ssr_str .= '&uot=0';
-            $ssr_str = $this->base64url_encode($ssr_str);
+            $ssr_str = base64url_encode($ssr_str);
             $ssr_scheme = 'ssr://' . $ssr_str;
             $ssr_scheme = 'ssr://' . $ssr_str;
 
 
             // 生成ss scheme
             // 生成ss scheme
             $ss_str = '';
             $ss_str = '';
             $ss_str .= $user->method . ':' . $user->passwd . '@';
             $ss_str .= $user->method . ':' . $user->passwd . '@';
             $ss_str .= $node->server . ':' . $user->port;
             $ss_str .= $node->server . ':' . $user->port;
-            $ss_str = $this->base64url_encode($ss_str) . '#' . 'VPN';
+            $ss_str = base64url_encode($ss_str) . '#' . 'VPN';
             $ss_scheme = 'ss://' . $ss_str;
             $ss_scheme = 'ss://' . $ss_str;
 
 
             // 生成文本配置信息
             // 生成文本配置信息
@@ -1243,7 +1243,7 @@ class AdminController extends Controller
     // 生成SS密码
     // 生成SS密码
     public function makePasswd(Request $request)
     public function makePasswd(Request $request)
     {
     {
-        exit($this->makeRandStr());
+        exit(makeRandStr());
     }
     }
 
 
     // 加密方式、混淆、协议、等级、国家地区
     // 加密方式、混淆、协议、等级、国家地区
@@ -1677,7 +1677,7 @@ class AdminController extends Controller
             $obj = new Invite();
             $obj = new Invite();
             $obj->uid = $user['id'];
             $obj->uid = $user['id'];
             $obj->fuid = 0;
             $obj->fuid = 0;
-            $obj->code = strtoupper(substr(md5(microtime() . $this->makeRandStr()), 8, 12));
+            $obj->code = strtoupper(substr(md5(microtime() . makeRandStr()), 8, 12));
             $obj->status = 0;
             $obj->status = 0;
             $obj->dateline = date('Y-m-d H:i:s', strtotime("+ 7days"));
             $obj->dateline = date('Y-m-d H:i:s', strtotime("+ 7days"));
             $obj->save();
             $obj->save();
@@ -1943,8 +1943,8 @@ class AdminController extends Controller
     {
     {
         $labelList = Label::query()->paginate(10);
         $labelList = Label::query()->paginate(10);
         foreach ($labelList as $label) {
         foreach ($labelList as $label) {
-            $label->userCount = UserLabel::query()->where('label_id', $label->id)->groupBy('user_id')->count();
-            $label->nodeCount = SsNodeLabel::query()->where('label_id', $label->id)->groupBy('node_id')->count();
+            $label->userCount = UserLabel::query()->where('label_id', $label->id)->groupBy('label_id')->count();
+            $label->nodeCount = SsNodeLabel::query()->where('label_id', $label->id)->groupBy('label_id')->count();
         }
         }
 
 
         $view['labelList'] = $labelList;
         $view['labelList'] = $labelList;

+ 7 - 94
app/Http/Controllers/Controller.php

@@ -17,23 +17,10 @@ class Controller extends BaseController
 {
 {
     use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
     use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
 
 
-    // 生成SS密码
-    public function makeRandStr($length = 8)
-    {
-        // 密码字符集,可任意添加你需要的字符
-        $chars = 'abcdefghijkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789';
-        $char = '';
-        for ($i = 0; $i < $length; $i++) {
-            $char .= $chars[mt_rand(0, strlen($chars) - 1)];
-        }
-
-        return $char;
-    }
-
     // 生成订阅地址的唯一码
     // 生成订阅地址的唯一码
     public function makeSubscribeCode()
     public function makeSubscribeCode()
     {
     {
-        $code = $this->makeRandStr(5);
+        $code = makeRandStr(5);
         if (UserSubscribe::query()->where('code', $code)->exists()) {
         if (UserSubscribe::query()->where('code', $code)->exists()) {
             $code = $this->makeSubscribeCode();
             $code = $this->makeSubscribeCode();
         }
         }
@@ -41,62 +28,6 @@ class Controller extends BaseController
         return $code;
         return $code;
     }
     }
 
 
-    // base64加密(处理URL)
-    function base64url_encode($data)
-    {
-        return strtr(base64_encode($data), array('+' => '-', '/' => '_', '=' => ''));
-    }
-
-    // base64解密(处理URL)
-    function base64url_decode($data)
-    {
-        return base64_decode(strtr($data, '-_', '+/'));
-    }
-
-    // 根据流量值自动转换单位输出
-    public function flowAutoShow($value = 0)
-    {
-        $kb = 1024;
-        $mb = 1048576;
-        $gb = 1073741824;
-        $tb = $gb * 1024;
-        $pb = $tb * 1024;
-        if (abs($value) > $pb) {
-            return round($value / $pb, 2) . "PB";
-        } elseif (abs($value) > $tb) {
-            return round($value / $tb, 2) . "TB";
-        } elseif (abs($value) > $gb) {
-            return round($value / $gb, 2) . "GB";
-        } elseif (abs($value) > $mb) {
-            return round($value / $mb, 2) . "MB";
-        } elseif (abs($value) > $kb) {
-            return round($value / $kb, 2) . "KB";
-        } else {
-            return round($value, 2) . "B";
-        }
-    }
-
-    public function toMB($traffic)
-    {
-        $mb = 1048576;
-
-        return $traffic * $mb;
-    }
-
-    public function toGB($traffic)
-    {
-        $gb = 1048576 * 1024;
-
-        return $traffic * $gb;
-    }
-
-    public function flowToGB($traffic)
-    {
-        $gb = 1048576 * 1024;
-
-        return $traffic / $gb;
-    }
-
     // 加密方式
     // 加密方式
     public function methodList()
     public function methodList()
     {
     {
@@ -160,7 +91,7 @@ class Controller extends BaseController
         $fp = fopen($file, "r+");
         $fp = fopen($file, "r+");
         assert($n > 0);
         assert($n > 0);
         $pos = $n + 1;
         $pos = $n + 1;
-        $lines = array();
+        $lines = [];
         while (count($lines) <= $n) {
         while (count($lines) <= $n) {
             try {
             try {
                 fseek($fp, -$pos, SEEK_END);
                 fseek($fp, -$pos, SEEK_END);
@@ -199,32 +130,14 @@ class Controller extends BaseController
         return $i;
         return $i;
     }
     }
 
 
-    /**
-     * 文件大小转换
-     *
-     * @param int $bytes
-     * @param int $precision
-     *
-     * @return string
-     */
-    public function formatBytes($bytes, $precision = 2)
-    {
-        $units = array('B', 'KB', 'MB', 'GB', 'TB');
-        $bytes = max($bytes, 0);
-        $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
-        $pow = min($pow, count($units) - 1);
-        $bytes /= pow(1024, $pow);
-
-        return round($bytes, $precision) . ' ' . $units[$pow];
-    }
-
     /**
     /**
      * 写入邮件发送日志
      * 写入邮件发送日志
-     * @param int $user_id 用户ID
-     * @param string $title 标题
+     *
+     * @param int    $user_id 用户ID
+     * @param string $title   标题
      * @param string $content 内容
      * @param string $content 内容
-     * @param int $status 投递状态
-     * @param string $error 投递失败时记录的异常信息
+     * @param int    $status  投递状态
+     * @param string $error   投递失败时记录的异常信息
      */
      */
     public function sendEmailLog($user_id, $title, $content, $status = 1, $error = '')
     public function sendEmailLog($user_id, $title, $content, $status = 1, $error = '')
     {
     {

+ 22 - 7
app/Http/Controllers/CouponController.php

@@ -77,7 +77,7 @@ class CouponController extends Controller
                 for ($i = 0; $i < $num; $i++) {
                 for ($i = 0; $i < $num; $i++) {
                     $obj = new Coupon();
                     $obj = new Coupon();
                     $obj->name = $name;
                     $obj->name = $name;
-                    $obj->sn = strtoupper($this->makeRandStr(7));
+                    $obj->sn = strtoupper(makeRandStr(7));
                     $obj->logo = $logo;
                     $obj->logo = $logo;
                     $obj->type = $type;
                     $obj->type = $type;
                     $obj->usage = $usage;
                     $obj->usage = $usage;
@@ -121,18 +121,19 @@ class CouponController extends Controller
     {
     {
         $cashCouponList = Coupon::query()->where('is_del', 0)->where('status', 0)->where('type', 1)->get();
         $cashCouponList = Coupon::query()->where('is_del', 0)->where('status', 0)->where('type', 1)->get();
         $discountCouponList = Coupon::query()->where('is_del', 0)->where('status', 0)->where('type', 2)->get();
         $discountCouponList = Coupon::query()->where('is_del', 0)->where('status', 0)->where('type', 2)->get();
+        $chargeCouponList = Coupon::query()->where('is_del', 0)->where('status', 0)->where('type', 3)->get();
 
 
         $filename = '卡券' . date('Ymd');
         $filename = '卡券' . date('Ymd');
-        Excel::create($filename, function($excel) use($cashCouponList, $discountCouponList) {
-            $excel->sheet('现金券', function($sheet) use($cashCouponList) {
+        Excel::create($filename, function($excel) use($cashCouponList, $discountCouponList, $chargeCouponList) {
+            $excel->sheet('抵用券', function($sheet) use($cashCouponList) {
                 $sheet->row(1, array(
                 $sheet->row(1, array(
-                    '名称', '用途', '有效期', '券码'
+                    '名称', '类型', '有效期', '券码', '面额'
                 ));
                 ));
 
 
                 if (!$cashCouponList->isEmpty()) {
                 if (!$cashCouponList->isEmpty()) {
                     foreach ($cashCouponList as $k => $vo) {
                     foreach ($cashCouponList as $k => $vo) {
                         $sheet->row($k + 2, array(
                         $sheet->row($k + 2, array(
-                            $vo->name, $vo->type == 1 ? '一次性' : '可重复', date('Y-m-d', $vo->available_start) . ' ~ ' . date('Y-m-d', $vo->available_end), $vo->sn
+                            $vo->name, $vo->type == 1 ? '一次性' : '可重复', date('Y-m-d', $vo->available_start) . ' ~ ' . date('Y-m-d', $vo->available_end), $vo->sn, $vo->amount / 100
                         ));
                         ));
                     }
                     }
                 }
                 }
@@ -140,13 +141,27 @@ class CouponController extends Controller
 
 
             $excel->sheet('折扣券', function($sheet) use($discountCouponList) {
             $excel->sheet('折扣券', function($sheet) use($discountCouponList) {
                 $sheet->row(1, array(
                 $sheet->row(1, array(
-                    '名称', '用途', '有效期', '券码'
+                    '名称', '类型', '有效期', '券码', '折扣'
                 ));
                 ));
 
 
                 if (!$discountCouponList->isEmpty()) {
                 if (!$discountCouponList->isEmpty()) {
                     foreach ($discountCouponList as $k => $vo) {
                     foreach ($discountCouponList as $k => $vo) {
                         $sheet->row($k + 2, array(
                         $sheet->row($k + 2, array(
-                            $vo->name, $vo->type == 1 ? '一次性' : '可重复', date('Y-m-d', $vo->available_start) . ' ~ ' . date('Y-m-d', $vo->available_end), $vo->sn
+                            $vo->name, $vo->type == 1 ? '一次性' : '可重复', date('Y-m-d', $vo->available_start) . ' ~ ' . date('Y-m-d', $vo->available_end), $vo->sn, $vo->discount
+                        ));
+                    }
+                }
+            });
+
+            $excel->sheet('充值券', function($sheet) use($chargeCouponList) {
+                $sheet->row(1, array(
+                    '名称', '类型', '有效期', '券码', '面额'
+                ));
+
+                if (!$chargeCouponList->isEmpty()) {
+                    foreach ($chargeCouponList as $k => $vo) {
+                        $sheet->row($k + 2, array(
+                            $vo->name, '一次性', date('Y-m-d', $vo->available_start) . ' ~ ' . date('Y-m-d', $vo->available_end), $vo->sn, $vo->amount / 100
                         ));
                         ));
                     }
                     }
                 }
                 }

+ 1 - 1
app/Http/Controllers/LoginController.php

@@ -66,7 +66,7 @@ class LoginController extends Controller
             $remember_token = "";
             $remember_token = "";
             User::query()->where('id', $user->id)->update(['last_login' => time()]);
             User::query()->where('id', $user->id)->update(['last_login' => time()]);
             if ($request->get('remember')) {
             if ($request->get('remember')) {
-                $remember_token = $this->makeRandStr(20);
+                $remember_token = makeRandStr(20);
 
 
                 User::query()->where('id', $user->id)->update(['last_login' => time(), "remember_token" => $remember_token]);
                 User::query()->where('id', $user->id)->update(['last_login' => time(), "remember_token" => $remember_token]);
             } else {
             } else {

+ 2 - 2
app/Http/Controllers/RegisterController.php

@@ -135,7 +135,7 @@ class RegisterController extends Controller
             $user->username = $username;
             $user->username = $username;
             $user->password = md5($password);
             $user->password = md5($password);
             $user->port = $port;
             $user->port = $port;
-            $user->passwd = $this->makeRandStr();
+            $user->passwd = makeRandStr();
             $user->transfer_enable = $transfer_enable;
             $user->transfer_enable = $transfer_enable;
             $user->method = $method ? $method->name : 'aes-192-ctr';
             $user->method = $method ? $method->name : 'aes-192-ctr';
             $user->protocol = $protocol ? $protocol->name : 'auth_chain_a';
             $user->protocol = $protocol ? $protocol->name : 'auth_chain_a';
@@ -180,7 +180,7 @@ class RegisterController extends Controller
 
 
             return Redirect::to('login');
             return Redirect::to('login');
         } else {
         } else {
-            $request->session()->put('register_token', $this->makeRandStr(16));
+            $request->session()->put('register_token', makeRandStr(16));
 
 
             $view['is_captcha'] = self::$config['is_captcha'];
             $view['is_captcha'] = self::$config['is_captcha'];
             $view['is_register'] = self::$config['is_register'];
             $view['is_register'] = self::$config['is_register'];

+ 1 - 1
app/Http/Controllers/ShopController.php

@@ -27,7 +27,7 @@ class ShopController extends Controller
         $goodsList = Goods::query()->where('is_del', 0)->orderBy('id', 'desc')->paginate(10);
         $goodsList = Goods::query()->where('is_del', 0)->orderBy('id', 'desc')->paginate(10);
         foreach ($goodsList as $goods) {
         foreach ($goodsList as $goods) {
             $goods->price = $goods->price / 100;
             $goods->price = $goods->price / 100;
-            $goods->traffic = $this->flowAutoShow($goods->traffic * 1048576);
+            $goods->traffic = flowAutoShow($goods->traffic * 1048576);
         }
         }
 
 
         $view['goodsList'] = $goodsList;
         $view['goodsList'] = $goodsList;

+ 8 - 8
app/Http/Controllers/SubscribeController.php

@@ -84,23 +84,23 @@ class SubscribeController extends Controller
             $ssr_str = '';
             $ssr_str = '';
             $ssr_str .= $node->server . ':' . ($node->single ? $node->single_port : $user->port);
             $ssr_str .= $node->server . ':' . ($node->single ? $node->single_port : $user->port);
             $ssr_str .= ':' . ($node->single ? $node->single_protocol : $user->protocol) . ':' . ($node->single ? $node->single_method : $user->method);
             $ssr_str .= ':' . ($node->single ? $node->single_protocol : $user->protocol) . ':' . ($node->single ? $node->single_method : $user->method);
-            $ssr_str .= ':' . ($node->single ? $node->single_obfs : $user->obfs) . ':' . ($node->single ? $this->base64url_encode($node->single_passwd) : $this->base64url_encode($user->passwd));
-            $ssr_str .= '/?obfsparam=' . ($node->single ? '' : $this->base64url_encode($obfs_param));
-            $ssr_str .= '&protoparam=' . ($node->single ? $this->base64url_encode($user->port . ':' . $user->passwd) : $this->base64url_encode($protocol_param));
-            $ssr_str .= '&remarks=' . $this->base64url_encode($node->name);
-            $ssr_str .= '&group=' . $this->base64url_encode('VPN');
+            $ssr_str .= ':' . ($node->single ? $node->single_obfs : $user->obfs) . ':' . ($node->single ? base64url_encode($node->single_passwd) : base64url_encode($user->passwd));
+            $ssr_str .= '/?obfsparam=' . ($node->single ? '' : base64url_encode($obfs_param));
+            $ssr_str .= '&protoparam=' . ($node->single ? base64url_encode($user->port . ':' . $user->passwd) : base64url_encode($protocol_param));
+            $ssr_str .= '&remarks=' . base64url_encode($node->name);
+            $ssr_str .= '&group=' . base64url_encode('VPN');
             $ssr_str .= '&udpport=0';
             $ssr_str .= '&udpport=0';
             $ssr_str .= '&uot=0';
             $ssr_str .= '&uot=0';
-            $ssr_str = $this->base64url_encode($ssr_str);
+            $ssr_str = base64url_encode($ssr_str);
             $scheme .= 'ssr://' . $ssr_str . "\n";
             $scheme .= 'ssr://' . $ssr_str . "\n";
         }
         }
 
 
-        exit($this->base64url_encode($scheme));
+        exit(base64url_encode($scheme));
     }
     }
 
 
     // 抛出无可用的节点信息,用于兼容防止客户端订阅失败
     // 抛出无可用的节点信息,用于兼容防止客户端订阅失败
     private function noneNode()
     private function noneNode()
     {
     {
-        return $this->base64url_encode('ssr://' . $this->base64url_encode('8.8.8.8:8888:origin:none:plain:' . $this->base64url_encode('0000') . '/?obfsparam=&protoparam=&remarks=' . $this->base64url_encode('无可用节点或账号被封禁') . '&group=' . $this->base64url_encode('VPN') . '&udpport=0&uot=0') . "\n");
+        return base64url_encode('ssr://' . base64url_encode('8.8.8.8:8888:origin:none:plain:' . base64url_encode('0000') . '/?obfsparam=&protoparam=&remarks=' . base64url_encode('无可用节点或账号被封禁') . '&group=' . base64url_encode('VPN') . '&udpport=0&uot=0') . "\n");
     }
     }
 }
 }

+ 13 - 13
app/Http/Controllers/UserController.php

@@ -47,8 +47,8 @@ class UserController extends Controller
         $user = $request->session()->get('user');
         $user = $request->session()->get('user');
 
 
         $user = User::query()->where('id', $user['id'])->first();
         $user = User::query()->where('id', $user['id'])->first();
-        $user->totalTransfer = $this->flowAutoShow($user->transfer_enable);
-        $user->usedTransfer = $this->flowAutoShow($user->u + $user->d);
+        $user->totalTransfer = flowAutoShow($user->transfer_enable);
+        $user->usedTransfer = flowAutoShow($user->u + $user->d);
         $user->usedPercent = $user->transfer_enable > 0 ? round(($user->u + $user->d) / $user->transfer_enable, 2) : 1;
         $user->usedPercent = $user->transfer_enable > 0 ? round(($user->u + $user->d) / $user->transfer_enable, 2) : 1;
         $user->levelName = Level::query()->where('level', $user['level'])->first()['level_name'];
         $user->levelName = Level::query()->where('level', $user['level'])->first()['level_name'];
         $user->balance = $user->balance / 100;
         $user->balance = $user->balance / 100;
@@ -86,21 +86,21 @@ class UserController extends Controller
             $ssr_str = '';
             $ssr_str = '';
             $ssr_str .= $node->server . ':' . ($node->single ? $node->single_port : $user->port);
             $ssr_str .= $node->server . ':' . ($node->single ? $node->single_port : $user->port);
             $ssr_str .= ':' . ($node->single ? $node->single_protocol : $user->protocol) . ':' . ($node->single ? $node->single_method : $user->method);
             $ssr_str .= ':' . ($node->single ? $node->single_protocol : $user->protocol) . ':' . ($node->single ? $node->single_method : $user->method);
-            $ssr_str .= ':' . ($node->single ? $node->single_obfs : $user->obfs) . ':' . ($node->single ? $this->base64url_encode($node->single_passwd) : $this->base64url_encode($user->passwd));
-            $ssr_str .= '/?obfsparam=' . ($node->single ? '' : $this->base64url_encode($obfs_param));
-            $ssr_str .= '&protoparam=' . ($node->single ? $this->base64url_encode($user->port . ':' . $user->passwd) : $this->base64url_encode($protocol_param));
-            $ssr_str .= '&remarks=' . $this->base64url_encode($node->name);
-            $ssr_str .= '&group=' . $this->base64url_encode('VPN');
+            $ssr_str .= ':' . ($node->single ? $node->single_obfs : $user->obfs) . ':' . ($node->single ? base64url_encode($node->single_passwd) : base64url_encode($user->passwd));
+            $ssr_str .= '/?obfsparam=' . ($node->single ? '' : base64url_encode($obfs_param));
+            $ssr_str .= '&protoparam=' . ($node->single ? base64url_encode($user->port . ':' . $user->passwd) : base64url_encode($protocol_param));
+            $ssr_str .= '&remarks=' . base64url_encode($node->name);
+            $ssr_str .= '&group=' . base64url_encode('VPN');
             $ssr_str .= '&udpport=0';
             $ssr_str .= '&udpport=0';
             $ssr_str .= '&uot=0';
             $ssr_str .= '&uot=0';
-            $ssr_str = $this->base64url_encode($ssr_str);
+            $ssr_str = base64url_encode($ssr_str);
             $ssr_scheme = 'ssr://' . $ssr_str;
             $ssr_scheme = 'ssr://' . $ssr_str;
 
 
             // 生成ss scheme
             // 生成ss scheme
             $ss_str = '';
             $ss_str = '';
             $ss_str .= $user->method . ':' . $user->passwd . '@';
             $ss_str .= $user->method . ':' . $user->passwd . '@';
             $ss_str .= $node->server . ':' . $user->port;
             $ss_str .= $node->server . ':' . $user->port;
-            $ss_str = $this->base64url_encode($ss_str) . '#' . 'VPN';
+            $ss_str = base64url_encode($ss_str) . '#' . 'VPN';
             $ss_scheme = 'ss://' . $ss_str;
             $ss_scheme = 'ss://' . $ss_str;
 
 
             // 生成文本配置信息
             // 生成文本配置信息
@@ -265,7 +265,7 @@ class UserController extends Controller
         $goodsList = Goods::query()->where('status', 1)->where('is_del', 0)->paginate(10)->appends($request->except('page'));
         $goodsList = Goods::query()->where('status', 1)->where('is_del', 0)->paginate(10)->appends($request->except('page'));
         foreach ($goodsList as $goods) {
         foreach ($goodsList as $goods) {
             $goods->price = $goods->price / 100;
             $goods->price = $goods->price / 100;
-            $goods->traffic = $this->flowAutoShow($goods->traffic * 1048576);
+            $goods->traffic = flowAutoShow($goods->traffic * 1048576);
         }
         }
 
 
         $view['goodsList'] = $goodsList;
         $view['goodsList'] = $goodsList;
@@ -412,7 +412,7 @@ class UserController extends Controller
         $obj = new Invite();
         $obj = new Invite();
         $obj->uid = $user['id'];
         $obj->uid = $user['id'];
         $obj->fuid = 0;
         $obj->fuid = 0;
-        $obj->code = strtoupper(mb_substr(md5(microtime() . $this->makeRandStr()), 8, 12));
+        $obj->code = strtoupper(mb_substr(md5(microtime() . makeRandStr()), 8, 12));
         $obj->status = 0;
         $obj->status = 0;
         $obj->dateline = date('Y-m-d H:i:s', strtotime("+7 days"));
         $obj->dateline = date('Y-m-d H:i:s', strtotime("+7 days"));
         $obj->save();
         $obj->save();
@@ -848,7 +848,7 @@ class UserController extends Controller
             }
             }
 
 
             $goods->price = $goods->price / 100;
             $goods->price = $goods->price / 100;
-            $goods->traffic = $this->flowAutoShow($goods->traffic * 1048576);
+            $goods->traffic = flowAutoShow($goods->traffic * 1048576);
             $view['goods'] = $goods;
             $view['goods'] = $goods;
             $view['paypal_status'] = self::$config['paypal_status'];
             $view['paypal_status'] = self::$config['paypal_status'];
 
 
@@ -905,7 +905,7 @@ class UserController extends Controller
         // 生成个人推广链接
         // 生成个人推广链接
         $user = $request->session()->get('user');
         $user = $request->session()->get('user');
 
 
-        $view['referral_traffic'] = $this->flowAutoShow(self::$config['referral_traffic'] * 1048576);
+        $view['referral_traffic'] = flowAutoShow(self::$config['referral_traffic'] * 1048576);
         $view['referral_percent'] = self::$config['referral_percent'];
         $view['referral_percent'] = self::$config['referral_percent'];
         $view['referral_money'] = self::$config['referral_money'];
         $view['referral_money'] = self::$config['referral_money'];
         $view['totalAmount'] = ReferralLog::query()->where('ref_user_id', $user['id'])->sum('ref_amount') / 100;
         $view['totalAmount'] = ReferralLog::query()->where('ref_user_id', $user['id'])->sum('ref_amount') / 100;

+ 98 - 0
app/helpers.php

@@ -0,0 +1,98 @@
+<?php
+
+// 生成SS密码
+if (!function_exists('makeRandStr')) {
+    function makeRandStr($length = 8)
+    {
+        // 密码字符集,可任意添加你需要的字符
+        $chars = 'abcdefghijkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789';
+        $char = '';
+        for ($i = 0; $i < $length; $i++) {
+            $char .= $chars[mt_rand(0, strlen($chars) - 1)];
+        }
+
+        return $char;
+    }
+}
+
+// base64加密(处理URL)
+if (!function_exists('base64url_encode')) {
+    function base64url_encode($data)
+    {
+        return strtr(base64_encode($data), ['+' => '-', '/' => '_', '=' => '']);
+    }
+}
+
+// base64解密(处理URL)
+if (!function_exists('base64url_decode')) {
+    function base64url_decode($data)
+    {
+        return base64_decode(strtr($data, '-_', '+/'));
+    }
+}
+
+// 根据流量值自动转换单位输出
+if (!function_exists('flowAutoShow')) {
+    function flowAutoShow($value = 0)
+    {
+        $kb = 1024;
+        $mb = 1048576;
+        $gb = 1073741824;
+        $tb = $gb * 1024;
+        $pb = $tb * 1024;
+        if (abs($value) > $pb) {
+            return round($value / $pb, 2) . "PB";
+        } elseif (abs($value) > $tb) {
+            return round($value / $tb, 2) . "TB";
+        } elseif (abs($value) > $gb) {
+            return round($value / $gb, 2) . "GB";
+        } elseif (abs($value) > $mb) {
+            return round($value / $mb, 2) . "MB";
+        } elseif (abs($value) > $kb) {
+            return round($value / $kb, 2) . "KB";
+        } else {
+            return round($value, 2) . "B";
+        }
+    }
+}
+
+if (!function_exists('toMB')) {
+    function toMB($traffic)
+    {
+        $mb = 1048576;
+
+        return $traffic * $mb;
+    }
+}
+
+if (!function_exists('toGB')) {
+    function toGB($traffic)
+    {
+        $gb = 1048576 * 1024;
+
+        return $traffic * $gb;
+    }
+}
+
+if (!function_exists('flowToGB')) {
+    function flowToGB($traffic)
+    {
+        $gb = 1048576 * 1024;
+
+        return $traffic / $gb;
+    }
+}
+
+// 文件大小转换
+if (!function_exists('formatBytes')) {
+    function formatBytes($bytes, $precision = 2)
+    {
+        $units = ['B', 'KB', 'MB', 'GB', 'TB'];
+        $bytes = max($bytes, 0);
+        $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
+        $pow = min($pow, count($units) - 1);
+        $bytes /= pow(1024, $pow);
+
+        return round($bytes, $precision) . ' ' . $units[$pow];
+    }
+}

+ 3 - 0
composer.json

@@ -23,6 +23,9 @@
         "phpunit/phpunit": "~5.7"
         "phpunit/phpunit": "~5.7"
     },
     },
     "autoload": {
     "autoload": {
+        "files": [
+            "app/helpers.php"
+        ],
         "classmap": [
         "classmap": [
             "database"
             "database"
         ],
         ],

+ 4 - 10
readme.md

@@ -48,7 +48,7 @@ PHP 7.1 (必须)
 MYSQL 5.5 (推荐5.6+)
 MYSQL 5.5 (推荐5.6+)
 内存 1G+ 
 内存 1G+ 
 磁盘空间 10G+
 磁盘空间 10G+
-PHP必须开启curl、gd、fileinfo、openssl组件
+PHP必须开启curl、gd、fileinfo、openssl、mbstring组件
 安装完成后记得编辑config/app.php中 'debug' => true, 改为 false
 安装完成后记得编辑config/app.php中 'debug' => true, 改为 false
 ````
 ````
 
 
@@ -193,21 +193,15 @@ chown www:www ssserver.log
 ````
 ````
 
 
 ## SSR(R)部署
 ## SSR(R)部署
-###### 手动部署
+###### 手动部署(基于SSRR)
 ````
 ````
-cp server/ssr-3.4.0.zip /root/
-cd /root
-unzip ssr-3.4.0.zip
+git clone https://github.com/ssrpanel/shadowsocksr.git
 cd shadowsocksr
 cd shadowsocksr
 sh initcfg.sh
 sh initcfg.sh
-把 userapiconfig.py 里的 API_INTERFACE 设置为 glzjinmod
-把 user-config.json 里的 connect_verbose_info 设置为 1
 配置 usermysql.json 里的数据库链接,NODE_ID就是节点ID,对应面板后台里添加的节点的自增ID,所以请先把面板搭好,搭好后进后台添加节点
 配置 usermysql.json 里的数据库链接,NODE_ID就是节点ID,对应面板后台里添加的节点的自增ID,所以请先把面板搭好,搭好后进后台添加节点
-
-同理部署SSRR,SSRR位于此处,自行下载:https://github.com/shadowsocksrr/shadowsocksr/tree/akkariiin/dev
 ````
 ````
 
 
-###### 一键自动部署
+###### 一键自动部署(基于SSR3.4)
 ````
 ````
 wget -N --no-check-certificate https://raw.githubusercontent.com/ssrpanel/ssrpanel/master/server/deploy_ssr.sh;chmod +x deploy_ssr.sh;./deploy_ssr.sh
 wget -N --no-check-certificate https://raw.githubusercontent.com/ssrpanel/ssrpanel/master/server/deploy_ssr.sh;chmod +x deploy_ssr.sh;./deploy_ssr.sh
 
 

+ 1 - 1
resources/views/403.blade.php

@@ -28,7 +28,7 @@
     <!-- END PAGE LEVEL STYLES -->
     <!-- END PAGE LEVEL STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
-    <link rel="shortcut icon" href="favicon.ico" /> </head>
+    <link rel="shortcut icon" href="{{asset('favicon.ico')}}" /> </head>
 <!-- END HEAD -->
 <!-- END HEAD -->
 
 
 <body class="page-404-3">
 <body class="page-404-3">

+ 1 - 1
resources/views/404.blade.php

@@ -28,7 +28,7 @@
     <!-- END PAGE LEVEL STYLES -->
     <!-- END PAGE LEVEL STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
-    <link rel="shortcut icon" href="favicon.ico" /> </head>
+    <link rel="shortcut icon" href="{{asset('favicon.ico')}}" /> </head>
 <!-- END HEAD -->
 <!-- END HEAD -->
 
 
 <body class="page-500-full-page">
 <body class="page-500-full-page">

+ 1 - 1
resources/views/login.blade.php

@@ -26,7 +26,7 @@
     <!-- END PAGE LEVEL STYLES -->
     <!-- END PAGE LEVEL STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
-    <link rel="shortcut icon" href="favicon.ico" />
+    <link rel="shortcut icon" href="{{asset('favicon.ico')}}" />
 </head>
 </head>
 
 
 <body class=" login">
 <body class=" login">

+ 1 - 1
resources/views/register.blade.php

@@ -26,7 +26,7 @@
     <!-- END PAGE LEVEL STYLES -->
     <!-- END PAGE LEVEL STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
-    <link rel="shortcut icon" href="favicon.ico" />
+    <link rel="shortcut icon" href="{{asset('favicon.ico')}}" />
 </head>
 </head>
 
 
 <body class=" login">
 <body class=" login">

+ 1 - 1
resources/views/user/active.blade.php

@@ -26,7 +26,7 @@
     <!-- END PAGE LEVEL STYLES -->
     <!-- END PAGE LEVEL STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
-    <link rel="shortcut icon" href="favicon.ico" />
+    <link rel="shortcut icon" href="{{asset('favicon.ico')}}" />
 </head>
 </head>
 
 
 <body class="login">
 <body class="login">

+ 1 - 1
resources/views/user/activeUser.blade.php

@@ -26,7 +26,7 @@
     <!-- END PAGE LEVEL STYLES -->
     <!-- END PAGE LEVEL STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
-    <link rel="shortcut icon" href="favicon.ico" />
+    <link rel="shortcut icon" href="{{asset('favicon.ico')}}" />
 </head>
 </head>
 
 
 <body class=" login">
 <body class=" login">

+ 1 - 1
resources/views/user/reset.blade.php

@@ -26,7 +26,7 @@
     <!-- END PAGE LEVEL STYLES -->
     <!-- END PAGE LEVEL STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
-    <link rel="shortcut icon" href="favicon.ico" />
+    <link rel="shortcut icon" href="{{asset('favicon.ico')}}" />
 </head>
 </head>
 
 
 <body class=" login">
 <body class=" login">

+ 1 - 1
resources/views/user/resetPassword.blade.php

@@ -26,7 +26,7 @@
     <!-- END PAGE LEVEL STYLES -->
     <!-- END PAGE LEVEL STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- BEGIN THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
     <!-- END THEME LAYOUT STYLES -->
-    <link rel="shortcut icon" href="favicon.ico" />
+    <link rel="shortcut icon" href="{{asset('favicon.ico')}}" />
 </head>
 </head>
 
 
 <body class=" login">
 <body class=" login">