<!--#include file="setup.asp" -->
<%
NC_Admin.AdminChk = "25"
NC_Admin.Check
DownsysClass.Admin_Header
Const MaxPerPage = 15
Dim totalPut
Dim CurrentPage
Dim TotalPages
Dim j, i
Dim totalnumber
Dim maxpagecount
Dim Pcount
Dim bookmark
Dim filename
Select Case Trim(request("action"))
	Case "del"
		Call DelEssay()
	Case "delall"
		Call DelAllEssay()
	Case Else
		Call EssayMain()
End Select
If FoundErr = True Then
	NC_Admin.Error_Msg(ErrMsg)
End If
DownsysClass.Admin_Footer
NothingObject

Sub EssayMain()
	If Not IsEmpty(Request("page")) Then
		CurrentPage = CLng(Request("page"))
	Else
		CurrentPage = 1
	End If
	If Not IsNumeric(Request("page")) And Request("page") <> "" Then
		Response.Write "错误的系统参数!请输入整数"
		Respponse.End
	End If

%>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
   <tr>
      <th nowrap>选择</th><th>文章评论标题</th><th nowrap>评 论 人</th><th nowrap>E-Mail</th><th nowrap>评论人IP</th><th nowrap>评论时间</th>
   </tr>
      <form name="myform" method="post" action=''>
<%
Set Rs = CreateObject("ADODB.Recordset")
SQL = "select NC_ArticleEssay.*,NC_Article.title From NC_ArticleEssay,NC_Article where NC_ArticleEssay.ArticleID = NC_Article.id order by postime desc"
Rs.Open SQL, conn, 1, 1
DownsysClass.SqlQueryNum = DownsysClass.SqlQueryNum + 1
If Rs.bof And Rs.EOF Then
	Response.Write "<tr><td colspan=5 class=forumrow>还没有找到任何文章评论！</td></tr>"
Else
	totalnumber = rs.recordcount
	If (totalnumber Mod maxperpage) = 0 Then
		Pcount = totalnumber \ maxperpage
	Else
		Pcount = totalnumber \ maxperpage + 1
	End If
	Rs.MoveFirst
	If CurrentPage > Pcount Then CurrentPage = Pcount
	If CurrentPage < 1 Then CurrentPage = 1
	rs.Move (CurrentPage - 1) * maxperpage
	bookmark = rs.bookmark
	i = 0
	Do While Not rs.EOF And i < CLng(maxperpage)

%>
   <tr height="21">
      <td align=center class=forumRowHighlight><input type=checkbox name=Essayid value='<%=Rs("id")%>'></td>
	  <td class=forumRowHighlight><A HREF='../ArticleEssay.asp?id=<%=Rs("ArticleID")%>' target=_blank><%=Server.HTMLEncode(rs("title"))%></A></td>
	  <td nowrap align=center class=forumRowHighlight><%=Server.HTMLEncode(rs("username"))%></td>
	  <td nowrap align=center class=forumRowHighlight><A HREF="admin_mailist.asp?action=mail&useremail=<%=rs("usermail")%>"><img src="images/email.gif" border=0></A></td>
	  <td nowrap align=center class=forumRowHighlight><%=rs("postip")%></td>
	  <td nowrap align=center class=forumRowHighlight><%=FormatDateTime(rs("postime"),2)%></td>
   </tr>
   <tr height="21">
      <td colspan=6 class=forumRow><%=DownsysClass.gotTopic(rs("content"),200)%></td>
   </tr>
<%
rs.movenext
i = i + 1
If i >= maxperpage Then Exit Do
Loop
End If
Rs.Close
Set Rs = Nothing
%>
   <tr height="21">
      <td align=center class=forumRowHighlight>管理</td>
	  <td colspan=5 class=forumRow><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">全选/反选　
	    <input type="radio" name="action" value="delall">清空所有文章评论&nbsp;&nbsp;
	    <input type="radio" name="action" value="del">批量删除&nbsp;&nbsp;
		<input type=submit name=Submit value="执行操作" class=button onclick="{if(confirm('您确定执行此操作吗?')){this.document.myform.submit();return true;}return false;}"></td>
   </tr>
   </form>
   <tr height="21">
      <td colspan=6 class=forumRowHighlight><%Call showpage%></td>
   </tr>
</table>
<%
End Sub

Private Sub DelEssay()
	DownsysClass.Execute ("delete from NC_ArticleEssay where id in (" & Request.Form("Essayid") & ")")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
	Err.Raise -19691969
End Sub

Private Sub DelAllEssay()
	DownsysClass.Execute ("delete from NC_ArticleEssay")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
	Err.Raise -19691969
End Sub

Private Sub showpage()
	Dim filename
	Dim n
	Dim ii
	filename = "admin_articlessay.asp"
	If totalnumber Mod maxperpage = 0 Then
		n = totalnumber \ maxperpage
	Else
		n = totalnumber \ maxperpage + 1
	End If
	Response.Write "<table cellspacing=1 width='100%' border=0><form method=Post action=" & filename & "><tr><td align=center> " & vbCrLf
	If CurrentPage < 2 Then
		Response.Write "共有评论 <font COLOR=#FF0000><B>" & totalnumber & "</B></font> &nbsp;首 页&nbsp;上一页&nbsp;"
	Else
		Response.Write "共有评论 <font COLOR=#FF0000><B>" & totalnumber & "</B></font> &nbsp;<a href=" & filename & "?page=1>首 页</a>&nbsp;"
		Response.Write "<a href=" & filename & "?page=" & CurrentPage - 1 & ">上一页</a>&nbsp;"
	End If
	If n - CurrentPage < 1 Then
		Response.Write "下一页&nbsp;尾 页 " & vbCrLf
	Else
		Response.Write "<a href=" & filename & "?page=" & (CurrentPage + 1) & ">下一页</a>"
		Response.Write "&nbsp;<a href=" & filename & "?page=" & n & ">尾 页</a>" & vbCrLf
	End If
	Response.Write "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
	Response.Write "&nbsp;转到："
	Response.Write "&nbsp;<select name='page' size='1' style=""font-size: 9pt"" onChange='javascript:submit()'>" & vbCrLf
	For ii = 1 To n
		Response.Write "<option value='" & ii & "' "
		If CurrentPage = Int(ii) Then
			Response.Write "selected "
		End If
		Response.Write ">第" & ii & "页</option>"
	Next
	Response.Write "&nbsp;</select> " & vbCrLf
	Response.Write "</td></tr></FORM></table>" & vbCrLf
End Sub
%>
