<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.online.OlUserSession" %>
<%@ page import="net.sz600.system.SzLog" %>
<%@ page import="net.sz600.organize.SzLogin" %>
<%@ page import="net.sz600.organize.SzLoginInfo" %>

<%
	//不能包含sessionInfo.jsp
	//因为sessionInfo.jsp检测到断线后，跳转到relogin.jsp，relogin又包含sessionInfo的话，导致死循环，当tomcat重新启动或断线时出现。
		String c = SzConvert.toSpaceStr((String)session.getAttribute("SzHelp")); //是否从助手登陆
    String COMPANY = SzConvert.toSpaceStr((String)session.getAttribute("SzCOMPANY")); //分公司信息    
    String skinType = SzConvert.toSpaceStr((String)session.getAttribute("SzSkinType")); //界面类型
    //记录访问日志
    String sIp = SzConvert.toSpaceStr( request.getRemoteHost());     
%>
<%
	String strUrl = "indexApp.jsp";

	String sDLID = SzConvert.toZeroStr(request.getParameter("DLID"));
	////绑定listener 2008-09-19
  //String szDLID_SESSION = SzConvert.toZeroStr((String)session.getAttribute("SzDLID"));	
	if (!sDLID.equals("0")) {
		//正常的退出
		SzLogin szLogin = new SzLogin();
		SzLoginInfo szLoginInfo = (SzLoginInfo)szLogin.getInfoByKey(SzConvert.toInt(sDLID));
		SzLog.getInstance().logoutLog(szLoginInfo.getDLID(), szLoginInfo.getDLXM(), sIp, COMPANY );
	} else {
		//检测到断线，或非法访问时被强制退出
		//SzLog.getInstance().logoutExceptionLog(0, "", sIp, COMPANY );		
	}
	
	OlUserSession.getInstance().removeUser(sDLID);
	session.removeAttribute(sDLID);
	
	StringBuffer sb = new StringBuffer("top.location.href='");
       sb.append(strUrl);
	boolean flag = false;
	if (!c.equals("")) {
		sb.append("?c=");
		sb.append(c);
		flag = true;
	}
	if (!COMPANY.equals("") && !COMPANY.equals("0")) {
		if (flag) {
			sb.append("&");
		} else {
			sb.append("?");
		}
		sb.append("COMPANY=");
		sb.append(COMPANY);		
	}
	sb.append("'");
	String s = sb.toString();
	sb = null;
	

	out.println("<script language=javascript>"); 
	//out.println("top.location.href='index.jsp?c=" + c + "&COMPANY=" + COMPANY + "'");
	out.println(s);
	out.println("</script>");
%>

