<!--#include file="User_Const.asp"-->
<%
Const MaxPerPage=20
dim Action
dim SearchContent,InfoID
if ChannelID=0 then User_ShowErr("<br><li>请指定频道ID！</li>")
Cl.GetChannelSetting(ChannelID)
Action			= Trim(request("Action"))
SearchContent	= Trim(request("SearchContent"))
InfoID			= Cl.ChkClng(request("InfoID"))
CurrentPage		= Cl.ChkClng(request("page"))
strFileName		= "User_Comment.asp?ChannelID="&ChannelID&""
%>
<html>
<head>
<title>评论管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../Skins/User_Style.Css">
<script language=javascript>
function unselectall()
{
    if(document.del.chkAll.checked){
	document.del.chkAll.checked = document.del.chkAll.checked&0;
    } 	
}

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;
    }
  }
function ConfirmDel()
{
   if(confirm("确定要删除选中的评论吗？一旦删除将不能恢复！"))
     return true;
   else
     return false;
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">
  <tr class="title"> 
    <td height="22" colspan=3 align=center><b><%=Cl.Channel_Setting(2)%>评论管理</b></td>
  </tr>
  <tr class="tdbg"> 
    <td width="70" height="30"><strong>管理导航：</strong></td>
    <td width="180" height="30">&nbsp;<a href="<%=strFileName%>">所有评论</a>&nbsp;<a href="<%=strFileName%>&Action=Pass">已审评论</a>&nbsp;<a href="<%=strFileName%>&Action=NoPass">待审评论</a>&nbsp;</td>
    <td height="30">
      <table width="100%"><tr>
	  <form name="searchArticle" method="get" action="User_Comment.asp">
            <td> 
			<input name="ChannelID" type="hidden" id="ChannelID" value="<%=ChannelID%>">
              <input name="SearchContent" type="text" class=smallInput id="SearchContent" size="28">
				<input name="Query" type="submit" id="Query" value="查 询">
              &nbsp;&nbsp;请输入查询的内容。如果为空，则查找所有评论。</td>
          </form></tr></table>
	</td>
  </tr>
</table>
<%
If Action="Show" then
	U_ShowComment
else
	U_main
end if
if FoundErr=True then
	User_ShowErr(ErrMsg)
end if

sub U_main()
	Dim strSql,strSql2
	strSql="M.CommentID,M.InfoID,M.UserLevel,M.UserName,M.Email,M.IP,M.WriteTime,M.Score,M.Content,M.ReplyName,M.ReplyContent,M.ReplyTime,M.Passed from Cl_Comment M Left join"
	strSql2=" where M.ChannelID="&ChannelID&" and M.UserName='"&Cl.User_Info(5)&"' and M.UserLevel=1"
	if SearchContent<>"" then
		strSql2=strSql2 & " and M.Content like '%" & SearchContent & "%' "
		strFileName=strFileName & "&SearchContent=" & SearchContent
	end if
	if InfoID>0 then
		strSql2=strSql2 & " and M.InfoID="&InfoID&" "
		strFileName=strFileName & "&InfoID=" & InfoID
	end if
	if Action="NoPass" then
		strSql2=strSql2 & " and M.Passed=False "
		strFileName=strFileName & "&Action=NoPass"
	Elseif Action="Pass" then
		strSql2=strSql2 & " and M.Passed=True "
		strFileName=strFileName & "&Action=Pass"
	end if
	Select Case Clng(Cl.Channel_Setting(20))
	Case 1
	sql="select I.ArticleID,I.ClassID,I.Title,I.IsHTML,I.HtmlFileUrl,"&strSql&" Cl_Article I On M.InfoID=I.ArticleID "&strSql2&" order by M.WriteTime desc,I.ArticleID desc"
	Case 2
	sql="select I.SoftID,I.ClassID,I.SoftName,I.IsHTML,I.HtmlFileUrl,"&strSql&" Cl_Soft I On M.InfoID=I.SoftID "&strSql2&" order by M.WriteTime desc,I.SoftID desc"
	Case 3
	sql="select I.PhotoID,I.ClassID,I.PhotoName,I.IsHTML,I.HtmlFileUrl,"&strSql&" Cl_Photo I On M.InfoID=I.PhotoID "&strSql2&" order by M.WriteTime desc,I.PhotoID desc"
	Case 4
	sql="select I.MovieID,I.ClassID,I.MovieName,I.IsHTML,I.HtmlFileUrl,"&strSql&" Cl_Movie I On M.InfoID=I.MovieID "&strSql2&" order by M.WriteTime desc,I.MovieID desc"
	Case 5
	sql="select I.ProductID,I.ClassID,I.ProductName,I.IsHTML,I.HtmlFileUrl,"&strSql&" Cl_Product I On M.InfoID=I.ProductID "&strSql2&" order by M.WriteTime desc,I.ProductID desc"
	Case 6
	sql="select I.TopicID,I.ClassID,I.Title,I.IsHTML,I.HtmlFileUrl,"&strSql&" Cl_Topic I On M.InfoID=I.TopicID "&strSql2&" order by M.WriteTime desc,I.TopicID desc"
	Case Else
		User_ShowErr("<br><li>请指定频道ID！</li>")
	end Select
	Set rs= Server.CreateObject("ADODB.Recordset")
	OpenConn : rs.open sql,Conn,1,1
%>
<br>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>您的位置：<a href="User_Comment.asp?ChannelID=<%=ChannelID%>"><%=Cl.Channel_Setting(2)%>评论管理</a>&nbsp;&gt;&gt;&nbsp;
	<%
	if request.querystring="" then
		response.write "所有评论"
	else
		if SearchContent<>"" then
			response.write "评论内容中含有“<font color=blue>" & SearchContent & "</font>”的评论"
		else
			response.Write("所有评论")
		end if
	end if
	%>
	</td>
	<td width="150" align="right">
	<%
  	if rs.eof and rs.bof then
		response.write "共找到 0 篇评论"
	else
    	TotalPut=rs.recordcount
		response.Write "共找到 <font color=red>" & TotalPut & "</font> 篇评论"
	end if
%>
	</td>
  </tr>
</table>
<%  
  	if Not (rs.eof and rs.bof) then
   		if (TotalPut mod MaxPerPage)=0 then
     		TotalPages = TotalPut \ MaxPerPage
		else
	   		TotalPages = TotalPut \ MaxPerPage + 1
		end if
		if CurrentPage > TotalPages then CurrentPage=TotalPages
		if CurrentPage < 1 then CurrentPage=1
   		rs.move (CurrentPage-1)*MaxPerPage
        ShowComment()
        Response.write Cl.ShowPage(strFileName,TotalPut,MaxPerPage,"篇","评论")
	end if
   	rs.close:set rs=Nothing  
end sub

Sub ShowComment()
	%>
	<form name="del" method="Post" action="User_Comment.asp?ChannelID=<%=ChannelID%>" onsubmit="return ConfirmDel();">
	<%
   	dim rsCommentU,UserIM
    i=0
	dim PrevID
	PrevID=rs(0)
	do while not rs.eof
		if rs(0)<>PrevID then response.write "</table></td></tr></table><br>"
		if i=0 or rs(0)<>PrevID then	%>
        <table class="border" width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
          <tr class="title">
            <td height="22" width="75%" align="left">△ <a href="User_Comment.asp?ChannelID=<%=ChannelID%>&InfoID=<%=rs(0)%>"><font color="#ffffff"><%=rs(2)%></font></a></td>
            <td width="25%" align="right"></td>
          </tr>
          <tr> 
            <td colspan="2"> 
      <table border="0" cellspacing="1" width="100%" cellpadding="0" style="word-break:break-all">
        <%end if%>
        <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'"> 
          <td width="30" align="center">
            <input name="CommentID" type="checkbox" onclick="unselectall()" id="CommentID" value="<%=cstr(rs("CommentID"))%>">
          </td>
          <td><a href="User_Comment.asp?ChannelID=<%=ChannelID%>&Action=Show&CommentID=<%=rs("Commentid")%>" Title="<%=left(rs("Content"),200)%>"><%=Cl.GotTopic(rs("Content"),25)%></a></td>
          <td width="70" align="center">评分：<%=rs("Score")%></td>
          <td width="50" align="center"><%=Cl.GetUserGroupName(rs("UserLevel"))%> </td>
          <td width="100" align="center"> 
            <%
			if rs("UserLevel")=5 then
				response.write "<span title='姓名：" & rs("UserName") & vbcrlf & "信箱：" & rs("Email") & vbcrlf & " I P：" & rs("IP") & "' style='cursor:hand'>" & rs("UserName") & "</span>"
			else
				response.write "<a href='Info.Asp?UserName=" & rs("UserName") & "' target='_blank'>" & rs("UserName") & "</a>"
			end if
		  %>
          </td>
          <td width="120" align="center"><%= rs("WriteTime") %></td>
          <td width="120" align="center">
		  <%
		  if rs("Passed")=True then
		      response.write "已审核"
		  else
			  response.write "<font color='#ff0033'>未审核</font>"
		  end if
		  %>
		  </td>
        </tr>
        <%if rs("ReplyName")<>"" then%>
        <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'"> 
          <td align="center">&nbsp;</td>
          <td colspan="5">
            <%response.write "管理员【" & rs("ReplyName") & "】于 " & rs("ReplyTime") & " 回复：<br><div style='padding:0px 20px'>" & rs("ReplyContent") & "</div>"%>
          </td>
          <td align="center"></td>
        </tr>
        <%
		end if
		i=i+1
	    if i>=MaxPerPage then exit do
	    PrevID=rs(0)
		rs.movenext
	loop
%>
      </table>
    </td>
          </tr>
        </table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="250" height="30"><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
              选中本页显示的所有评论 </td>
    <td><input name="submit" type='submit' value='删除选定的评论'>
              <input name="Action" type="hidden" id="Action" value="Del"></td>
  </tr>
</table>
</form>
<%
end sub

sub U_ShowComment()
	dim CommentID
	CommentID=Trim(Request("CommentID"))
	if CommentID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定评论ID</li>"
		Exit sub
	else
		CommentID=Clng(CommentID)
	end if
	sql="Select * from Cl_Comment where CommentID=" & CommentID
	Set rs=Server.CreateObject("Adodb.RecordSet")
	OpenConn : rs.Open sql,Conn,1,1
	if rs.Bof or rs.EOF then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的评论！</li>"
	else
	
%>
<form method="post" action="User_Comment.asp?ChannelID=<%=ChannelID%>" name="form1">
    
  <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" >
    <tr align="center" class="title"> 
      <td height="22" colspan="4"> <strong>查 看 评 论 </strong></td>
    </tr>
    <tr> 
      <td width="100" align="right" class="tdbg">评论人姓名：</td>
      <td class="tdbg">
        <input name="UserName" type="text" id="UserName" value="<%=rs("UserName")%>" ReadOnly>
      </td>
      <td width="100" align="right" class="tdbg">评 分：</td>
      <td class="tdbg"><input name="Score" type="text" id="Score" maxlength="15" value="<%=rs("Score")%>" ReadOnly></td>
    </tr>
    <tr> 
      <td width="100" align="right" class="tdbg">评论时间：</td>
      <td class="tdbg"> 
        <input name="WriteTime" type="text" id="WriteTime" value="<%=rs("WriteTime")%>" ReadOnly>
      </td>
      <td class="tdbg" align="right" width="100">评论人IP：</td>
      <td class="tdbg"> 
        <input name="IP" type="text" id="IP" maxlength="15" value="<%=rs("IP")%>" ReadOnly>
      </td>
    </tr>
    <tr> 
      <td width="100" align="right" class="tdbg">评论内容：</td>
      <td class="tdbg" colspan="3"> 
        <textarea name="Content" cols="56" rows="8" id="Content" ReadOnly><%=rs("Content")%></textarea>
      </td>
    </tr>
        <%if rs("ReplyName")<>"" then%>
        <tr> 
          <td align="center" class="tdbg">&nbsp;</td>
          <td colspan="3" class="tdbg">
            <%response.write "管理员【" & rs("ReplyName") & "】于 " & rs("ReplyTime") & " 回复：<br><div style='padding:0px 20px'>" & rs("ReplyContent") & "</div>"%>
          </td>
        </tr>
        <%end if%>
  </table>
</form>
<%
	end if
	rs.close
	set rs=Nothing
end sub
%>
<%
'===================================================
' CreateLive CMS Version 3.1
'							Powered by Aspoo.CoM
'===================================================
' Mail: aspoo@126.com, Info@aspoo.cn
' Q  Q: 3315263, 596197794
' Msn : aspoo@126.com, Clw866@hotmail.com
' Web : http://www.aspoo.com, http://www.aspoo.net
' Bbs : http://bbs.aspoo.com, http://bbs.aspoo.net
' Copyright (C) 2005 Aspoo.CoM All Rights Reserved.
'===================================================
%>