<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/ex_stock/ex_sm_conn.asp"-->
<!--#include file="inc/ex_stock/ex_sm_const.asp"-->
<!--#include file="inc/ex_stock/ex_admin/ex_admin_index.asp"-->
<%
	if not exsm.stockadmin then
		exsm.errmess="您没有管理权限！请返回。"
		call exsm.endinfo("no")
	else
		dim sqlstr,l_type
		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
	sub main()
		dim logname,sqlstrname
		sqlstrname=""
		if request("search")="search" then
			logname=trim(replace(request("logname"),"'",""))
			if logname="" then
				exsm.errmess="请输入查询关键字。"
				call exsm.endinfo("no")
				exit sub
			end if
			if sqlstr<>"" then
				sqlstrname=" and l_content like '%"&logname&"%'"
			else
				sqlstrname="where l_content like '%"&logname&"%'"
			end if
		end if
		adminmenutop "日志管理"
		session("ex_sm")=0
%>
		<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0" style="width:100%">
			<tr align="center" height="25">
				<th><a href="?">全部日志</a></th>
				<th><a href="?action=stlog">股票操作</a></th>
				<th><a href="?action=uslog">用户操作</a></th>
				<th><a href="?action=prlog">资金流向</a></th>
				<th><a href="?action=anlog">公新操作</a></th>
				<th><a href="?action=ellog">其它操作</a></th>
				<th><a href="?action=dalog">数据库操作</a></th>
			</tr>
			<tr>
				<form name="form" method="post" action="?action=<%=request("action")%>&search=search">
				<td class="tablebody1" colspan="7">日志查询：<input type="text" name="logname" size="20">&nbsp;<input type="submit" name="submit" value="查询"></td>
				</form>
			</tr>
		</table>
		<br>
		<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0" style="width:100%">
			<tr height="25">
				<th>对象</th>
				<th>事件内容</th>
				<th>操作时间/ip</th>
				<th>操作人</th>
				<th>操作</th>
			</tr>
			<form action="?action=dellog&l_type=<%=l_type%>" method="post" name="form1">
<%
		sql="select * from ex_log "&sqlstr&sqlstrname&" 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=""tablebody1"" 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 align="center" height="25">
				<td class="tablebody1" width="80"><a target="_blank" title="对象：“<%=rs("l_touser")%>”" href="ex_sm_topuser.asp?action=search&username=<%=rs("l_touser")%>"><%=left(rs("l_touser"),10)%>..</a></td>
				<td class="tablebody1" align="left"><%=rs("l_content")%></td>
				<td class="tablebody1" width="210"><%=rs("l_addtime")%>/<%=rs("l_ip")%></td>
				<td class="tablebody1" width="80"><a target="_blank" href="ex_sm_topuser.asp?action=search&username=<%=rs("l_username")%>"><%=rs("l_username")%></a></td>
				<td class="tablebody1" width="30"><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="tablebody2" 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>
			</form>
		</table>
		<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>
<%
			call exsm.disppagenum(totalrec,page_count,currentpage,pcount,"?action="&request("action")&"&search="&request("search")&"&logname="&logname&"&page=","?action="&request("action")&"&search="&request("search")&"&logname="&logname&"")
		end if
		rs.close
		set rs=nothing
		adminmenubottom
		exsm.rootshowa
	end sub
	sub dellog()
		dim delid
		if exsm.outsiderefer() then
			exsm.errmess="请不要从外部提交数据。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if exsm.repeatrefer() then
			exsm.errmess="您提交的数据已经保存，请不要重复提交。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if request("act")="删除" then
			delid=replace(request.form("l_id"),"'","")
			if delid="" then
				exsm.errmess="请指定要删除的日志。"
				call exsm.endinfo("no")
				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
				session("ex_sm")=1
			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
			session("ex_sm")=1
		end if
		exsm.sucmess="日志被成功删除！注意：两天内的日志将被自动保留。"
		call exsm.endinfo("ok")
	end sub
%>