You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

208 lines
6.3 KiB

1 year ago
10 months ago
1 year ago
1 year ago
  1. {extend name="admin/layout" /}
  2. {block name="title"}黑白名单{/block}
  3. {block name="main"}
  4. <style>
  5. .alert{margin-bottom: 5px;}
  6. </style>
  7. <div class="container" style="padding-top:70px;">
  8. <div class="col-xs-12 col-md-10 center-block" style="float: none;">
  9. <ul class="nav nav-tabs">
  10. <li class="{if $type=='black'}active{/if}"><a href="/admin/list">黑名单列表</a></li><li class="{if $type=='white'}active{/if}"><a href="/admin/list/type/white">白名单列表</a></li>
  11. </ul>
  12. {if $type=='black' && config_get('whitelist')=='1'}
  13. <div class="alert alert-warning">提示:当前为白名单模式,黑名单列表里面的记录不会生效。</div>
  14. {/if}
  15. {if $type=='white' && config_get('whitelist')=='0'}
  16. <div class="alert alert-warning">提示:当前未开启白名单模式,白名单列表里面的记录不会生效。</div>
  17. {/if}
  18. {if $type=='black'}
  19. <div class="alert alert-info">添加到黑名单列表中的服务器IP将无法使用此云端</div>
  20. {/if}
  21. {if $type=='white'}
  22. <div class="alert alert-info">只有添加到白名单列表中的服务器IP才可以使用此云端</div>
  23. {/if}
  24. <div id="searchToolbar">
  25. <form onsubmit="return searchSubmit()" method="GET" class="form-inline">
  26. <div class="form-group">
  27. <label>搜索</label>
  28. <input type="text" class="form-control" name="ip" placeholder="服务器IP">
  29. </div>
  30. <div class="form-group">
  31. <button class="btn btn-primary" type="submit"><i class="fa fa-search"></i> 搜索</button>&nbsp;
  32. <a href="javascript:searchClear()" class="btn btn-default"><i class="fa fa-repeat"></i> 重置</a>&nbsp;
  33. <a href="javascript:add_item()" class="btn btn-success"><i class="fa fa-plus"></i> 添加</a>&nbsp;
  34. </div>
  35. </form>
  36. </div>
  37. <table id="listTable">
  38. </table>
  39. </div>
  40. </div>
  41. <script src="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/layer/3.5.1/layer.js"></script>
  42. <script src="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/bootstrap-table/1.19.1/bootstrap-table.min.js"></script>
  43. <script src="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/bootstrap-table/1.19.1/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script>
  44. <script src="/static/js/custom.js"></script>
  45. <script>
  46. function setEnable(id,enable) {
  47. $.ajax({
  48. type : 'POST',
  49. url : '/admin/list_op/type/{$type}',
  50. data: { act:'enable', id:id, enable:enable},
  51. dataType : 'json',
  52. success : function(data) {
  53. if(data.code == 0){
  54. searchSubmit();
  55. }else{
  56. layer.msg(data.msg, {icon:2, time:1500});
  57. }
  58. },
  59. error:function(data){
  60. layer.msg('服务器错误');
  61. }
  62. });
  63. }
  64. function add_item(){
  65. layer.open({
  66. area: ['360px'],
  67. title: '添加IP{$typename}',
  68. content: '<div class="form-group"><input type="text" class="form-control" name="item_input" placeholder="请输入服务器IP" value=""></div>',
  69. yes: function(){
  70. var ip = $("input[name='item_input']").val();
  71. $.ajax({
  72. type : 'POST',
  73. url : '/admin/list_op/type/{$type}',
  74. data: { act:'add', ip:ip},
  75. dataType : 'json',
  76. success : function(data) {
  77. if(data.code == 0){
  78. layer.msg('添加成功', {icon:1, time:800});
  79. searchSubmit();
  80. }else{
  81. layer.alert(data.msg, {icon: 2});
  82. }
  83. },
  84. error:function(data){
  85. layer.msg('服务器错误');
  86. }
  87. });
  88. },
  89. shadeClose: true
  90. });
  91. }
  92. function edit_item(id){
  93. $.ajax({
  94. type : 'POST',
  95. url : '/admin/list_op/type/{$type}',
  96. data: { act:'get', id:id},
  97. dataType : 'json',
  98. success : function(data) {
  99. if(data.code == 0){
  100. layer.open({
  101. area: ['360px'],
  102. title: '编辑IP{$typename}',
  103. content: '<div class="form-group"><input type="text" class="form-control" name="item_input" placeholder="请输入服务器IP" value="'+data.data.ip+'"></div>',
  104. yes: function(){
  105. var ip = $("input[name='item_input']").val();
  106. $.ajax({
  107. type : 'POST',
  108. url : '/admin/list_op/type/{$type}',
  109. data: { act:'edit', id:id, ip:ip},
  110. dataType : 'json',
  111. success : function(data) {
  112. if(data.code == 0){
  113. layer.msg('修改成功', {icon:1, time:800});
  114. searchSubmit();
  115. }else{
  116. layer.alert(data.msg, {icon: 2});
  117. }
  118. },
  119. error:function(data){
  120. layer.msg('服务器错误');
  121. }
  122. });
  123. },
  124. shadeClose: true
  125. });
  126. }else{
  127. layer.alert(data.msg, {icon: 2});
  128. }
  129. },
  130. error:function(data){
  131. layer.msg('服务器错误');
  132. }
  133. });
  134. }
  135. function del_item(id) {
  136. if(confirm('是否确定删除此记录?')){
  137. $.ajax({
  138. type : 'POST',
  139. url : '/admin/list_op/type/{$type}',
  140. data: { act:'del', id:id},
  141. dataType : 'json',
  142. success : function(data) {
  143. if(data.code == 0){
  144. layer.msg('删除成功!', {icon:1, time:800});
  145. searchSubmit();
  146. }else{
  147. layer.alert(data.msg, {icon:2});
  148. }
  149. },
  150. error:function(data){
  151. layer.msg('服务器错误');
  152. }
  153. });
  154. }
  155. }
  156. $(document).ready(function(){
  157. updateToolbar();
  158. const defaultPageSize = 15;
  159. const pageNumber = typeof window.$_GET['pageNumber'] != 'undefined' ? parseInt(window.$_GET['pageNumber']) : 1;
  160. const pageSize = typeof window.$_GET['pageSize'] != 'undefined' ? parseInt(window.$_GET['pageSize']) : defaultPageSize;
  161. $("#listTable").bootstrapTable({
  162. url: '/admin/list_data/type/{$type}',
  163. pageNumber: pageNumber,
  164. pageSize: pageSize,
  165. classes: 'table table-striped table-hover table-bottom-border',
  166. columns: [
  167. {
  168. field: 'id',
  169. title: 'ID',
  170. formatter: function(value, row, index) {
  171. return '<b>'+value+'</b>';
  172. }
  173. },
  174. {
  175. field: 'ip',
  176. title: '服务器IP'
  177. },
  178. {
  179. field: 'enable',
  180. title: '是否生效',
  181. formatter: function(value, row, index) {
  182. return value?'<a href="javascript:setEnable('+row.id+',0)"><font color=green><i class="fa fa-check-circle"></i>已生效</font></a>':'<a href="javascript:setEnable('+row.id+',1)"><font color=red><i class="fa fa-times-circle"></i>未生效</font></a>';
  183. }
  184. },
  185. {
  186. field: 'addtime',
  187. title: '添加时间'
  188. },
  189. {
  190. field: '',
  191. title: '操作',
  192. formatter: function(value, row, index) {
  193. return '<a href="javascript:edit_item('+row.id+')" class="btn btn-xs btn-info">编辑</a>&nbsp;<a href="javascript:del_item('+row.id+')" class="btn btn-xs btn-danger">删除</a>';
  194. },
  195. },
  196. ],
  197. })
  198. })
  199. </script>
  200. {/block}