forbidip.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:7k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=utf-8" %>
  2. <%@ page import="java.util.*"%>
  3. <%@ page import="cn.js.fan.util.*"%>
  4. <%@ page import="cn.js.fan.db.*"%>
  5. <%@ page import="cn.js.fan.base.*"%>
  6. <%@ page import="com.redmoon.forum.security.*"%>
  7. <%@ page import="com.redmoon.forum.*"%>
  8. <%@ page import="cn.js.fan.web.*"%>
  9. <%@ taglib uri="/WEB-INF/tlds/LabelTag.tld" prefix="lt" %>
  10. <jsp:useBean id="StrUtil" scope="page" class="cn.js.fan.util.StrUtil"/>
  11. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  12. <html><head>
  13. <meta http-equiv="pragma" content="no-cache">
  14. <link rel="stylesheet" href="../../common.css">
  15. <LINK href="default.css" type=text/css rel=stylesheet>
  16. <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
  17. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  18. <title><lt:Label res="res.label.forum.admin.forbidip" key="forbidip"/></title>
  19. <body bgcolor="#FFFFFF" topmargin='0' leftmargin='0'>
  20. <jsp:useBean id="privilege" scope="page" class="com.redmoon.forum.Privilege"/>
  21. <%
  22. if (!privilege.isMasterLogin(request)) {
  23. out.print(cn.js.fan.web.SkinUtil.makeErrMsg(request, cn.js.fan.web.SkinUtil.LoadString(request, "pvg_invalid")));
  24. return;
  25. }
  26. String op = ParamUtil.get(request, "op");
  27. if (op.equals("add")) {
  28. String ip = ParamUtil.get(request, "ip").trim();
  29. if (!StrUtil.isValidIP(ip)) {
  30. out.print(StrUtil.Alert_Back(SkinUtil.LoadString(request, "res.label.forum.admin.forbidip", "ip_format_error")));
  31. return;
  32. }
  33. String userName = ParamUtil.get(request, "userName").trim();
  34. String reason = ParamUtil.get(request, "reason").trim();
  35. if (ip.equals("")) {
  36. out.print(StrUtil.Alert_Back(SkinUtil.LoadString(request, "res.label.forum.admin.forbidip", "ip_can_not_empty")));
  37. }
  38. else {
  39. ForbidIPDb fid = new ForbidIPDb();
  40. fid = fid.getForbidIPDb(ip);
  41. if (fid.isLoaded())
  42. out.print(StrUtil.Alert(SkinUtil.LoadString(request, "res.label.forum.admin.forbidip", "ip_forbided"))); 
  43. else {
  44. fid.setIp(ip);
  45. fid.setUserName(userName);
  46. fid.setReason(reason);
  47. if (fid.create())
  48. out.print(StrUtil.Alert(SkinUtil.LoadString(request, "info_op_success")));
  49. else
  50. out.print(StrUtil.Alert_Back(SkinUtil.LoadString(request, "info_op_fail")));
  51. }
  52. }
  53. }
  54. if (op.equals("del")) {
  55. String ip = ParamUtil.get(request, "ip").trim();
  56. ForbidIPDb fid = new ForbidIPDb();
  57. fid = fid.getForbidIPDb(ip);
  58. if (fid.del())
  59. out.print(StrUtil.Alert(SkinUtil.LoadString(request, "info_op_success")));
  60. else
  61. out.print(StrUtil.Alert_Back(SkinUtil.LoadString(request, "info_op_fail")));
  62. }
  63. %>
  64. <table width='100%' cellpadding='0' cellspacing='0' >
  65.   <tr>
  66.     <td class="head"><lt:Label res="res.label.forum.admin.forbidip" key="forbid_single_ip"/>&nbsp;&nbsp;<a href="forbidiprange.jsp"><lt:Label res="res.label.forum.admin.forbidip" key="forbid_single_ip_range"/></a>&nbsp;</td>
  67.   </tr>
  68. </table>
  69. <br>
  70. <%
  71. ForbidIPDb fid = new ForbidIPDb();
  72. String sql = "select ip from sq_forbid_ip order by add_date desc";
  73. int total = fid.getObjectCount(sql);
  74. int pagesize = 20;
  75. int curpage,totalpages;
  76. Paginator paginator = new Paginator(request, total, pagesize);
  77. //设置当前页数和总页数
  78. totalpages = paginator.getTotalPages();
  79. curpage = paginator.getCurrentPage();
  80. if (totalpages==0)
  81. {
  82. curpage = 1;
  83. totalpages = 1;
  84. }
  85. %>
  86. <table width="98%" height="227" border='0' align="center" cellpadding='0' cellspacing='0' class="frame_gray">
  87.   <tr> 
  88.     <td height=20 align="left" class="thead"><lt:Label res="res.label.forum.admin.forbidip" key="ip_manage"/> </td>
  89.   </tr>  
  90.   <tr> 
  91.     <td valign="top"><br>
  92.       <table width="92%" border="0" align="center">
  93.       <tr>
  94.         <td align="right"><%=paginator.getPageStatics(request)%></td>
  95.       </tr>
  96.     </table>
  97.       <table width="92%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999">
  98.       <tr align="center" bgcolor="#F8F7F9">
  99.         <td width="13%" height="24" bgcolor="#EFEBDE"><strong>IP</strong></td>
  100.         <td width="16%" height="24" bgcolor="#EFEBDE"><span class="thead">
  101.           <lt:Label res="res.label.forum.admin.forbidip" key="ip_manage"/>
  102.         </span></td>
  103.         <td width="38%" height="24" bgcolor="#EFEBDE"><strong><lt:Label res="res.label.forum.admin.forbidip" key="reason"/></strong></td>
  104.         <td width="21%" bgcolor="#EFEBDE"><strong><lt:Label res="res.label.forum.admin.forbidip" key="forbid_date"/></strong></td>
  105.         <td width="12%" bgcolor="#EFEBDE"><strong><lt:Label key="op"/></strong></td>
  106.       </tr>
  107. <%
  108. ObjectBlockIterator oir = fid.getObjects(sql, (curpage-1)*pagesize, curpage*pagesize);
  109. while (oir.hasNext()) {
  110. fid = (ForbidIPDb)oir.next();
  111. %>
  112.       <tr align="center">
  113.         <td height="24" bgcolor="#FFF7FF"><%=fid.getIp()%></td>
  114.        <td height="24" bgcolor="#FFF7FF"><%=fid.getUserName()%></td>
  115.         <td height="24" bgcolor="#FFF7FF"><%=fid.getReason()%></td>
  116.       <td bgcolor="#FFF7FF">
  117.    <%=DateUtil.format(fid.getAddDate(), "yyyy-MM-dd HH:mm:ss")%>
  118.   </td>
  119.         <td height="24" bgcolor="#FFF7FF"><a href="?op=del&ip=<%=fid.getIp()%>"><lt:Label key="op_del"/></a> </td>
  120.       </tr>
  121. <%}%>
  122.     </table>
  123.       <table width="92%" border="0" cellspacing="1" cellpadding="3" align="center" class="9black">
  124.         <tr>
  125.           <td height="23" align="right">
  126.               <%
  127.   String querystr = "";
  128.     out.print(paginator.getCurPageBlock("forbidip.jsp?"+querystr));
  129. %>          </td>
  130.         </tr>
  131.       </table>
  132.       <br>
  133.     <table width="50%" border="0" align="center" cellpadding="2" cellspacing="0" class="tableframe_gray">
  134. <form name=form1 action="?op=add" method=post>
  135.       <tr>
  136.         <td colspan="2" align="center" class="thead"><lt:Label res="res.label.forum.admin.forbidip" key="add_ip"/></td>
  137.         </tr>
  138.       <tr>
  139.         <td width="22%">IP</td>
  140.         <td width="78%"><input name="ip" maxlength="15" ></td>
  141.       </tr>
  142.       <tr>
  143.         <td><lt:Label res="res.label.forum.admin.forbidip" key="user_name"/>          </td>
  144.         <td><input name="userName" maxlength="20" ></td>
  145.       </tr>
  146.       <tr>
  147.         <td><lt:Label res="res.label.forum.admin.forbidip" key="reason"/></td>
  148.         <td><input name="reason" size="50" ></td>
  149.       </tr>
  150.       <tr>
  151.         <td colspan="2" align="center"><input name="submit" type="submit" value="<lt:Label key="op_add"/>"></td>
  152.         </tr>
  153. </form>
  154.     </table> 
  155.     <br></td>
  156.   </tr>
  157. </table>
  158. </td> </tr>             
  159.       </table>                                        
  160.        </td>                                        
  161.      </tr>                                        
  162.  </table>                                        
  163.                                
  164. </body>                                        
  165. </html>                            
  166.