<!--#include file="const.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称：新云网站管理系统
' 当前版本：NewAsp Content Management System Version 4.0
' 文件名称：admin_downlog.asp
' 更新日期：2008-06-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="200" align="left">用户下载日志管理</td>
		<td class="tableline" width="*" align="right"><a href="admin_index.asp">管理首页</a>
			 - <a href="admin_downlog.asp?ChannelID=<%=ChannelID%>">下载日志</a>
			 - <a href="admin_makehtml.asp?ChannelID=<%=ChannelID%>">生成HTML管理</a>
			 - <a href="admin_list.asp?ChannelID=<%=ChannelID%>"><%=NewAsp.ModuleName%>管理</a>
			 - <a href="../sys/admin_channel.asp?action=edit&ChannelID=<%=ChannelID%>">频道设置</a>
			 - <a href="../sys/admin_class.asp?ChannelID=<%=ChannelID%>">分类管理</a>
			 - <a href="../sys/admin_template.asp">模板管理</a>
		</td>
	</tr>
</table>
<form action="admin_downlog.asp?ChannelID=<%=ChannelID%>" method="post" name="searchform">
<table class="tableborder" cellspacing="1" cellpadding="3" align="center" border="0">
	<tr>
		<th>软件管理选项</th>
	</tr>
	<tr>
		<td class="tablerow2">搜索： <input name="word" type="text" size="45" value="<%=Request("word")%>" /> 
			条件： <select size="1" name="searchfield">
				<option value="0">不限条件</option>
				<option value="1">软件名称</option>
				<option value="2" selected="selected">用户名称</option>
			</select> 
			<input class="button" type="submit" name="search_button" value="开始搜索" />
		</td>
	</tr>
	<tr>
		<td class="tablerow1"><strong>操作选项：</strong> <a href="admin_downlog.asp?ChannelID=<%=ChannelID%>">管理首页</a> | 
		<a href="?ChannelID=<%=ChannelID%>&showmode=1">用户已删除软件</a> | 
		<a href="?action=delall&ChannelID=<%=ChannelID%>" onClick="return confirm('此操作将删除所有的用户下载记录，确定要删除吗？')"><font color="red">删除所有下载记录</font></a></td>
	</tr>
</table>
</form>
<%
If Not ChkAdmin("List_"&ChannelID) Then
	Call Transfer_error()
End If

Dim maxperpage,totalrec,Pcount,pagelinks,showmode,pagenow,count
Dim Action,Topiclist,SQLQuery
Action=LCase(Request("action"))
Select Case Trim(Action)
Case "del"
	Call Deldownlog()
Case "delall"
	Call Delalldownlog()
Case Else
	Call showmain()
End Select
If FoundErr=True Then
	ReturnError(ErrMsg)
End If
Admin_footer
NewAsp.PageEnd

Sub showmain()
	Dim i,iCount,lCount,m_strstate,isdown
	iCount=1:lCount=2
	maxperpage = 30 '###每页显示数
	count=NewAsp.ChkNumeric(Request("count"))
	pagenow=NewAsp.ChkNumeric(Request("page"))
	If pagenow=0 Then pagenow=1
%>
<table border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr>
	<th nowrap="nowrap" width="5%">选择</th>
	<th width="55%">软件名称</th>
	<th nowrap="nowrap" width="15%">最后下载时间</th>
	<th nowrap="nowrap" width="12%">用户名称</th>
	<th nowrap="nowrap" width="8%">下载次数</th>
	<th nowrap="nowrap" width="5%">状态</th>
</tr>
<tr>
	<td class="tablerow1" colspan="6" align="left" id="showNextPage">&nbsp;</td>
</tr>
<form name="selform" method="post" action="?action=del&ChannelID=<%=ChannelID%>">
<%
	Call showDownlist()
	If IsArray(Topiclist) Then
		For i=0 To Ubound(Topiclist,2)
			If Not Response.IsClientConnected Then Response.End
			If (i mod 2) = 0 Then iCount=2:lCount=1 Else iCount=1:lCount=2
			isdown = Newasp.ChkNumeric(Topiclist(8,i) + Topiclist(9,i))
			If isdown > 0 Then
				m_strstate = "<b style=""color:blue;"" title=""已下载"">√</b>"
			Else
				m_strstate = "<b style=""color:red;"" title=""未下载"">×</b>"
			End If
%>
<tr align="center">
	<td class="tablerow<%=iCount%> hovered"><input type="checkbox" name="sid" value="<%=Topiclist(0,i)%>"></td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap" align="left"><a href="<%=NewAsp.ChannelUrl%>softdown.asp?softid=<%=Topiclist(4,i)%>" target="_blank"><%=Server.HTMLEncode(Topiclist(5,i))%></a></td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap"><%=showDateTime(Topiclist(7,i),"yyyy-MM-dd")%></td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap"><a href="../users/admin_user.asp?action=edit&userid=<%=Topiclist(2,i)%>"><%=Topiclist(3,i)%></a></td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap"><%=Topiclist(6,i)%></td>
	<td class="tablerow<%=iCount%> hovered" nowrap="nowrap"><%=m_strstate%></td>
</tr>
<%
		Next
		Topiclist=Null
	End If
%>
<tr>
	<td class="tablerow<%=lCount%>" colspan="6">
	<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_button" value="删除下载日志" onclick="return confirm('您确定要删除选择的下载日志吗?');">
	</td>
</tr>
</form>
<tr>
	<td class="tablerow<%=iCount%>" colspan="6" id="NextPageText"><var class="morePage"><%=showlistpage(pagenow,Pcount,maxperpage,totalrec,pagelinks)%></var></td>
</tr>
</table>
<script type="text/javascript">
document.getElementById("showNextPage").innerHTML = document.getElementById("NextPageText").innerHTML;
</script>
<%
End Sub

Sub showDownlist()
	Dim Rs,SQL,keyword
	On Error Resume Next
	showmode=NewAsp.ChkNumeric(Request("showmode"))
	keyword=Trim(NewAsp.CheckStr(Request("word")))
	If Len(keyword)>1 Then
		Select Case NewAsp.ChkNumeric(Request("searchfield"))
			Case 1
				SQLQuery="And title like '%" & keyword & "%'"
			Case 2
				SQLQuery="And UserName='" & keyword & "'"
		Case Else
				If IsSqlDataBase=1 Then
					SQLQuery="And (title+UserName like '%"& keyword &"%')"
				Else
					SQLQuery="And (InStr(1,LCase(title+UserName),LCase('"&keyword&"'),0)>0)"
				End If
		End Select
	Else
		If showmode=1 Then
			SQLQuery= "And isdel=1"
		Else
			SQLQuery= "And isdel=0"
		End If
	End If
	If count=0 Then
		totalrec=NewAsp.Execute("SELECT COUNT(*) FROM [NC_UserDown] WHERE ChannelID="&ChannelID&" "&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="?ChannelID="&ChannelID&"&showmode="&Request("showmode")&"&searchfield="&Request("searchfield")&"&word="&Request("word")&"&count="&totalrec&"&"
	Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
	SQL = "SELECT id,ChannelID,userid,UserName,softid,title,downhits,lasttime,isdown1,isdown2,isdel FROM [NC_UserDown] WHERE ChannelID="&ChannelID&" "&SQLQuery&" ORDER BY lasttime DESC, id DESC"
	Rs.Open SQL,Conn,1,1
	If pagenow >1 Then
		Rs.Move (pagenow-1) * maxperpage
	End If
	If Not (Rs.BOF And Rs.EOF) Then
		Topiclist=Rs.GetRows(maxperpage)
	Else
		Topiclist=Null
	End If
	Rs.close()
	Set Rs=Nothing
End Sub

Sub Deldownlog()
	Dim softidlist
	softidlist=NewAsp.CheckIDlist(Request("sid"))
	If softidlist<>"0" And ""<>softidlist Then
		NewAsp.Execute ("DELETE FROM [NC_UserDown] WHERE ChannelID="& ChannelID &" And id in (" &softidlist& ")")
	End If
	Response.Redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

Sub Delalldownlog()
%>
<form action="" method="post" name="form2">
<table class="tableborder" cellspacing="1" cellpadding="3" align="center" border="0">
	<tr>
		<th>删除所有下载记录</th>
	</tr>
	<tr>
		<td class="tablerow2"><b>说明：</b><br/><font color="blue">①、此操作将删除所有会员下载记录不能恢复，删除后可以节省数据库空间，不过会员将看不到他的下载记录。<br/>
		②、如果您确定要删除，请点击确定删除所有下载记录</font></td>
	</tr>
	<input type="hidden" name="ChannelID" value="<%=ChannelID%>" />
	<input type="hidden" name="action" value="delall" />
	<input type="hidden" name="del" value="yes" />
	<tr>
		<td class="tablerow1" align="center"><input class="button" type="submit" onclick="return confirm('删除后不能恢复，您确定执行该操作吗?');" name="submit_button" value="确定删除所有下载记录" /></td>
	</tr>
</table>
</form>
<%
	If Request("del") = "yes" Then
		NewAsp.Execute ("DELETE FROM [NC_UserDown] WHERE ChannelID="& ChannelID)
		Response.Redirect ("admin_downlog.asp?ChannelID="& ChannelID)
	End If
End Sub

%>