<!--#include file="setup.asp"-->
<!--#include file="plus/Ex_Stock/Exsm_Plus_Conn.asp"-->
<!--#include file="plus/Ex_Stock/Exsm_Plus_Const.asp"-->
<%
	Dim sqlstr,l_type,l_content
	'检查用户名和ＩＤ是否合法
	If Exsm.UserID="" or Exsm.UserID=0 or not isnumeric(Exsm.UserID) or Exsm.StockHolder="" Then
		Response.Redirect "Exsm_Plus_Gupiao.asp"
	Else
		set Rs=stock_conn.execute("select UserName,LockUser from Ex_User where ID="&Exsm.UserID&"")
		'是否存在用户
		If Rs.eof and Rs.bof Then
			Response.Redirect "Exsm_Plus_Gupiao.asp"
		'用户是否锁定
		Elseif Rs(1)>1 Then
			Response.Redirect "Exsm_Plus_Gupiao.asp"
		'是否已经登录
		Elseif not Exsm.Members Then
			Response.Redirect "Exsm_Plus_Gupiao.asp"
		'检查用户等级
		Elseif not Exsm.StockAdmin Then
			Response.Redirect "Exsm_Plus_Gupiao.asp"
		'再次验证身份
		Elseif not Rs(0)=Exsm.StockHolder Then
			Response.Redirect "Exsm_Plus_Gupiao.asp"
		Else
			Select Case request("action")
				Case "Anlog"
				sqlstr=" where l_type=1 "
				l_type=1
				main
				Case "Dalog"
					sqlstr=" where l_type=2 "
					l_type=2
					main
				Case "Stlog"
					sqlstr=" where l_type=3 "
					l_type=3
					main
				Case "Ellog"
					sqlstr=" where l_type=4 "
					l_type=4
					main
				Case "Uslog"
					sqlstr=" where l_type=5 "
					l_type=5
					main
				Case "Prlog"
					sqlstr=" where l_type=6 "
					l_type=6
					main
				Case "DelLog"
					DelLog
				Case Else
					sqlstr=" "
					l_type=""
					main
			End Select
		End if
	End if
	Sub main()
		Exsm.Title 1,"日志管理"
%>
		<table class=a2 width=<%=Exsm.AssignWidth%> cellspacing=1 cellpadding=3 align=center border=0>
			<tr align=center height=25 class=a1>
				<td>对象</td>
				<td>事件内容</td>
				<td>操作时间/IP</td>
				<td>操作人</td>
				<td>操作</td>
			</tr>
			<form action="?action=DelLog&l_type=<%=l_type%>" method="post" name="form1">
<%
		sql="select * from EX_log "&sqlstr&" order by l_addtime desc"
		Dim currentpage,page_count,Pcount,totalrec
		currentPage=request("page")
		if currentpage="" or not isnumeric(currentpage) then
			currentpage=1
		end if
		set rs=server.createobject("adodb.recordset")
		rs.open sql,stock_conn,1,1
		if rs.eof and rs.bof then
			response.write "<tr><td class=a3 colspan=5>没有任何日志</td></tr></table>"
		else
			rs.PageSize=CInt(Exsm.Setting_Info(16))
			rs.AbsolutePage=currentpage
			page_count=0
			totalrec=rs.recordcount
			do while (not rs.eof) and (not page_count = rs.PageSize)%>
			<tr height="25">
				<td class=a3 align="center" width="80"><a target="_blank" title="对象：“<%=Rs("l_touser")%>”" href="Exsm_Plus_TopUser.asp?action=search&username=<%=Rs("l_touser")%>"><%=left(Rs("l_touser"),10)%>..</a></td>
				<td class=a3 align="left"><%=Rs("l_content")%></td>
				<td class=a3 align="center" width="210"><%=Rs("l_addtime")%>/<%=Rs("l_ip")%></td>
				<td class=a3 align="center" width="80"><a target="_blank" href="Exsm_Plus_TopUser.asp?action=search&username=<%=Rs("l_username")%>"><%=Rs("l_username")%></a></td>
				<td class=a3 align="center" width="28"><input type="checkbox" name="l_id" value="<%=Rs("l_id")%>"></td>
			</tr>
<%
		page_count = page_count + 1		
		rs.movenext
		loop
		Pcount=rs.PageCount
%>
			<tr>
				<td class=a4 align="right" colspan=5><input type=checkbox name=chkall value=on onclick="CheckAll(this.form)">&nbsp;全选/取消&nbsp;批量删除&nbsp;<input type=submit name=act value=删除  onclick="{if(confirm('您确定执行删除操作吗?')){this.document.form1.submit();return true;}return false;}">&nbsp;<input type=submit name=act value=清空日志 onclick="{if(confirm('确定清除当前所有的纪录吗?')){this.document.form1.submit();return true;}return false;}"></td>
			</tr>
		</table>
		<table cellpadding=0 cellspacing=1 border=0 width=<%=Exsm.AssignWidth%> align=center>
			<tr>
				<td valign=middle Align=Left>页次：<Font Color=red><%=currentpage%></Font> / <Font Color=blue><%=Pcount%></Font>&nbsp;页，每页&nbsp;<Font Color=blue><%=Rs.PageSize%></Font>&nbsp;个，共&nbsp;<Font Color=blue><%=totalrec%></Font>&nbsp;个日志
				<td valign=middle align=right>分页：<%call Exsm.DispPageNum(currentpage,Pcount,"""?page=","""")%></td>
			</tr>
			</form>
		</table>
<%
		end if
		rs.close
		set rs=nothing
		Exsm.RootShowA
	End Sub
	Sub DelLog()
		Dim delid
		If request("act")="删除" Then
			delid=replace(request.form("l_id"),"'","")
			If delid="" Then
				Exsm.Errmess="<li>请指定要删除的日志。"
				Call Exsm.Endinfo(1)
				Exit sub
			End if
			If delid<>"" then
				If IsSqlSmDataBase=1 Then
					stock_conn.execute("delete from EX_log where Datediff(D,l_addtime,"&SqlSmNowString&") > 2 and l_id in ("&delid&")")
				Else
					stock_conn.execute("delete from EX_log where Datediff('D',l_addtime,"&SqlSmNowString&") > 2 and l_id in ("&delid&")")
				End if
			End if
		End if
		If request("act")="清空日志" Then
			If request("l_type")="" or isnull(request("l_type")) Then
				If IsSqlSmDataBase=1 Then
					stock_conn.execute("delete from EX_log Where Datediff(D,l_addtime,"&SqlSmNowString&") > 2")
				Else
					stock_conn.execute("delete from EX_log Where Datediff('D',l_addtime,"&SqlSmNowString&") > 2")
				End if
			Else
				If IsSqlSmDataBase=1 Then
					stock_conn.execute("delete from EX_log where Datediff(D,l_addtime,"&SqlSmNowString&") > 2 and l_type="&Cint(request("l_type"))&"")
				Else
					stock_conn.execute("delete from EX_log where Datediff('D',l_addtime,"&SqlSmNowString&") > 2 and l_type="&Cint(request("l_type"))&"")
				End if
			End if
		End if
		Exsm.Sucmess="<li>日志被成功删除！注意：两天内的日志将被自动保留。"
		Call Exsm.Endinfo(1)
	End Sub
%>
	<script language="JavaScript">
	<!--
	function CheckAll(form)	{
		for (var i=0;i<form.elements.length;i++)	{
		var e = form.elements[i];
		if (e.name != 'chkall')	{
		e.checked = form.chkall.checked;
		}
		}
		}
	//-->
	</script>