Browse Source

remove(trafficlog)

兩足大貓貓 4 years ago
parent
commit
5f9e33ea2c

+ 0 - 2
resources/views/material/admin/main.tpl

@@ -89,12 +89,10 @@
                         <li><a href="/admin"><i class="icon icon-lg">business_center</i>&nbsp;系统概览</a></li>
                         <li><a href="/admin/announcement"><i class="icon icon-lg">announcement</i>&nbsp;公告管理</a></li>
                         <li><a href="/admin/ticket"><i class="icon icon-lg">question_answer</i>&nbsp;工单管理</a></li>
-                        <li><a href="/admin/auto"><i class="icon icon-lg">flash_auto</i>&nbsp;下发命令</a></li>
                     </ul>
                     <a class="waves-attach" data-toggle="collapse" href="#ui_menu_node">节点</a>
                     <ul class="menu-collapse collapse in" id="ui_menu_node">
                         <li><a href="/admin/node"><i class="icon icon-lg">router</i>&nbsp;节点列表</a></li>
-                        <li><a href="/admin/trafficlog"><i class="icon icon-lg">traffic</i>&nbsp;流量记录</a></li>
                         <li><a href="/admin/block"><i class="icon icon-lg">dialer_sip</i>&nbsp;已封禁IP</a></li>
                         <li><a href="/admin/unblock"><i class="icon icon-lg">dialer_sip</i>&nbsp;已解封IP</a></li>
                     </ul>

+ 0 - 38
resources/views/material/admin/trafficlog.tpl

@@ -1,38 +0,0 @@
-{include file='admin/main.tpl'}
-
-<main class="content">
-    <div class="content-header ui-content-header">
-        <div class="container">
-            <h1 class="content-heading">流量使用记录</h1>
-        </div>
-    </div>
-    <div class="container">
-        <div class="col-lg-12 col-sm-12">
-            <section class="content-inner margin-top-no">
-                <div class="card">
-                    <div class="card-main">
-                        <div class="card-inner">
-                            <p>部分节点不支持流量记录.</p>
-                            <p>显示表项:
-                                {include file='table/checkbox.tpl'}
-                            </p>
-                        </div>
-                    </div>
-                </div>
-                <div class="table-responsive">
-                    {include file='table/table.tpl'}
-                </div>
-            </section>
-        </div>
-    </div>
-</main>
-
-
-{include file='admin/footer.tpl'}
-
-<script>
-    {include file='table/js_1.tpl'}
-    window.addEventListener('load', () => {
-        {include file='table/js_2.tpl'}
-    });
-</script>

+ 1 - 16
sql/glzjin_all.sql

@@ -177,17 +177,6 @@ CREATE TABLE IF NOT EXISTS `user_token` (
   `expire_time` int(11)      NOT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
-CREATE TABLE IF NOT EXISTS `user_traffic_log` (
-  `id`       int(11)     NOT NULL,
-  `user_id`  int(11)     NOT NULL,
-  `u`        int(11)     NOT NULL,
-  `d`        int(11)     NOT NULL,
-  `node_id`  int(11)     NOT NULL,
-  `rate`     float       NOT NULL,
-  `traffic`  varchar(32) NOT NULL,
-  `log_time` int(11)     NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
 ALTER TABLE `alive_ip`
   ADD PRIMARY KEY (`id`);
 ALTER TABLE `announcement`
@@ -222,8 +211,6 @@ ALTER TABLE `user`
   ADD KEY `email` (`email`);
 ALTER TABLE `user_token`
   ADD PRIMARY KEY (`id`);
-ALTER TABLE `user_traffic_log`
-  ADD PRIMARY KEY (`id`);
 ALTER TABLE `alive_ip`
   MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
 ALTER TABLE `announcement`
@@ -254,8 +241,6 @@ ALTER TABLE `user`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 ALTER TABLE `user_token`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
-ALTER TABLE `user_traffic_log`
-  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
 
 CREATE TABLE IF NOT EXISTS `ss_node` (
   `id`                      int(11)      NOT NULL,
@@ -431,7 +416,7 @@ CREATE TABLE IF NOT EXISTS `paylist` (
 ALTER TABLE `paylist`
   ADD PRIMARY KEY (`id`);
 ALTER TABLE `paylist`
-  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;ALTER TABLE `user_traffic_log` CHANGE `u` `u` BIGINT(20) NOT NULL, CHANGE `d` `d` BIGINT(20) NOT NULL;
+  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
 
 --
 -- 用户订阅日志

+ 1 - 1
src/Command/Backup.php

@@ -47,7 +47,7 @@ class Backup extends Command
                 $ret
             );
             system(
-                'mysqldump --opt --user=' . $_ENV['db_username'] . ' --password=' . $_ENV['db_password'] . ' --host=' . $db_address_array[0] . ' ' . (isset($db_address_array[1]) ? '-P ' . $db_address_array[1] : '') . ' -d ' . $_ENV['db_database'] . ' alive_ip ss_node_info ss_node_online_log user_traffic_log detect_log telegram_session >> /tmp/ssmodbackup/mod.sql',
+                'mysqldump --opt --user=' . $_ENV['db_username'] . ' --password=' . $_ENV['db_password'] . ' --host=' . $db_address_array[0] . ' ' . (isset($db_address_array[1]) ? '-P ' . $db_address_array[1] : '') . ' -d ' . $_ENV['db_database'] . ' alive_ip ss_node_info ss_node_online_log detect_log telegram_session >> /tmp/ssmodbackup/mod.sql',
                 $ret
             );
         }

+ 0 - 2
src/Command/Job.php

@@ -13,7 +13,6 @@ use App\Models\LoginIp;
 use App\Models\DetectLog;
 use App\Models\UnblockIp;
 use App\Models\Speedtest;
-use App\Models\TrafficLog;
 use App\Models\EmailVerify;
 use App\Models\DetectBanLog;
 use App\Models\EmailQueue;
@@ -110,7 +109,6 @@ class Job extends Command
         Token::where('expire_time', '<', time())->delete();
         NodeInfoLog::where('log_time', '<', time() - 86400 * 3)->delete();
         NodeOnlineLog::where('log_time', '<', time() - 86400 * 3)->delete();
-        TrafficLog::where('log_time', '<', time() - 86400 * 3)->delete();
         DetectLog::where('datetime', '<', time() - 86400 * 3)->delete();
         Speedtest::where('datetime', '<', time() - 86400 * 3)->delete();
         EmailVerify::where('expire_in', '<', time() - 86400 * 3)->delete();

+ 0 - 87
src/Controllers/Admin/UserLog/TrafficLogController.php

@@ -1,87 +0,0 @@
-<?php
-
-namespace App\Controllers\Admin\UserLog;
-
-use App\Controllers\AdminController;
-use App\Models\{
-    User,
-    Node,
-    TrafficLog
-};
-use App\Utils\Tools;
-use Slim\Http\{
-    Request,
-    Response
-};
-use Psr\Http\Message\ResponseInterface;
-
-class TrafficLogController extends AdminController
-{
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
-    public function index($request, $response, $args): ResponseInterface
-    {
-        $id = $args['id'];
-        $user = User::find($id);
-        $table_config['total_column'] = array(
-            'id'              => 'ID',
-            'node_name'       => '使用节点',
-            'rate'            => '倍率',
-            'origin_traffic'  => '实际使用流量',
-            'traffic'         => '结算流量',
-            'log_time'        => '记录时间'
-        );
-        $table_config['default_show_column'] = array();
-        foreach ($table_config['total_column'] as $column => $value) {
-            $table_config['default_show_column'][] = $column;
-        }
-        $table_config['ajax_url'] = 'traffic/ajax';
-
-        return $response->write(
-            $this->view()
-                ->assign('table_config', $table_config)
-                ->assign('user', $user)
-                ->display('admin/user/traffic.tpl')
-        );
-    }
-
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
-    public function ajax($request, $response, $args): ResponseInterface
-    {
-        $start        = $request->getParam("start");
-        $limit_length = $request->getParam('length');
-        $id           = $args['id'];
-        $user         = User::find($id);
-        $datas        = TrafficLog::where('user_id', $user->id)->skip($start)->limit($limit_length)->orderBy('id', 'desc')->get();
-        $total_conut  = TrafficLog::where('user_id', $user->id)->count();
-        $out_data     = [];
-        foreach ($datas as $data) {
-            $tempdata                   = [];
-            $tempdata['id']             = $data->id;
-            $node                       = Node::where('id', $data->node_id)->first();
-            $tempdata['node_name']      = $node->name;
-            $tempdata['rate']           = $data->rate;
-            $tempdata['origin_traffic'] = Tools::flowAutoShow($data->u + $data->d);
-            $tempdata['traffic']        = $data->traffic;
-            $tempdata['log_time']       = date('Y-m-d H:i:s', $data->log_time);
-            $out_data[]                 = $tempdata;
-        }
-        $info = [
-            'draw'              => $request->getParam('draw'),
-            'recordsTotal'      => $total_conut,
-            'recordsFiltered'   => $total_conut,
-            'data'              => $out_data
-        ];
-
-        return $response->write(
-            json_encode($info)
-        );
-    }
-}

+ 0 - 36
src/Controllers/AdminController.php

@@ -177,42 +177,6 @@ class AdminController extends UserController
         return $response->getBody()->write(json_encode($res));
     }
 
-    public function trafficLog($request, $response, $args)
-    {
-        $table_config['total_column'] = array(
-            'id' => 'ID', 'user_id' => '用户ID',
-            'user_name' => '用户名', 'node_name' => '使用节点',
-            'rate' => '倍率', 'origin_traffic' => '实际使用流量',
-            'traffic' => '结算流量',
-            'log_time' => '记录时间'
-        );
-        $table_config['default_show_column'] = array(
-            'id', 'user_id',
-            'user_name', 'node_name',
-            'rate', 'origin_traffic',
-            'traffic', 'log_time'
-        );
-        $table_config['ajax_url'] = 'trafficlog/ajax';
-        return $this->view()->assign('table_config', $table_config)->display('admin/trafficlog.tpl');
-    }
-
-    public function ajax_trafficLog($request, $response, $args)
-    {
-        $datatables = new Datatables(new DatatablesHelper());
-        $datatables->query('Select log.id,log.user_id,user.user_name,node.name as node_name,log.rate,(log.u + log.d) as origin_traffic,log.traffic,log.log_time from user_traffic_log as log,user,ss_node as node WHERE log.user_id = user.id AND log.node_id = node.id');
-
-        $datatables->edit('log_time', static function ($data) {
-            return date('Y-m-d H:i:s', $data['log_time']);
-        });
-
-        $datatables->edit('origin_traffic', static function ($data) {
-            return Tools::flowAutoShow($data['origin_traffic']);
-        });
-
-        $body = $response->getBody();
-        $body->write($datatables->generate());
-    }
-
     public function ajax_payback($request, $response, $args)
     {
         $datatables = new Datatables(new DatatablesHelper());

+ 0 - 12
src/Controllers/Mod_Mu/UserController.php

@@ -8,7 +8,6 @@ use App\Models\{
     Node,
     User,
     DetectLog,
-    TrafficLog,
     NodeOnlineLog
 };
 use App\Utils\Tools;
@@ -168,17 +167,6 @@ class UserController extends BaseController
                     ];
                     return $this->echoJson($response, $res);
                 }
-
-                // log
-                $traffic = new TrafficLog();
-                $traffic->user_id = $user_id;
-                $traffic->u = $u;
-                $traffic->d = $d;
-                $traffic->node_id = $node_id;
-                $traffic->rate = $node->traffic_rate;
-                $traffic->traffic = Tools::flowAutoShow(($u + $d) * $node->traffic_rate);
-                $traffic->log_time = time();
-                $traffic->save();
             }
         }
 

+ 0 - 19
src/Controllers/UserController.php

@@ -26,7 +26,6 @@ use App\Models\{
     Speedtest,
     DetectLog,
     DetectRule,
-    TrafficLog,
     InviteCode,
     EmailVerify,
     UserSubscribeLog
@@ -1353,24 +1352,6 @@ class UserController extends BaseController
         return $this->echoJson($response, $res);
     }
 
-    public function trafficLog($request, $response, $args)
-    {
-        $traffic = TrafficLog::where('user_id', $this->user->id)->where('log_time', '>', time() - 3 * 86400)->orderBy('id', 'desc')->get();
-
-        if ($request->getParam('json') == 1) {
-            $res['ret'] = 1;
-            foreach ($traffic as $trafficdata) {
-                $trafficdata->total_used = $trafficdata->totalUsedRaw();
-                $trafficdata->name = $trafficdata->node()->name;
-            }
-            $res['traffic'] = $traffic;
-
-            return $this->echoJson($response, $res);
-        }
-
-        return $this->view()->assign('logs', $traffic)->display('user/trafficlog.tpl');
-    }
-
     public function detect_index($request, $response, $args)
     {
         $pageNum = $request->getQueryParams()['page'] ?? 1;

+ 0 - 13
src/Models/Node.php

@@ -120,19 +120,6 @@ class Node extends Model
         return $log;
     }
 
-    public function getTrafficFromLogs()
-    {
-        $id = $this->attributes['id'];
-
-        $traffic = TrafficLog::where('node_id', $id)->sum('u') + TrafficLog::where('node_id', $id)->sum('d');
-
-        if ($traffic == 0) {
-            return '暂无数据';
-        }
-
-        return Tools::flowAutoShow($traffic);
-    }
-
     public function isNodeOnline()
     {
         $delay = 300;

+ 0 - 1
src/Models/User.php

@@ -352,7 +352,6 @@ class User extends Model
         InviteCode::where('user_id', '=', $uid)->delete();
         TelegramSession::where('user_id', '=', $uid)->delete();
         UnblockIp::where('userid', '=', $uid)->delete();
-        TrafficLog::where('user_id', '=', $uid)->delete();
         Token::where('user_id', '=', $uid)->delete();
         PasswordReset::where('email', '=', $email)->delete();
         UserSubscribeLog::where('user_id', '=', $uid)->delete();