banip.tpl 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. }else{
  54. if (data.info){
  55. alert(data.info);
  56. }else{
  57. window.location.href="/accountlogin";
  58. }
  59. }
  60. }
  61. });
  62. }
  63. function submitDelete(ip) {
  64. var token = document.getElementById("token").value;
  65. var text = "token=" + encodeURI(token);
  66. text += "&ip=" + encodeURI(ip);
  67. $.ajax({
  68. type:"delete",
  69. url:"/banip?" + text,
  70. success:function (data) {
  71. // alert(data.status);
  72. if (data.status){
  73. window.location.href="/banip";
  74. }else{
  75. if (data.info){
  76. alert(data.info);
  77. }else{
  78. window.location.href="/accountlogin";
  79. }
  80. }
  81. }
  82. });
  83. }
  84. </script>
  85. </body>
  86. </html>