
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.*,weaver.hrm.*,weaver.security.classLoader.ReflectMethodCall,weaver.general.Util" %>
<jsp:useBean id="xssUtil" class="weaver.filter.XssUtil" scope="page"></jsp:useBean>
<%
    response.setHeader("cache-control", "no-cache");
    response.setHeader("pragma", "no-cache");
    response.setHeader("expires", "Mon 1 Jan 1990 00:00:00 GMT");
	
%>
<%String secondPrefixPath = xssUtil.null2String(xssUtil.getRule().get("second-prefix-path"));%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<style type="text/css">
		*{
			font-family: 微软雅黑; 
			mso-hansi-font-family: 微软雅黑
		}
		.listTable{
			width:100%;
			border:1px solid #dcdcdc;
			border-collapse:collapse;
		}
		.listTable th{
			height:40px;
			background-color:#f0f3f4;
		}
		.listTable th, .listTable td{
			border:1px solid #dcdcdc;
			font-size:12px;
			color:#384049;
		}
		.listTable td{
			height:50px;
			text-align:center;
		}
	</style>
	<script type="text/javascript" src="jquery.min.js"></script>
<%
	User user = HrmUserVarify.getUser (request , response) ;
		if(user == null)  {
			//response.sendRedirect("/login/Login.jsp");
			out.println("please login with admin.");
			return;
		} ;
	int UID = xssUtil.getIntValue(""+xssUtil.getRule().get("userID"),1);
		if (user.getUID()!=UID)
		{
			out.println("please login with admin.");
			//response.sendRedirect("/notice/noright.jsp");
			return;
		}
		
%>

<script type="text/javascript">
	function allow(ip){
		if(confirm("该IP由于存在疑似可疑系统的行为而被禁止访问系统. 你确定要解封吗？")){
			jQuery.ajax({
				url:"MonitorSecurityAjax.jsp",
				method:"POST",
				data:{
					src:"allow",
					ip:ip
				},
				success:function(res){
					if(!!res && res.indexOf("success")>=0){
						document.getElementById(ip+"_tr").remove();
					}else{
						alert("操作失败。");
					}
				},
				error:function(res){
					alert("操作失败。")
				}
			});
		}
	}
</script>

<title>永久黑名单</title>
</head>

<body>
<div style="margin-left:auto;margin-right:auto;width:80%;margin-top:36px;min-height:400px;text-align:center;">
	
	<%
	
			if( user!=null ){
				final Map<String,Map<String,String>> map = xssUtil.getAlwayForbiddenIpMap();
				if(map==null || map.size()==0){
					out.println("<div style='line-height:400px;color:#384049'>未找到永久黑名单信息!</div>");
				}else{
					
	%>
	<div style="margin-top:20px;max-height:600px;overflow:auto;">
		<table class="listTable">
			<colgroup>
				<col width=30%/>
				<col width=30%
				<col width=40%/>
			</colgroup>
			<thead>
				<th>IP</th>
				<th>可疑源IP归属地</th>
				<th>操作</th>
			</thead>
			<tbody>
		<%
						java.util.Iterator it = map.entrySet().iterator();
						ReflectMethodCall rmc = new ReflectMethodCall();	
						while(it.hasNext()){
							java.util.Map.Entry entry = (java.util.Map.Entry)it.next();
							String key = (String)entry.getKey();
							String checkKey = key;
							if(key!=null && key.endsWith(".")){
								checkKey = key+"0";
							}
							String time = "";
							String city = (String)rmc.call("weaver.security.util.IPUtil",null,"getCityInfo",
		            		new Class[]{String.class}, checkKey);
							
		%>
				<tr id="<%=key+"_tr"%>">
					<td style="text-align:center;"><span style="padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;"><%=key%></span></td>
					<td style="text-align:center;"><%=city%></td>
					<td style="text-align:center;" id="<%=key+"_td"%>"><div style="margin-left:auto;margin-right:auto;text-align:center;cursor:pointer;color:#f25f1e;width:54px;height:26px;line-height:26px;border:1px solid #d6d6d6;" onclick="allow('<%=key%>');">解封</div></td>
				</tr>
		<%
						}
				}
		%>
			</tbody>
		</table>
	</div>
	<%
			}else{
				//response.sendRedirect("/notice/noright.jsp");
				out.println("please login with admin.");
			}
		
	%>
</div>
</body>
</html>
