<!--#include file="const.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称：新云网站管理系统
' 当前版本：NewAsp Content Management System Version 4.0
' 文件名称：admin_comment.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="80" align="left" noWrap="noWrap"><%=NewAsp.ModuleName%>评论管理</td>
		<td class="tableline" width="*" align="right"><a href="admin_index.asp?ChannelID=<%=ChannelID%>">管理首页</a>
			 - <a href="admin_comment.asp?ChannelID=<%=ChannelID%>">评论首页</a>
			 - <a href="admin_comment.asp?ChannelID=<%=ChannelID%>&audit=0">已审核评论</a>
			 - <a href="admin_comment.asp?ChannelID=<%=ChannelID%>&audit=1">未审核评论</a>
			 - <a href="admin_comment.asp?ChannelID=<%=ChannelID%>&apprize=1">通知管理员</a>
			 - <a href="admin_list.asp?ChannelID=<%=ChannelID%>"><%=NewAsp.ModuleName%>管理</a>
			 - <a href="../sys/admin_channel.asp?action=edit&ChannelID=<%=ChannelID%>">频道管理</a>
			 - <a href="admin_makehtml.asp?ChannelID=<%=ChannelID%>">生成HTLM</a>
		</td>
	</tr>
</table>
<%
Dim maxperpage,totalrec,Pcount,pagelinks,pagenow,count
Dim Action,TopicArry,SQLQuery,SQLField
If Not ChkAdmin("Comment_"&ChannelID) Then
	Call Transfer_error()
End If
Action=LCase(Request("action"))
Select Case Trim(Action)
Case "save"
	Call saveComment()
Case "edit"
	Call editComment()
Case "audit"
	Call auditComment
Case "noaudit"
	Call NoAuditComment
Case "del"
	Call delComment()
Case "delall"
	Call delAllComment()
Case Else
	Call showmain()
End Select
If FoundErr=True Then
	ReturnError(ErrMsg)
End If
Admin_footer
SaveLogInfo(AdminName)
NewAsp.PageEnd

Sub showmain()
	Dim i
	maxperpage=30
	pagenow=NewAsp.ChkNumeric(Request("page"))
	If pagenow=0 Then pagenow=1
	count=NewAsp.ChkNumeric(Request("count"))
%>
<form name="selform" id="selform" method="post" action="admin_comment.asp?ChannelID=<%=ChannelID%>">
<input type="hidden" name="action" value="del">
<table id="tablehovered" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr>
	<th width="5%" noWrap="noWrap">选择</th>
	<th width="50%">评论主题</th>
	<th width="5%" noWrap="noWrap">状态</th>
	<th width="11%" noWrap="noWrap">用户名称</th>
	<th width="5%" noWrap="noWrap">得分</th>
	<th width="12%" noWrap="noWrap">评论时间</th>
	<th width="12%" noWrap="noWrap">评论IP</th>
</tr>
<tr>
	<td class="tablerow2" colspan="7" align="left" id="showNextPage">&nbsp;</td>
</tr>
<%
	Call showTopiclist()
	If IsArray(TopicArry) Then
		For i=0 To Ubound(TopicArry,2)
			If Not Response.IsClientConnected Then Response.End
%>
<tr align="center">
	<td class="tablerow1 hovered"><input type="checkbox" name="commentid" value="<%=TopicArry(0,i)%>"/></td>
	<td class="tablerow1 hovered" align="left" title="点击查看此评论"><%
	If CLng(TopicArry(7,i))=1 Then Response.Write "<img src=""../images/announce.gif"" border=""0"" alt=""通知管理员"" align=""absMiddle"" />"
	%>
		<a href="?ChannelID=<%=ChannelID%>&flashid=<%=TopicArry(9,i)%>"><%=Server.HTMLEncode(TopicArry(10,i))%></a>
	</td>
	<td class="tablerow1 hovered" title="点击此处编辑评论"><a href="?action=edit&ChannelID=<%=ChannelID%>&commentid=<%=TopicArry(0,i)%>"><%
	If CLng(TopicArry(8,i)) = 0 Then
		Response.Write "<b style=""color:blue;"" title=""已审核"">√</b>"
	Else
		Response.Write "<b style=""color:red;"" title=""未审核"">×</b>"
	End If
	%></a></td>
	<td class="tablerow1 hovered" noWrap="noWrap" title="点击查看该用户的所有评论"><a href="?ChannelID=<%=ChannelID%>&username=<%=Server.HTMLEncode(TopicArry(4,i))%>"><%=Server.HTMLEncode(TopicArry(4,i))%></a></td>
	<td class="tablerow1 hovered" noWrap="noWrap" title="点击查看该<%=NewAsp.ModuleName%>的所有评论"><a href="<%=NewAsp.ChannelUrl%>comment.asp?id=<%=TopicArry(1,i)%>" target="_blank"><%=TopicArry(3,i)%></a></td>
	<td class="tablerow1 hovered" noWrap="noWrap"><%=showDateTime(TopicArry(5,i),"yyyy-MM-dd")%></td>
	<td class="tablerow1 hovered" noWrap="noWrap"><%=TopicArry(6,i)%></td>
</tr>
<tr>
	<td class="tablerow2" colspan="7"><%=NewAsp.HTMLEncodes(Left(TopicArry(2,i),100))%></td>
</tr>
<%
		Next
		TopicArry=Null
	End If
%>
<tr>
	<td class="tablerow1" colspan="7"><input class="button" type="button" name="chkall" value="全选" onClick="CheckAll(this.form)"><input class="button" type="button" name="chksel" value="反选" onClick="ContraSel(this.form)">
	<%If Trim(Request("audit")) = "0" Then%>
		<input class="button" type="submit" name="submit_button1" value="取消审核" onclick="{if(confirm('您确定要批量取消审核评论吗?')){document.selform.action.value='noaudit';return true;}return false;}">
	<%Else%>
		<input class="button" type="submit" name="submit_button1" value="批量审核" onclick="{if(confirm('您确定要批量审核评论吗?')){document.selform.action.value='audit';return true;}return false;}">
	<%End If%>
		<input class="button" type="submit" name="submit_button2" value="删除评论" onclick="{if(confirm('您确定要删除此评论吗?')){document.selform.action.value='del';return true;}return false;}">
		<input class="button" type="submit" name="submit_button3" value="全部删除" onclick="{if(confirm('您确定要删除所有评论吗?')){document.selform.action.value='delall';return true;}return false;}">
	</td>
</tr>
<tr>
	<td class="tablerow2" align="right" colspan="7" 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 showTopiclist()
	Dim Rs,SQL
	If Trim(Request("audit")) <> "" Then
		SQLQuery=" And A.Audit=" & NewAsp.ChkNumeric(Request("audit"))
	Else
		SQLQuery=""
	End If
	If NewAsp.ChkNumeric(Request("flashid")) > 0 Then
		SQLQuery=SQLQuery&" And A.postid=" & NewAsp.ChkNumeric(Request("flashid"))
	End If
	If NewAsp.ChkNumeric(Request("apprize")) > 0 Then
		SQLQuery=" And A.apprize=" & NewAsp.ChkNumeric(Request("apprize"))
	End If
	If Trim(Request("username")) <> "" Then
		SQLQuery=" And A.username='" & NewAsp.Checkstr(Request("username")) &"'"
	End If
	SQLField="A.commentid,A.postid,A.[content],A.Grade,A.username,A.postime,A.postip,A.apprize,A.Audit,B.flashid,B.title"
	
	If count=0 Then
		totalrec=NewAsp.Execute("SELECT COUNT(*) FROM NC_Comment A WHERE A.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
	Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
	SQL="SELECT "& SQLField &" FROM [NC_Comment] A INNER JOIN [NC_FlashList] B on A.postid=B.flashid WHERE A.ChannelID=" &ChannelID& " "&SQLQuery&" ORDER BY A.commentid 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
		TopicArry=Rs.GetRows(maxperpage)
	Else
		TopicArry=Null
	End If
	Rs.close()
	Set Rs=Nothing
	pagelinks="admin_comment.asp?channelid="& ChannelID &"&flashid="&Request("flashid")&"&apprize="&Request("apprize")&"&audit="&Request("audit")&"&username="&Request("username")&"&count="&totalrec&"&"
End Sub

Sub editComment()
	Dim Rs,SQL,commentid
	commentid = NewAsp.ChkNumeric(Request("commentid"))
	SQL = "SELECT commentid,postid,[content],Grade,username,postime,postip,apprize,Audit FROM NC_Comment WHERE ChannelID="& ChannelID &" And commentid=" & commentid
	Set Rs = NewAsp.Execute(SQL)
	If Rs.BOF And Rs.EOF Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>错误的系统参数!</li>"
		Exit Sub
	End If
%>
<table class="tableborder" cellspacing="1" cellpadding="3" align="center" border="0">
<tr>
	<th colspan="2">编辑/审核<%=NewAsp.ModuleName%>评论</th>
</tr>
<form action="?action=save" method="post" name="form2">
<input type="hidden" name="commentid" value="<%=Rs("commentid")%>" />
<input type="hidden" name="ChannelID" value="<%=ChannelID%>" />
<tr>
	<td class="tablerow2" width="20%">用户名称</td>
	<td class="tablerow2" width="80%"><input name="username" value="<%=Server.HTMLEncode(Rs("username"))%>" type="text" size="30" /></td>
</tr>
<tr>
	<td class="tablerow1">评论时间/IP地址</td>
	<td class="tablerow1"><font color="red"><%=Server.HTMLEncode(Rs("postime"))%></font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="blue"><%=Server.HTMLEncode(Rs("postip"))%></font></td>
</tr>
<tr>
	<td class="tablerow2">用户评分</td>
	<td class="tablerow2"><input name="Grade" value="<%=Rs("Grade")%>" type="text" size="5" maxlength="3" /></td>
</tr>
<tr>
	<td class="tablerow1">评论内容<br/>支持HTML代码</td>
	<td class="tablerow1"><textarea name="content1" rows="10" cols="80"><%=Server.HTMLEncode(Rs("content"))%></textarea></td>
</tr>
<tr>
	<td class="tablerow2">评论审核</td>
	<td class="tablerow2"><input type="radio" name="Audit" value="0"<%If Rs("Audit") = 0 Then Response.Write " checked=""checked"""%> /> 确定审核&nbsp;&nbsp; 
		<input type="radio" name="Audit" value="1"<%If Rs("Audit") = 1 Then Response.Write " checked=""checked"""%> /> 取消审核</td>
</tr>
<tr>
	<td class="tablerow1">&nbsp;</td>
	<td class="tablerow1"><input class="button" type="button" onclick="javascript:history.go(-1)" name="button2" value="返回上一页" /> 
	<input class="button" type="submit" name="submit_button" value="保存编辑" /></td>
</tr>
</form>
</table>
<%
	Set Rs = Nothing
End Sub

Sub saveComment()
	Dim Rs,SQL,commentid
	commentid = NewAsp.ChkNumeric(Request("commentid"))
	If Trim(Request.Form("username")) = "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>用户名不能为空！</li>"
	End If
	If Trim(Request.Form("content1")) = "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>评论内容不能为空！</li>"
	End If
	If Founderr = True Then Exit Sub
	Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
	SQL = "SELECT * FROM NC_Comment WHERE commentid= " & commentid
	Rs.Open SQL,Conn,1,3
	If Not (Rs.BOF And Rs.EOF) Then
		Rs("username").Value = Trim(Request.Form("username"))
		Rs("content").Value = Trim(Request.Form("content1"))
		Rs("Grade").Value = NewAsp.ChkNumeric(Request.Form("Grade"))
		Rs("Audit").Value = NewAsp.ChkNumeric(Request.Form("Audit"))
		Rs.update
		If CInt(NewAsp.IsCreateHtml) <> 0 Then
			Call makehtml(Rs("postid"))
		End If
	End If
	Rs.Close:Set Rs = Nothing
	Succeed("<li>恭喜您！编辑/审核评论成功。</li>")
End Sub

Sub delComment()
	Dim Rs,SQL
	Dim postid,strPostID,ArrayPostID,i
	If Trim(Request("commentid"))<>"" Then
		If CInt(NewAsp.IsCreateHtml) <> 0 Then
			Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
			SQL = "SELECT Distinct(postid) FROM NC_Comment WHERE ChannelID="& ChannelID &" And commentid in (" & Request("commentid") & ") ORDER BY postid"
			Rs.Open SQL,Conn,1,1
			strPostID = ""
			If Not (Rs.BOF And Rs.EOF) Then
				Do While Not Rs.EOF
					strPostID = strPostID & "," & Rs("postid")
					Rs.movenext
				Loop
			End If
			Rs.Close:Set Rs = Nothing
			NewAsp.Execute ("DELETE FROM NC_Comment WHERE ChannelID="& ChannelID &" And commentid in (" & Request("commentid") & ")")
			If strPostID <> "" Then
				ArrayPostID = Split(strPostID, ",")
				For i = 1 To UBound(ArrayPostID)
					postid = NewAsp.ChkNumeric(ArrayPostID(i))
					If postid > 0 Then
						Call makehtml(postid)
					End If
				Next
			End If
		Else
			NewAsp.Execute ("DELETE FROM NC_Comment WHERE ChannelID="& ChannelID &" And commentid in (" & Request("commentid") & ")")
		End If
		Succeed("<li>恭喜您！删除评论成功。</li>")
	Else
		ErrMsg = "<li>错误的系统参数,请选择要删除的评论ID</li>"
		FoundErr = True
		Exit Sub
	End If
End Sub

Sub delAllComment()
	NewAsp.Execute ("DELETE FROM NC_Comment WHERE ChannelID = "& ChannelID)
	Succeed("<li>恭喜您！删除所有评论成功。</li>")
End Sub

Sub makehtml(sid)
	Dim url
	url = "admin_makeshow.asp?ChannelID=" & ChannelID & "&inflashid=" & sid & "&t=2"
	Call ScriptCreation(url)
End Sub

Sub auditComment()
	Dim Rs,SQL
	Dim postid,strPostID,ArrayPostID,i
	If Trim(Request("commentid"))<>"" Then
		If CInt(NewAsp.IsCreateHtml) <> 0 Then
			Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
			SQL = "SELECT DISTINCT(postid) FROM NC_Comment WHERE ChannelID="& ChannelID &" And commentid in (" & Request("commentid") & ") ORDER BY postid"
			Rs.Open SQL,Conn,1,1
			strPostID = ""
			If Not (Rs.BOF And Rs.EOF) Then
				Do While Not Rs.EOF
					strPostID = strPostID & "," & Rs("postid")
					Rs.movenext
				Loop
			End If
			Rs.Close:Set Rs = Nothing
			NewAsp.Execute ("UPDATE NC_Comment SET Audit=0 WHERE ChannelID="& ChannelID &" And commentid in (" & Request("commentid") & ")")
			If strPostID <> "" Then
				ArrayPostID = Split(strPostID, ",")
				For i = 1 To UBound(ArrayPostID)
					postid = NewAsp.ChkNumeric(ArrayPostID(i))
					If postid > 0 Then
						Call makehtml(postid)
					End If
				Next
			End If
		Else
			NewAsp.Execute ("UPDATE NC_Comment SET Audit=0 WHERE ChannelID="& ChannelID &" And commentid in (" & Request("commentid") & ")")
		End If
		Succeed("<li>恭喜您！评论批量审核成功。</li>")
	Else
		ErrMsg = "<li>错误的系统参数,请选择要审核的评论ID</li>"
		FoundErr = True
		Exit Sub
	End If
End Sub

Sub NoAuditComment()
	Dim Rs,SQL
	Dim postid,strPostID,ArrayPostID,i
	If Trim(Request("commentid"))<>"" Then
		If CInt(NewAsp.IsCreateHtml) <> 0 Then
			Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
			SQL = "SELECT DISTINCT(postid) FROM NC_Comment WHERE ChannelID="& ChannelID &" And commentid in (" & Request("commentid") & ") ORDER BY postid"
			Rs.Open SQL,Conn,1,3
			If Not (Rs.BOF And Rs.EOF) Then
				Do While Not Rs.EOF
					strPostID = strPostID & "," & Rs("postid")
					Rs.movenext
				Loop
			End If
			Rs.Close:Set Rs = Nothing
			NewAsp.Execute ("UPDATE NC_Comment SET Audit=1 WHERE ChannelID="& ChannelID &" And commentid in (" & Request("commentid") & ")")
			If strPostID <> "" Then
				ArrayPostID = Split(strPostID, ",")
				For i = 1 To UBound(ArrayPostID)
					postid = NewAsp.ChkNumeric(ArrayPostID(i))
					If postid > 0 Then
						Call makehtml(postid)
					End If
				Next
			End If
		Else
			NewAsp.Execute ("UPDATE NC_Comment SET Audit=1 WHERE ChannelID="& ChannelID &" And commentid in (" & Request("commentid") & ")")
		End If
		Succeed("<li>恭喜您！评论批量取消审核成功。</li>")
	Else
		ErrMsg = "<li>错误的系统参数,请选择要取消审核的评论ID</li>"
		FoundErr = True
		Exit Sub
	End If
End Sub
%>