<!--#include file="conn.asp"-->
<%if request.cookies("admin")("admin")="" then
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆！');window.location.href='login.asp';</script>"
response.End
else
if request.cookies("admin")("flag")>2 then
response.Write "<p align=center><font color=red>您没有此项目管理权限！</font></p>"
response.End
end if
end if
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../image/css.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="1">
<%dim action
action=request.QueryString("action")
select case action
case "del"
if request("shenhe").count=0 then
response.write "<script language=javascript>alert('您没有选择要删除的评论？');history.go(-1);</script>"
response.End
end if
conn.execute ("delete from news_pinglun where pinglunid in ("&request("shenhe")&")")
response.write "<script language=javascript>alert('批量删除成功!');history.go(-1);</script>"
response.end
case "shenhe"
if request("shenhe").count=0 then
response.write "<script language=javascript>alert('您没有选择要审核的评论？');history.go(-1);</script>"
response.End
end if
conn.execute "update news_pinglun set shenhe=1 where pinglunid in ("&request("shenhe")&")"
response.write "<script language=javascript>alert('批量审核成功!');history.go(-1);</script>"
response.end
case "delzhou"
dim theday
theday=date-7
conn.execute ("delete from news_pinglun where pinglundate<#"&theday&"# and shenhe=0")
response.write "<script language=javascript>alert('一周前未审核评论删除成功!');history.go(-1);</script>"
response.end
case "delall"
conn.execute ("delete from news_pinglun where shenhe=0")
response.write "<script language=javascript>alert('所有未审核评论删除成功!');history.go(-1);</script>"
response.end
case ""%>

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr> 
<form name="form1" method="post" action="">
<td> 
<%'开始分页
Const MaxPerPage=20 
dim totalPut   
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if 
if request("mo")="no" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from news_pinglun where shenhe=0 order by pinglunid desc",conn,1,1
elseif request("mo")="all" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from news_pinglun order by pinglunid desc",conn,1,1
elseif request("mo")="hf" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from news_pinglun where huifu is null order by pinglunid desc",conn,1,1
elseif request("mo")="yes" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from news_pinglun where shenhe=1 order by pinglunid desc",conn,1,1
elseif request("mo")="more" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from news_pinglun order by pinglunid desc",conn,1,1
end if
if err.number<>0 then
response.write "数据库中无数据"
end if
if rs.eof And rs.bof then
Response.Write "<p align='center' class='contents'> 目前还没有任何评论！</p>"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"managenewspinglun.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move  (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"managenewspinglun.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"managenewspinglun.asp"
end if
end if
end if
sub showContent
dim i
i=0%>
<table class="tableBorder" width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="4" class="managetop">
☉ <a href="managenewspinglun.asp?mo=all">所有评论</a> 
☉ <a href="managenewspinglun.asp?mo=hf">未回复的评论</a> 
☉ <a href="managenewspinglun.asp?mo=no">未审核的评论</a> 
☉ <a href="managenewspinglun.asp?mo=yes">已审核的评论</a> 
☉ <a href="managenewspinglun.asp?mo=more">更多</a></td>
</tr>
<tr class="tdcolor">
<td width="10%">ID号</td>
<td width="30%">评论标题</td> 
<td width="30%" align="center">评论时间</td>
<td width="10%" align="center">操 作</td>
</tr>
<%do while not rs.eof
set rs1=server.CreateObject("adodb.recordset")
rs1.open"select * from news_moban where newsid="&rs("newsid")&" ",conn,1,1%>
<tr class="tdcolor">
<td><a href="<%=rs1("pathlink")%>" target="_blank"><%=rs1("newsid")%></a></td>
<td><a href="?action=viewpin&id=<%=rs("pinglunid") %>" title="<%=trim(rs("pingluntitle"))%>"><%=trim(rs("pingluntitle"))%></a></td> 
<td align="center"><%=rs("pinglundate")%></td>
<td align="center">
<input name="shenhe" type="checkbox" id="shenhe" value="<%=rs("pinglunid")%>"></td>
</tr>
<%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing
%>
<tr class="tdcolor"> 
<td height="30" colspan="4" align="center"> 
<%if action="no" then%>
<input type="submit" name="Submit" value="通过审核" onClick="this.form.action='managenewspinglun.asp?action=shenhe';this.form.submit()">
<%end if%>
&nbsp; 
<input type="button" name="Submit2" value="删 除" onClick="this.form.action='managenewspinglun.asp?action=del';this.form.submit()">
&nbsp;&nbsp;全选 
<input type="checkbox" name="checkbox" value="Check All" onClick="mm()"></td>
</tr>
</table>
<%End Sub   
Function showpage(totalnumber,maxperpage,filename)  
Dim n
If totalnumber Mod maxperpage=0 Then  
n= totalnumber \ maxperpage  
Else
n= totalnumber \ maxperpage+1  
End If
Response.Write "<form method=Post action="&filename&"?action="&action&">"  
Response.Write "<p align='center' class='contents'> "  
If CurrentPage<2 Then  
Response.Write "<font class='contents'>首页 上一页</font> "  
Else  
Response.Write "<a href="&filename&"?page=1&action="&action&" class='contents'>首页</a> "  
Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&action="&action&" class='contents'>上一页</a> "  
End If
If n-currentpage<1 Then  
Response.Write "<font class='contents'>下一页 尾页</font>"  
Else  
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&action="&action&" class='contents'>"  
Response.Write "下一页</a> <a href="&filename&"?page="&n&"&action="&action&" class='contents'>尾页</a>"  
End If  
Response.Write "<font class='contents'> 页次：</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"页</font> "  
Response.Write "<font class='contents'> 共有"&totalnumber&"条记录 " 
Response.Write "<font class='contents'>" 
Response.Write "</form>"  
End Function %>
</td>
</form>
</tr>
</table>
<table class="tableBorder" width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr> 
<td class="managetop">其 它 操 作 </td>
</tr>
<tr class="tdcolor"> 
<td height="50"> 
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr> 
<td height="20" class=pad>删除一周前未审核的评论　
<input type="submit" name="Submit4" value="确 认" onClick="if(confirm('您确定这样操作吗?')) location.href='managenewspinglun.asp?action=delzhou';else return;">
</td>
</tr>
<tr> 
<td height="16" class=pad>删除所有未审核的评论　　
<input type="submit" name="Submit4" value="确 认" onClick="if(confirm('您确定这样操作吗?')) location.href='managenewspinglun.asp?action=delall';else return;">
</td>
</tr>
</table>
</td>
</tr>
</table>
<script language=javascript>
function mm()
{
   var a = document.getElementsByTagName("input");
   if(a[0].checked==true){
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = false;
   }
   else
   {
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = true;
   }
}
</script>

<%case "savepin"
pinglunid=request("id")
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from news_pinglun where pinglunid="&pinglunid,conn,1,3
rs("huifu")=trim(request("huifu"))
rs("huifudate")=now()
rs.update
rs.close
set rs=nothing
response.write "<span style='height:500px;font-size:12px;padding-top:200px;padding-left:150px;color:red'>提交成功</span><script>window.setTimeout(""location.href='?mo=all'"",1000);</script>"
response.End
case "viewpin"%>
<table class="tableBorder" width="90%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<tr> 
<td class="managetop">发表评论</td>
</tr>
<tr>
<%set rs=server.CreateObject("adodb.recordset")
rs.open "select * from news_pinglun where pinglunid="&request("id"),conn,1,3%>
<form name="pinglunform" method="post" action="?action=savepin&id=<%=rs("pinglunid")%>">
<td class="tdcolor"> 
<table width="100%" align="center" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF">
<tr class="tdcolor"> 
<td width="20%" align="right">姓 名：</td>
<td width="80%"> 
<input name="pinglunname" type="text" id="pinglunname" size="30" value="<%=rs("pinglunname")%>" readonly></td>
</tr>
<tr class="tdcolor"> 
<td align="right">评论标题：</td>
<td><input name="pingluntitle" type="text" id="pingluntitle" size="30" value="<%=rs("pingluntitle")%>" readonly></td>
</tr>
<tr class="tdcolor"> 
<td align="right" valign="top">评论正文：</td>
<td><textarea name="pingluncontent" cols="30" rows="3" id="pingluncontent"><%=rs("pingluncontent")%></textarea></td>
</tr>
<tr class="tdcolor"> 
<td align="right" valign="top"><font color="#FF0000">管理回复：</font></td>
<td><textarea name="huifu" cols="30" rows="5" id="huifu"><%=rs("huifu")%></textarea></td>
</tr>
<tr class="tdcolor">
<td></td>
<td>
<input onClick="return check();" name="submit" type="submit" value="回复保存">
<input onClick="ClearReset()" type="reset" name="Clear" value="重新填写"></td>
</tr>
</table>
<%rs.close
set rs=nothing%>
</td>
</form>
</tr>
</table>
<%function HTMLEncode2(fString)
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
HTMLEncode2 = fString
end function%>
<script language="javascript">
<!--
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
function check()
{
  if(checkspace(document.pinglunform.pinglunname.value)) {
	document.pinglunform.pinglunname.focus();
    alert("请填写您的姓名！");
	return false;
  }
  if(checkspace(document.pinglunform.pingluntitle.value)) {
	document.pinglunform.pingluntitle.focus();
    alert("请填写评论标题！");
	return false;
  }
  if(checkspace(document.pinglunform.pingluncontent.value)) {
	document.pinglunform.pingluncontent.focus();
    alert("请填写评论正文！");
	return false;
  }
	  }
//-->
</script>
<%end select%>
<!--#include file="copyright.asp"-->
</body>
</html>