banip.tpl 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>欢迎页面-X-admin2.0</title>
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  8. <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
  9. <link rel="stylesheet" href="./static/css/font.css">
  10. <link rel="stylesheet" href="./static/css/xadmin.css">
  11. <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  12. <script src="./static/lib/layui/layui.js" charset="utf-8"></script>
  13. <script type="text/javascript" src="./static/js/xadmin.js"></script>
  14. </head>
  15. <body>
  16. <input type="text" id="token" value={{.token}} hidden=true>
  17. <div class="x-body layui-anim layui-anim-up">
  18. <blockquote class="layui-elem-quote">
  19. <input id="ip" name="ip" placeholder="IP" type="text" lay-verify="required" class="layui-input">
  20. <br>
  21. <input class="layui-btn" type="button" onclick="addBanIP()" value=新增>
  22. </blockquote>
  23. </div>
  24. <table class="radio-table" border="1">
  25. <thead>
  26. <th style="width:128px;">IP</th>
  27. <th style="width:128px;">操作</th>
  28. </thead>
  29. <tbody>
  30. {{range .ipList}}
  31. <tr>
  32. <td style = "text-align:center;">{{.IP}}</td>
  33. <td style = "text-align:center;">
  34. <input class="layui-btn" type="button" onclick="submitDelete({{.IP}})" value=删除>
  35. </td>
  36. </tr>
  37. {{end}}
  38. </tbody>
  39. </table>
  40. <script language="JavaScript">
  41. function addBanIP () {
  42. var token = document.getElementById("token").value;
  43. var ip = document.getElementById("ip").value;
  44. var text = "token=" + encodeURI(token);
  45. text += "&ip=" + encodeURI(ip);
  46. $.ajax({
  47. type:"post",
  48. url:"/banip?" + text,
  49. success:function (data) {
  50. // alert(data.status);
  51. if (data.status){
  52. window.location.href="/banip";
  53. if (data.info){
  54. layer.msg(data.info,{icon:1,time:1000});
  55. }
  56. }else{
  57. if (data.info){
  58. alert(data.info);
  59. }else{
  60. window.location.href="/accountlogin";
  61. }
  62. }
  63. }
  64. });
  65. }
  66. function submitDelete(ip) {
  67. var token = document.getElementById("token").value;
  68. var text = "token=" + encodeURI(token);
  69. text += "&ip=" + encodeURI(ip);
  70. $.ajax({
  71. type:"delete",
  72. url:"/banip?" + text,
  73. success:function (data) {
  74. // alert(data.status);
  75. if (data.status){
  76. window.location.href="/banip";
  77. if (data.info){
  78. layer.msg(data.info,{icon:1,time:1000});
  79. }
  80. }else{
  81. if (data.info){
  82. alert(data.info);
  83. }else{
  84. window.location.href="/accountlogin";
  85. }
  86. }
  87. }
  88. });
  89. }
  90. </script>
  91. </body>
  92. </html>