userList.blade.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/plugins/datatables/datatables.min.css" rel="stylesheet" type="text/css" />
  4. <link href="/assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
  5. @endsection
  6. @section('title', '控制面板')
  7. @section('content')
  8. <!-- BEGIN CONTENT BODY -->
  9. <div class="page-content" style="padding-top:0;">
  10. <!-- BEGIN PAGE BASE CONTENT -->
  11. <div class="row">
  12. <div class="col-md-12">
  13. <!-- BEGIN EXAMPLE TABLE PORTLET-->
  14. <div class="portlet light bordered">
  15. <div class="portlet-title">
  16. <div class="caption font-dark">
  17. <span class="caption-subject bold uppercase"> 用户列表 </span>
  18. </div>
  19. <div class="actions">
  20. <div class="btn-group btn-group-devided">
  21. <button class="btn sbold red" onclick="exportSSJson()"> 导出JSON </button>
  22. <button class="btn sbold blue" onclick="batchAddUsers()"> 批量生成 </button>
  23. <button class="btn sbold blue" onclick="addUser()"> 添加用户 </button>
  24. </div>
  25. </div>
  26. </div>
  27. <div class="portlet-body">
  28. <div class="row" style="padding-bottom:5px;">
  29. <div class="col-md-2 col-sm-2">
  30. <input type="text" class="col-md-4 form-control input-sm" name="username" value="{{Request::get('username')}}" id="username" placeholder="用户名" onkeydown="if(event.keyCode==13){doSearch();}">
  31. </div>
  32. <div class="col-md-2 col-sm-2">
  33. <input type="text" class="col-md-4 form-control input-sm" name="wechat" value="{{Request::get('wechat')}}" id="wechat" placeholder="微信" onkeydown="if(event.keyCode==13){doSearch();}">
  34. </div>
  35. <div class="col-md-2 col-sm-2">
  36. <input type="text" class="col-md-4 form-control input-sm" name="qq" value="{{Request::get('qq')}}" id="qq" placeholder="QQ" onkeydown="if(event.keyCode==13){doSearch();}">
  37. </div>
  38. </div>
  39. <div class="row">
  40. <div class="col-md-2 col-sm-2">
  41. <input type="text" class="col-md-4 form-control input-sm" name="port" value="{{Request::get('port')}}" id="port" placeholder="端口" onkeydown="if(event.keyCode==13){doSearch();}">
  42. </div>
  43. <div class="col-md-2 col-sm-2">
  44. <select class="form-control input-sm" name="pay_way" id="pay_way" onChange="doSearch()">
  45. <option value="" @if(Request::get('pay_way') == '') selected @endif>付费方式</option>
  46. <option value="0" @if(Request::get('pay_way') == '0') selected @endif>免费</option>
  47. <option value="1" @if(Request::get('pay_way') == '1') selected @endif>月付</option>
  48. <option value="2" @if(Request::get('pay_way') == '2') selected @endif>季付</option>
  49. <option value="3" @if(Request::get('pay_way') == '3') selected @endif>半年付</option>
  50. <option value="4" @if(Request::get('pay_way') == '4') selected @endif>年付</option>
  51. </select>
  52. </div>
  53. <div class="col-md-2 col-sm-2">
  54. <select class="form-control input-sm" name="status" id="status" onChange="doSearch()">
  55. <option value="" @if(Request::get('status') == '') selected @endif>状态</option>
  56. <option value="-1" @if(Request::get('status') == '-1') selected @endif>禁用</option>
  57. <option value="0" @if(Request::get('status') == '0') selected @endif>未激活</option>
  58. <option value="1" @if(Request::get('status') == '1') selected @endif>正常</option>
  59. </select>
  60. </div>
  61. <div class="col-md-2 col-sm-2">
  62. <select class="form-control input-sm" name="enable" id="enable" onChange="doSearch()">
  63. <option value="" @if(Request::get('enable') == '') selected @endif>SSR(R)状态</option>
  64. <option value="1" @if(Request::get('enable') == '1') selected @endif>启用</option>
  65. <option value="0" @if(Request::get('enable') == '0') selected @endif>禁用</option>
  66. </select>
  67. </div>
  68. <div class="col-md-2 col-sm-2">
  69. <button type="button" class="btn btn-sm blue" onclick="doSearch();">查询</button>
  70. <button type="button" class="btn btn-sm grey" onclick="doReset();">重置</button>
  71. </div>
  72. </div>
  73. <div class="table-scrollable table-scrollable-borderless">
  74. <table class="table table-hover table-light">
  75. <thead>
  76. <tr>
  77. <th> # </th>
  78. <th> 用户名 </th>
  79. <th> 端口 </th>
  80. <th> 加密方式 </th>
  81. <th> 协议 </th>
  82. <th> 混淆 </th>
  83. <th> 已消耗 </th>
  84. <th> 最后使用 </th>
  85. <th> 有效期 </th>
  86. <th> 状态 </th>
  87. <th> 代理 </th>
  88. <th> 操作 </th>
  89. </tr>
  90. </thead>
  91. <tbody>
  92. @if ($userList->isEmpty())
  93. <tr>
  94. <td colspan="12" style="text-align: center;">暂无数据</td>
  95. </tr>
  96. @else
  97. @foreach ($userList as $user)
  98. <tr class="odd gradeX {{$user->trafficWarning ? 'danger' : ''}}">
  99. <td> {{$user->id}} </td>
  100. <td> {{$user->username}} </td>
  101. <td> <span class="label label-danger"> {{$user->port ? $user->port : '未分配'}} </span> </td>
  102. <td> <span class="label label-default"> {{$user->method}} </span> </td>
  103. <td> <span class="label label-default"> {{$user->protocol}} </span> </td>
  104. <td> <span class="label label-default"> {{$user->obfs}} </span> </td>
  105. <td class="center"> {{$user->used_flow}} / {{$user->transfer_enable}} </td>
  106. <td class="center"> {{empty($user->t) ? '未使用' : date('Y-m-d H:i:s', $user->t)}} </td>
  107. <td class="center">
  108. @if ($user->expireWarning)
  109. <span class="label label-warning"> {{$user->expire_time}} </span>
  110. @else
  111. {{$user->expire_time}}
  112. @endif
  113. </td>
  114. <td>
  115. @if ($user->status == '1')
  116. <span class="label label-info">正常</span>
  117. @elseif ($user->status == '0')
  118. <span class="label label-default">未激活</span>
  119. @else
  120. <span class="label label-danger">禁用</span>
  121. @endif
  122. </td>
  123. <td>
  124. @if ($user->enable)
  125. <span class="label label-info"><i class="fa fa-check"></i></span>
  126. @else
  127. <span class="label label-danger"><i class="fa fa-close"></i></span>
  128. @endif
  129. </td>
  130. <td>
  131. <button type="button" class="btn btn-sm blue btn-outline" onclick="editUser('{{$user->id}}')">
  132. <i class="fa fa-pencil"></i>
  133. </button>
  134. <button type="button" class="btn btn-sm green btn-outline" onclick="doExport('{{$user->id}}')">
  135. <i class="fa fa-paper-plane-o"></i>
  136. </button>
  137. <button type="button" class="btn btn-sm purple btn-outline" onclick="doMonitor('{{$user->id}}')">
  138. <i class="fa fa-area-chart"></i>
  139. </button>
  140. <button type="button" class="btn btn-sm green-meadow btn-outline" onclick="resetTraffic('{{$user->id}}')">
  141. <i class="fa fa-refresh"></i>
  142. </button>
  143. <button type="button" class="btn btn-sm red btn-outline" onclick="switchToUser('{{$user->id}}')">切</button>
  144. </td>
  145. </tr>
  146. @endforeach
  147. @endif
  148. </tbody>
  149. </table>
  150. </div>
  151. <div class="row">
  152. <div class="col-md-4 col-sm-4">
  153. <div class="dataTables_info" role="status" aria-live="polite">共 {{$userList->total()}} 个账号</div>
  154. </div>
  155. <div class="col-md-8 col-sm-8">
  156. <div class="dataTables_paginate paging_bootstrap_full_number pull-right">
  157. {{ $userList->links() }}
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. <!-- END EXAMPLE TABLE PORTLET-->
  164. </div>
  165. </div>
  166. <!-- END PAGE BASE CONTENT -->
  167. </div>
  168. <!-- END CONTENT BODY -->
  169. @endsection
  170. @section('script')
  171. <script src="/js/layer/layer.js" type="text/javascript"></script>
  172. <script type="text/javascript">
  173. // 导出原版json配置
  174. function exportSSJson() {
  175. layer.msg("成功导出原版SS的用户配置信息,加密方式为系统默认的加密方式");
  176. window.location.href = '{{url('admin/exportSSJson')}}';
  177. }
  178. // 批量生成账号
  179. function batchAddUsers() {
  180. layer.confirm('将自动生成5个账号,确定继续吗?', {icon: 3, title:'警告'}, function(index) {
  181. $.post("{{url('admin/batchAddUsers')}}", {_token:'{{csrf_token()}}'}, function(ret) {
  182. layer.msg(ret.message, {time:1000}, function() {
  183. if (ret.status == 'success') {
  184. window.location.reload();
  185. }
  186. });
  187. });
  188. layer.close(index);
  189. });
  190. }
  191. // 添加账号
  192. function addUser() {
  193. window.location.href = '{{url('admin/addUser')}}';
  194. }
  195. // 编辑账号
  196. function editUser(id) {
  197. window.location.href = '{{url('admin/editUser?id=')}}' + id + '&page=' + '{{Request::get('page', 1)}}';
  198. }
  199. // 删除账号
  200. function delUser(id) {
  201. layer.confirm('确定删除账号?', {icon: 2, title:'警告'}, function(index) {
  202. $.post("{{url('admin/delUser')}}", {id:id, _token:'{{csrf_token()}}'}, function(ret) {
  203. layer.msg(ret.message, {time:1000}, function() {
  204. if (ret.status == 'success') {
  205. window.location.reload();
  206. }
  207. });
  208. });
  209. layer.close(index);
  210. });
  211. }
  212. // 搜索
  213. function doSearch() {
  214. var username = $("#username").val();
  215. var wechat = $("#wechat").val();
  216. var qq = $("#qq").val();
  217. var port = $("#port").val();
  218. var pay_way = $("#pay_way option:checked").val();
  219. var status = $("#status option:checked").val();
  220. var enable = $("#enable option:checked").val();
  221. window.location.href = '{{url('admin/userList')}}' + '?username=' + username + '&wechat=' + wechat + '&qq=' + qq + '&port=' + port + '&pay_way=' + pay_way + '&status=' + status + '&enable=' + enable;
  222. }
  223. // 重置
  224. function doReset() {
  225. window.location.href = '{{url('admin/userList')}}';
  226. }
  227. // 导出配置
  228. function doExport(id) {
  229. window.location.href = '{{url('admin/export?id=')}}' + id;
  230. }
  231. // 流量监控
  232. function doMonitor(id) {
  233. window.location.href = '{{url('admin/userMonitor?id=')}}' + id;
  234. }
  235. // 重置流量
  236. function resetTraffic(id) {
  237. layer.confirm('确定重置该用户流量吗?', {icon: 7, title:'警告'}, function(index) {
  238. $.post("{{url('admin/resetUserTraffic')}}", {_token:'{{csrf_token()}}', id:id}, function (ret) {
  239. layer.msg(ret.message, {time:1000}, function() {
  240. if (ret.status == 'success') {
  241. window.location.reload();
  242. }
  243. });
  244. });
  245. layer.close(index);
  246. });
  247. }
  248. // 切换用户身份
  249. function switchToUser(user_id) {
  250. $.ajax({
  251. 'url': "{{url("/admin/switchToUser")}}",
  252. 'data': {
  253. 'user_id': user_id,
  254. '_token': '{{csrf_token()}}'
  255. },
  256. 'dataType': "json",
  257. 'type': "POST",
  258. success: function (ret) {
  259. layer.msg(ret.message, {time: 1000}, function () {
  260. if (ret.status == 'success') {
  261. window.location.href = "/";
  262. }
  263. });
  264. }
  265. });
  266. }
  267. </script>
  268. @endsection