<!--#include file="../../conn.asp"-->
<!--#include file="../inc/setup.asp"-->
<!--#include file="../inc/const.asp"-->
<!--#include file="../inc/check.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称：新云网站管理系统
' 当前版本：NewAsp Content Management System Version 4.0
' 文件名称：admin_log.asp
' 更新日期：2008-09-16
' 官方网站：新云网络(www.NewAsp.net www.NewAsp.cn) QQ：94022511
'=====================================================================
' Copyright 2003-2008 NewAsp.net - All Rights Reserved.
' newasp is a trademark of NewAsp.net
'=====================================================================
%>
<table class="table1" cellspacing="1" cellpadding="3" align="center" border="0">
	<tr>
		<td class="tableline linetitle" width="100" align="left">充值卡管理</td>
		<td class="tableline" width="*" align="right"><a href="admin_log.asp">查看全部日志</a>
			 - <a href="?showmode=1">查看事件一</a>
			 - <a href="?showmode=2">查看事件二</a>
			 - <a href="admin_setting.asp">基本设置</a>
			 - <a href="admin_config.asp">后台设置</a>
			 - <a href="../users/admin_master.asp">管理员列表</a>
			 - <a href="../users/admin_password.asp">修改管理密码</a>
		</td>
	</tr>
</table>
<%
Dim maxperpage,totalrec,Pcount,pagelinks,showmode,pagenow,count
Dim Action,listArry,SQLQuery

If Not ChkAdmin("9999") Then
	Call Transfer_error()
End If
Call ConnectionLogDatabase()
Action = LCase(Request("action"))
Select Case Trim(Action)
Case "del"
	Call delLog()
Case "delall"
	Call delAllLog()
Case "compress"
	Call DBCompress()
Case Else
	Call showmain()
End Select
If FoundErr=True Then
	ReturnError(ErrMsg)
End If
Admin_footer
NewAsp.PageEnd
If IsObject(lconn) Then
	lconn.Close
	Set lconn = Nothing
End If

Sub showmain()
	Dim i,iCount,lCount
	iCount=1:lCount=2
	maxperpage = 30 '###每页显示数
	count=NewAsp.ChkNumeric(Request("count"))
	pagenow=NewAsp.ChkNumeric(Request("page"))
	If pagenow=0 Then pagenow=1
%>
<form name="evenform" method="post" action="admin_log.asp">
<input type="hidden" name="action" value="del" />
<table border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr>
	<th width="5%" nowrap>选择</th>
	<th width="10%" nowrap>操 作 人</th>
	<th width="10%" nowrap>对 象</th>
	<th width="65%" nowrap>事件内容</th>
	<th width="10%" nowrap>日期时间/IP</th>
</tr>
<tr>
	<td class="tablerow1" colspan="5" align="left" id="showNextPage">&nbsp;</td>
</tr>
<%
	Call showLoglist()
	If IsArray(listArry) Then
		For i=0 To Ubound(listArry,2)
			If Not Response.IsClientConnected Then Response.End
			If (i mod 2) = 0 Then iCount=2:lCount=1 Else iCount=1:lCount=2
%>
<tr>
	<td class="tablerow<%=iCount%> hovered"><input type="checkbox" name="logid" value="<%=listArry(0,i)%>"></td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap"><%=Server.HTMLEncode(listArry(1,i)&"")%></td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap"><%=Server.HTMLEncode(listArry(2,i)&"")%></td>
	<td class="tablerow<%=iCount%> hovered"><%=Server.HTMLEncode(listArry(3,i)&"")%></td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap"><%=Server.HTMLEncode(listArry(4,i)&"")%><br/><%=Server.HTMLEncode(listArry(5,i)&"")%></td>
</tr>
<%
		Next
		listArry=Null
	End If
%>
<tr>
	<td class="tablerow<%=lCount%>" colspan="5">
	<input class="button" type="button" name="chkall" value="全选" onClick="CheckAll(this.form)"><input class="button" type="button" name="chksel" value="反选" onClick="ContraSel(this.form)">
	<input class="button" type="submit" name="submit_button1" value="删除管理日志" onclick="{if(confirm('您确定要删除所选择的日志吗?')){document.evenform.action.value='del';return true;}return false;}">
	<input class="button" type="submit" name="submit_button2" value="清空管理日志" onclick="{if(confirm('确定清除所有的日志纪录吗?')){document.evenform.action.value='delall';return true;}return false;}">
	<input class="button" type="submit" name="submit_button3" value="压缩日志数据库" onclick="{if(confirm('确定压缩日志数据库吗?')){document.evenform.action.value='compress';return true;}return false;}">
	</td>
</tr>
<tr>
	<td class="tablerow<%=iCount%>" colspan="5" id="NextPageText"><var class="morePage"><%=showlistpage(pagenow,Pcount,maxperpage,totalrec,pagelinks)%></var></td>
</tr>
</table>
</form>
<script type="text/javascript">
document.getElementById("showNextPage").innerHTML = document.getElementById("NextPageText").innerHTML;
</script>
<%
End Sub

Sub showLoglist()
	Dim Rs,SQL
	showmode=NewAsp.ChkNumeric(Request("showmode"))
	If showmode=1 Then
		SQLQuery="WHERE LogType=0"
	ElseIf showmode=2 Then
		SQLQuery="WHERE LogType=1"
	Else
		SQLQuery=""
	End If
	If count=0 Then
		totalrec=lConn.Execute("SELECT COUNT(*) FROM [NC_LogInfo] "&SQLQuery&"")(0)
	Else
		totalrec=count
	End If
	Pcount = CLng(totalrec / maxperpage)
	If Pcount < totalrec / maxperpage Then Pcount = Pcount + 1
	If pagenow>Pcount Then pagenow=1
	pagelinks="?showmode="&Request("showmode")&"&count="&totalrec&"&"
	Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
	SQL = "SELECT logid,username,ScriptName,ActContent,LogAddTime,UserIP FROM [NC_LogInfo] "&SQLQuery&" ORDER BY logid DESC"
	Rs.Open SQL,lConn,1,1
	If pagenow >1 Then
		Rs.Move (pagenow-1) * maxperpage
	End If
	If Not (Rs.BOF And Rs.EOF) Then
		listArry=Rs.GetRows(maxperpage)
	Else
		listArry=Null
	End If
	Rs.close()
	Set Rs=Nothing
End Sub

Sub delLog()
	Dim logIDlist
	logIDlist=NewAsp.CheckIDlist(Request("logid"))
	If logIDlist<>"0" And ""<>logIDlist Then
		lConn.Execute("DELETE FROM NC_LogInfo WHERE Datediff('d',LogAddTime, Now())>3 And logid in ("&logIDlist&")")
		Succeed ("<li>成功删除日志。</li><li>注意：三天内的日志会被系统保留。</li>")
	End If
End Sub

Sub delAllLog()
	lConn.Execute("DELETE FROM NC_LogInfo WHERE Datediff('d',LogAddTime, Now())>3")
	Succeed ("<li>成功清空所有管理日志。</li><li>注意：三天内的日志会被系统保留。</li>")
End Sub

Sub DBCompress()
	If CompressMDB("../script/Logdata.Asa") Then
		Succeed ("<li>后台管理日志数据库压缩成功。</li>")
	Else
		FoundErr=True
		ErrMsg="<li>后台管理日志数据库压缩失败！</li>"
	End If
End Sub

'================================================
' 函数名：CompressMDB
' 作  用：压缩ACCESS数据库
' 参  数：dbPath ----数据库路径
' 返回值：True  ----  False
'================================================
Function CompressMDB(DBPath)
	On Error Resume Next
	Dim fso, Engine, strDBPath, JET_3X
	CompressMDB = False
	If DBPath = "" Then Exit Function
	If InStr(DBPath, ":") = 0 Then DBPath = Server.MapPath(DBPath)
	strDBPath = Left(DBPath, InStrRev(DBPath, "\"))
	Set fso = NewAsp.CreateAXObject(NewAsp.MainSetting(47))
	If fso.FileExists(DBPath) Then
		fso.CopyFile DBPath, strDBPath & "temp.mdb"
		Set Engine = NewAsp.CreateAXObject("JRO.JetEngine")

		Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
		"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb"

		fso.CopyFile strDBPath & "temp1.mdb", DBPath
		fso.DeleteFile (strDBPath & "temp.mdb")
		fso.DeleteFile (strDBPath & "temp1.mdb")
		Set fso = Nothing
		Set Engine = Nothing
		CompressMDB = True
	Else
		CompressMDB = False
	End If
End Function
%>