<!--#include file="setup.asp"-->
<!--#include file="check.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称：新云网站管理系统(华西网域风格）(华西网域风格）
' 当前版本：NewCloud Site Management System Version 2.1
' 文件名称：admin_comment.asp
' 更新日期：2005-4-15
' 官方网站：新云网络(www.newasp.net) QQ：94022511
'=====================================================================
' Copyright 2002-2005 newasp.net - All Rights Reserved.
' newasp is a trademark of newasp.net
'=====================================================================
Dim Action
If Not ChkAdmin("ErrorSoft" & ChannelID) Then
	Server.Transfer("showerr.asp")
	Response.End
End If

Action = LCase(Request("action"))
Select Case Trim(Action)
Case "del"
	Call DeleteComment
Case "delall"
	Call DelAllComment
Case Else
	Call showmain
End Select
If FoundErr = True Then
	ReturnError(ErrMsg)
End If
Admin_footer
SaveLogInfo(AdminName)
CloseConn
Sub showmain()
	Dim CurrentPage,page_count,totalnumber,Pcount,maxperpage
	Dim strTopic
	maxperpage = 20
	CurrentPage = Request("page")
	If CurrentPage = "" Or Not IsNumeric(CurrentPage) Then
		CurrentPage = 1
	Else
		CurrentPage = CLng(CurrentPage)
	End If
	If CLng(CurrentPage) = 0 Then CurrentPage = 1
	Response.Write "<table cellspacing=1 align=center cellpadding=3 border=0 class=tableborder>"
	Response.Write "	<tr>"
	Response.Write "		<th width='5%'>选择</th>"
	Response.Write "		<th width='50%'>评论主题</th>"
	Response.Write "		<th width='16%'>用户名称</th>"
	Response.Write "		<th width='5%'>打分</th>"
	Response.Write "		<th width='12%'>评论时间</th>"
	Response.Write "		<th width='12%'>用户IP</th>"
	Response.Write "	</tr>"
	Response.Write "	<form name=selform method=post action='admin_comment.asp'>"
	Response.Write "	<input type=hidden name=action value=""del"">"
	Response.Write "	<input type=hidden name=ChannelID value="""& ChannelID &""">"
	totalnumber = Newasp.Execute("SELECT COUNT(commentid) FROM NC_Comment WHERE ChannelID=" & ChannelID)(0)
	Pcount = CLng(totalnumber / maxperpage)  '得到总页数
	If Pcount < totalnumber / maxperpage Then Pcount = Pcount + 1
	If CurrentPage < 1 Then CurrentPage = 1
	If CurrentPage > Pcount Then CurrentPage = Pcount
	Select Case CInt(Newasp.modules)
	Case 1
		SQL = "SELECT C.commentid,C.postid,C.content,C.Grade,C.username,C.postime,C.postip,A.ArticleID,A.title FROM [NC_Comment] C INNER JOIN [NC_Article] A ON C.Postid=A.ArticleID WHERE C.ChannelID=" & ChannelID & " ORDER BY C.Postime DESC"
	Case 2
		SQL = "SELECT C.commentid,C.postid,C.content,C.Grade,C.username,C.postime,C.postip,A.softid,A.SoftName,A.SoftVer FROM [NC_Comment] C INNER JOIN [NC_SoftList] A ON C.Postid=A.softid WHERE C.ChannelID=" & ChannelID & " ORDER BY C.Postime DESC"
	Case 3
		SQL = "SELECT C.commentid,C.postid,C.content,C.Grade,C.username,C.postime,C.postip,A.shopid,A.TradeName FROM [NC_Comment] C INNER JOIN [NC_ShopList] A ON C.Postid=A.shopid WHERE C.ChannelID=" & ChannelID & " ORDER BY C.Postime DESC"
	Case 5
		SQL = "SELECT C.commentid,C.postid,C.content,C.Grade,C.username,C.postime,C.postip,A.flashid,A.title FROM [NC_Comment] C INNER JOIN [NC_FlashList] A ON C.Postid=A.flashid WHERE C.ChannelID=" & ChannelID & " ORDER BY C.Postime DESC"
	Case Else
		ErrMsg = "<li>错误的系统参数~!</li>"
		FoundErr = True
		Exit Sub
	End Select
	Set Rs = Server.CreateObject("ADODB.Recordset")
	If IsSqlDataBase=1 Then
		Set Rs = Newasp.Execute(SQL)
	Else
		Rs.Open SQL, Conn, 1, 1
	End If
	If Rs.BOF And Rs.EOF Then
		Response.Write "<tr><td align=center colspan=6 class=TableRow1>没有" & sModuleName & "评论！</td></tr>"
	Else
		Rs.MoveFirst
		If Pcount > 1 then Rs.Move (CurrentPage - 1) * maxperpage
		page_count = 0
		Do While Not Rs.EOF And page_count < CInt(maxperpage)
			If Not Response.IsClientConnected Then ResponseEnd
			Select Case CInt(Newasp.modules)
			Case 1
				strTopic = "<a href=""../" & Newasp.ChannelDir & "Comment.Asp?ArticleID="& Rs(7) &""" title='点击查看此" & sModuleName & "评论' target=_blank>"& Rs(8) &"</a>"
			Case 2
				strTopic = "<a href=""../" & Newasp.ChannelDir & "Comment.Asp?softid="& Rs(7) &""" title='点击查看此" & sModuleName & "评论' target=_blank>"& Rs(8) &" "& Rs(9) &"</a>"
			Case 3
				strTopic = "<a href=""../" & Newasp.ChannelDir & "Comment.Asp?shopid="& Rs(7) &""" title='点击查看此" & sModuleName & "评论' target=_blank>"& Rs(8) &"</a>"
			Case 5
				strTopic = "<a href=""../" & Newasp.ChannelDir & "Comment.Asp?flashid="& Rs(7) &""" title='点击查看此" & sModuleName & "评论' target=_blank>"& Rs(8) &"</a>"
			End Select
			
			Admin_Comment_list Rs(0),strTopic,Rs(1),Rs(2),Rs(3),Rs(4),Rs(5),Rs(6)
			Rs.movenext
			page_count = page_count + 1
			If page_count >= maxperpage Then Exit Do
		Loop
	End If
	Rs.Close:Set Rs = Nothing
	Response.Write "	<tr>"
	Response.Write "		<td class=tablerow1 colspan=6>"
	Response.Write "<input class=Button type=""button"" name=""chkall"" value=""全选"" onClick=""CheckAll(this.form)""><input class=Button type=""button"" name=""chksel"" value=""反选"" onClick=""ContraSel(this.form)"">"
	Response.Write "<input type=submit name=submit2 value=""删除评论"" onclick=""return confirm('您确定要删除此评论吗?')"" class=Button>"
	Response.Write "<input type=submit name=submit3 value="" 全部删除 "" onclick=""document.selform.action.value='delall';return confirm('您确定要删除所以评论吗?')"" class=Button>"
	Response.Write "</td>"
	Response.Write "	</tr>"
	Response.Write "	</form>"
	Response.Write "	<tr align=center>"
	Response.Write "		<td class=tablerow2 colspan=6>"
	Response.Write showpages(CurrentPage,Pcount,totalnumber,maxperpage,"&ChannelID="& ChannelID)
	Response.Write "</td>"
	Response.Write "	</tr>"
	Response.Write "</table>"
End Sub
Function Admin_Comment_list(commentid,topic,postid,content,Grade,username,postime,postip)
	Response.Write "	<tr>"
	Response.Write "		<td class=TableRow2 align=center><input type=checkbox name=commentid value="""& commentid &"""></td>"
	Response.Write "		<td class=TableRow2>" & topic & "</td>"
	Response.Write "		<td class=TableRow2 align=center><font color=blue>" & username & "</font></td>"
	Response.Write "		<td class=TableRow2 align=center><font color=red>" & Grade & "</font></td>"
	Response.Write "		<td class=TableRow2 align=center>" & Newasp.FormatDate(postime,2) & "</td>"
	Response.Write "		<td class=TableRow2 align=center>" & postip & "</td>"
	Response.Write "	</tr>"
	Response.Write "	<tr>"
	Response.Write "		<td class=TableRow1 colspan=6>"& Newasp.CutString(content,100) &"</td>"
	Response.Write "	</tr>"
End Function

Sub DeleteComment()
	If Trim(Request("commentid")) <> "" Then
		Newasp.Execute ("DELETE FROM NC_Comment WHERE ChannelID = "& ChannelID &" And CommentID in (" & Request("CommentID") & ")")
		Response.Redirect  Request.ServerVariables("HTTP_REFERER")
	Else
		ErrMsg = "<li>错误的系统参数,请选择要删除的评论ID</li>"
		FoundErr = True
		Exit Sub
	End If
End Sub
Sub DelAllComment()
	Newasp.Execute ("DELETE FROM NC_Comment WHERE ChannelID = "& ChannelID)
	Response.Redirect  Request.ServerVariables("HTTP_REFERER")
End Sub
%>