<!--#include file="sdcms_check.asp"-->
<%
set sdcms=new Sdcms_Admin
sdcms.Check_admin
sdcms.Check_lever 7
set sdcms=nothing
set sdcms=new sdcms_function
classid=sdcms.Requestint(classid)
set sdcms=nothing
select case action
case else:title="评论管理"
end select
sd_table="sd_comment"
sd_table01="sd_count"
sd_table02="sd_info"
sdcms_head
%>
<div class="sdcms_notice"><span>管理操作：</span><a href="?">评论管理</a></div>
<br>
 
<ul id="sdcms_sub_title">
	<li class="sub"><%=title%></li>
</ul>
<div id="sdcms_right_b">
<%
select case action
case "del":del
case "pass":pass
case else:main
end select
closedb
sub main
echo "<form name=""add"" action=""?"" method=""post""  onSubmit=""return confirm('确定要执行选定的操作吗？');"">"
	page=request.querystring("page")
	if page="" or not isnumeric(page) then
	page=1
	end if
	pages =20
	set rs=server.CreateObject("adodb.recordset")
	if request("classid")<>0 then tj=" where infoid="&request("classid")&""
	sql="select id,username,"
	if Is_sql=0 then
		sql=sql&"(iif(ispass=1,'已审','未审'))"
	else
		sql=sql&"(case ispass when 1 then '已审'else'未审' end)"
	end if
	sql=sql&",ip,adddate,content,ispass,infoid from "&sd_table&" "&tj&" order by ispass,id desc"
	
	rs.open sql,conn,1,1	
	if rs.eof then
	echo "没有资料"
	else
	rs.pagesize = pages
	maxpagecount=rs.pagecount
	rs.absolutepage = page 
	rcount1=0
	pagestart=page-5
	pageend=page+5
	if pagestart<1 then
	pagestart=1
	end if
	if pageend>maxpagecount then
	pageend=maxpagecount
	end if
	rcount=rs.RecordCount
	k=0
	do while not rs.eof and rcount1 <rs.pagesize  
	%>
	<table border="0" align="center" cellpadding="3" cellspacing="1" class="table_b">
	<tr> 
      <td class="title_bg" style="text-align:left"><span style="float:right"><%if rs(6)=0 then%><a href="?action=pass&id=<%=rs(0)%>&t=1&classid=<%=classid%>">通过验证</a><%else%><a href="?action=pass&id=<%=rs(0)%>&t=0&classid=<%=classid%>">取消验证</a><%end if%> <a href="?action=del&id=<%=rs(0)%>&classid=<%=classid%>" onclick='return confirm("真的要删除?不可恢复!");'>删除</a></span><input name="id"  type="checkbox" onClick="unselectall()"   value="<%=rs(0)%>"> <%=rs(1)%> 发表于：<%=rs(4)%>　IP：<%=rs(3)%></td>
   
    </tr>
    <tr onmouseover=this.bgColor='#EBFFDC'; onmouseout=this.bgColor='#ffffff';  bgcolor='#ffffff'>

      <td style="word-break:break-all;">
	<%
	
	set sdcms_f=new sdcms_function
	set rs1=conn.execute("select htmlname,classid,title from sd_info where id="&rs(7)&"")
	if not rs1.eof then
	echo "所属信息：<a "
	echo "href="""&sdcms_root&sdcms_htmdir&sdcms_f.LoadRecord("classdir","sd_class",rs1(1))&rs1(0)&sdcms_filetxt&""" target=""_blank"">"	
	echo ""&rs1(2)&"</a><br>"
	end if
	set sdcms_f=nothing
	echo "评论内容："&rs(5)&"</a>"
	%></td>

    
    </tr>
 
	</table><br>
	<%
	k=k+1
	rs.movenext
	rcount1=rcount1+1
	loop
	end if
	if rcount>0 then      
	%>
	<table border="0" align="center" cellpadding="3" cellspacing="1" class="table_b">
	<tr>
      <td   class="tdbg" >
	  <span class="right">转到第
		 <select onChange="location.href='?classid=<%=classid%>&page='+this.value+''">
		 <%for i=1 to maxpagecount%>
		 <option value="<%=i%>" <%if clng(page)=clng(i) then echo "selected" end if%>><%=i%></option>
		 <%next%>
		 </select>页</span>　<input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox"> 全选 
              <select name="action">
			  <option>→操作</option>
			  <option value="del">删除</option>
			  </select> 
             
      <input type="submit" class="bnt01" value="执行">

</td>
    </tr>
	<%if rcount>0 then%>
	<tr>
      <td   class="tdbg" align="center">
<%
if page<>"1" then
echo "<a href=?page="&page-1&"&classid="&classid&">上一页</a> "
else
echo "上一页 "
end if
for i=pagestart to pageend
if i=0 then 
i=1
end if
if i=clng(page) then
str="<font color=red><b>"&i&"</b></font>"
else
str=i
end if
strurl="[<a href=?page="&i&"&classid="&classid&">"&str&"</a>]"
echo strurl
next
if page=maxpagecount then
echo " 下一页"
elseif  page<>""&maxpagecount&"" then
echo " <a href=?page="&page+1&"&stype="&stype&"&classid="&classid&">下一页</a>"
else
echo " 下一页"
end if
echo " 页次:"&page&"/"&maxpagecount&" 页   每页: "&pages&" 条  总数: "&rcount&" 条"
%>
</td>
    </tr>
	<%end if%>
  </table>
<%
end if
end sub

sub del
if id<>"" then
if instr(id,", ")>0 then
	id=split(id,", ")
		for i=0 to ubound(id)
		
  conn.execute("Insert into sd_log (sdcms_name,ip,content) values('"&sdcms_adminname&"','"&sdcms_adminip&"','删除评论：编号为"&id(i)&"')")
  infoid=conn.execute("select infoid from "&sd_table&" where id="&id(i)&"")(0)
  conn.execute("update "&sd_table01&" set comment_num=comment_num-1 where id=1")
  conn.execute("update "&sd_table02&" set comment_num=comment_num-1 where id="&infoid&"")
  conn.execute("delete from "&sd_table&" where id="&id(i)&"")
 Next
Else
	conn.execute("Insert into sd_log (sdcms_name,ip,content) values('"&sdcms_adminname&"','"&sdcms_adminip&"','删除评论：编号为"&id&"')")
  conn.execute("update "&sd_table01&" set comment_num=comment_num-1 where id=1")
  infoid=conn.execute("select infoid from "&sd_table&" where id="&id&"")(0)
  conn.execute("update "&sd_table02&" set comment_num=comment_num-1 where id="&infoid&"")
  conn.execute("delete from "&sd_table&" where id="&id&"")
End if
End if
  response.Redirect("?classid="&classid&"")
end sub

sub pass
select case t
case "0","1"
case else:t=0
end select
if t=0 then
conn.execute("Insert into sd_log (sdcms_name,ip,content) values('"&sdcms_adminname&"','"&sdcms_adminip&"','取消验证评论：编号为"&id&"')")
else
conn.execute("Insert into sd_log (sdcms_name,ip,content) values('"&sdcms_adminname&"','"&sdcms_adminip&"','通过验证评论：编号为"&id&"')")
end if
conn.execute("update "&sd_table&" set ispass="&t&" where id="&id&"")
response.Redirect("?classid="&classid&"")
end sub

%>  
</div>
</body>
</html>