<!--#include file="setup.asp" -->
<!--#include file="../inc/Create_ArticleCls.Asp"-->
<%
Dim DelArticleHtml,GetArticleHtml
Dim Rs1,Rs2,selArticleid,i
Dim CurrentPage,maxperpage,totalPut
Dim totalnumber,Pcount,tempPcount
Dim strclassname,keyword,findword
NC_Admin.AdminChk = "23"
NC_Admin.Check
DownsysClass.admin_header
Set Rs = Server.CreateObject("adodb.recordset")
Set Rs1 = Server.CreateObject("adodb.recordset")
Select Case Trim(Request("Action"))
	Case "save"
		Call saveAdd
	Case "modify"
		Call saveModify
	Case "update"
		Call UpdateAllArticle
	Case Else
		Call InfoMain
End Select
If founderr = True Then
	NC_Admin.Error_msg (ErrMsg)
End If
DownsysClass.admin_footer
NothingObject

Private Sub InfoMain()
	Dim bookmark
	If Not IsEmpty(Request("selArticleid")) Then
		selArticleid = Request("selArticleid")
		Select Case Request("action")
			Case "del"
				Call delarticle
			Case "yes"
				Call comeback
			Case Else
				Response.Write "无效参数！"
				Err.Raise -19691969
		End Select
	End If
	Response.Write "<script language=""JavaScript"">" & Chr(13) & Chr(10)
	Response.Write "<!--//" & Chr(13) & Chr(10)
	Response.Write "function Selectbox() {" & Chr(13) & Chr(10)
	Response.Write Chr(9) & "for (var i=0;i<document.form1.selArticleid.length;i++) {" & Chr(13) & Chr(10)
	Response.Write Chr(9) & Chr(9) & "var e=document.form1.selArticleid[i];" & Chr(13) & Chr(10)
	Response.Write Chr(9) & Chr(9) & "e.checked=!e.checked;" & Chr(13) & Chr(10)
	Response.Write Chr(9) & "}" & Chr(13) & Chr(10)
	Response.Write "}" & Chr(13) & Chr(10)
	Response.Write "//-->"
	Response.Write "</script>" & Chr(13) & Chr(10)
	Response.Write "<SCRIPT language = ""JavaScript"">" & Chr(13) & Chr(10)
	Response.Write "<!--//" & Chr(13) & Chr(10)
	Response.Write "function unselectall()" & Chr(13) & Chr(10)
	Response.Write "{" & Chr(13) & Chr(10)
	Response.Write " if(document.myform.chkAll.checked){" & Chr(13) & Chr(10)
	Response.Write Chr(9) & "document.myform.chkAll.checked = document.myform.chkAll.checked&0;" & Chr(13) & Chr(10)
	Response.Write " } " & Chr(9) & Chr(13) & Chr(10)
	Response.Write "}" & Chr(13) & Chr(10)
	Response.Write "function CheckAll(form)" & Chr(13) & Chr(10)
	Response.Write "{" & Chr(13) & Chr(10)
	Response.Write " for (var i=0;i<form.elements.length;i++)" & Chr(13) & Chr(10)
	Response.Write " {" & Chr(13) & Chr(10)
	Response.Write " var e = form.elements[i];" & Chr(13) & Chr(10)
	Response.Write " if (e.Name != ""chkAll"")" & Chr(13) & Chr(10)
	Response.Write " e.checked = form.chkAll.checked;" & Chr(13) & Chr(10)
	Response.Write " }" & Chr(13) & Chr(10)
	Response.Write "}" & Chr(13) & Chr(10)
	Response.Write "//-->"
	Response.Write "</script>" & Chr(13) & Chr(10)
	Response.Write "<table width=""100%"" border=""0"" align=""center"" cellpadding=""2"" cellspacing=""1"" class=""tableBorder"">" & Chr(13) & Chr(10)
	Response.Write " <tr>" & Chr(13) & Chr(10)
	Response.Write " <th width=""5%"" nowrap>选择</th><th width=""80%"">回收站管理</th><th width=""20%"" nowrap>查看文章</th></tr>" & Chr(13) & Chr(10)
	If Not IsEmpty(Request("page")) Then
		CurrentPage = CInt(Request("page"))
	Else
		CurrentPage = 1
	End If
	maxperpage = 20 '###每页显示数
	If Not IsNumeric(Request("page")) And Request("page") <> "" Then
		Response.Write "错误的系统参数!请输入整数"
		Err.Raise -19691969
	End If
	SQL = "select * from NC_article where isLock=1 order by infotime desc"
	Rs.Open SQL, conn, 1, 1
	DownsysClass.SqlQueryNum = DownsysClass.SqlQueryNum + 1
	If Rs.bof And Rs.EOF Then
		Response.Write "<tr><td colspan=3 class=forumrow>回收站没有任何文章！</td></tr>"
	Else
		totalPut = Rs.recordcount
		totalnumber = Rs.recordcount
		If (totalPut Mod maxperpage) = 0 Then
			tempPcount = totalPut \ maxperpage
		Else
			tempPcount = totalPut \ maxperpage + 1
		End If
		If (totalPut Mod maxperpage) = 0 Then
			Pcount = totalPut \ maxperpage
		Else
			Pcount = totalPut \ 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
		Response.Write "<form name=""form1"" method=""post"">" & Chr(13) & Chr(10)
		Response.Write " <tr align=""right"">" & Chr(13) & Chr(10)
		Response.Write " <td height=""22"" colspan=""3"" class=""forumRowHighlight"">"
		Call showpage
		Response.Write "</td></tr>" & Chr(13) & Chr(10)
		Do While Not Rs.EOF And i < CLng(maxperpage)
			Response.Write " <tr>" & Chr(13) & Chr(10)
			Response.Write " <td class=forumrow align=""center""><input type=""checkbox"" name=""selArticleid"" id=""selArticleid"" value="""
			Response.Write Rs("id")
			Response.Write """></td>" & Chr(13) & Chr(10)
			Response.Write " <td height=""22"" class=""forumrow"">["
			Response.Write Rs("classname")
			Response.Write "] <u>"
			Response.Write Rs("title")
			Response.Write "</u></td>" & Chr(13) & Chr(10)
			Response.Write " <td class=forumrow align=""center"" nowrap><a href=admin_article.asp?action=edit&id="
			Response.Write Rs("id")
			Response.Write "&classid="
			Response.Write Rs("classid")
			Response.Write ">查看编辑</a></td></tr>" & Chr(13) & Chr(10)
			Rs.movenext
			i = i + 1
			If i >= maxperpage Then Exit Do
		Loop
	End If
	Rs.Close
	Response.Write " <tr>" & Chr(13) & Chr(10)
	Response.Write " <td height=""22"" colspan=""3"" class=""forumRowHighlight"">"
	Call showpage
	Response.Write "</td></tr>" & Chr(13) & Chr(10)
	Response.Write " <tr>" & Chr(13) & Chr(10)
	Response.Write " <td height=""22"" class=""forumrow"">管理</td>" & Chr(13) & Chr(10)
	Response.Write " <td height=""22"" colspan=""2"" class=""forumrow""><input name=""chkAll"" type=""checkbox"" id=""chkAll"" onclick=CheckAll(this.form) value=""checkbox"">全选/反选 " & Chr(13) & Chr(10)
	Response.Write Chr(9) & "<input type=""radio"" name=""action"" value=""del"">彻底删除" & Chr(13) & Chr(10)
	Response.Write Chr(9) & "<input type=""radio"" name=""action"" value=""yes"">批量还原" & Chr(13) & Chr(10)
	Response.Write "[<a href=?action=update>更新所有文章</a>]" & vbCrLf
	Response.Write "　<input type=""submit"" name=""Submit"" value=""执行操作"" class=button onclick=""{if(confirm('您确定执行的操作吗?')){this.document.form1.submit();return true;}return false;}""></td>" & Chr(13) & Chr(10)
	Response.Write " </tr></form>" & Chr(13) & Chr(10)
	Response.Write "</table>" & Chr(13) & Chr(10)
End Sub

Private Sub showpage()
	Dim filename
	Dim ii
	Dim n
	filename = "admin_articlerec.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><tr><td align=center> " & vbCrLf
	If CurrentPage < 2 Then
		Response.Write " 共有文章 <font COLOR=#FF0000>" & totalnumber & "</font> 篇&nbsp;&nbsp;首 页&nbsp;&nbsp;上一页&nbsp;&nbsp;&nbsp;"
	Else
		Response.Write "共有文章 <font COLOR=#FF0000>" & totalnumber & "</font> 篇&nbsp;&nbsp;<a href=" & filename & "?page=1>首 页</a>&nbsp;&nbsp;"
		Response.Write "<a href=" & filename & "?page=" & CurrentPage - 1 & ">上一页</a>&nbsp;&nbsp;&nbsp;"
	End If
	If n - CurrentPage < 1 Then
		Response.Write "下一页&nbsp;&nbsp;尾 页 " & vbCrLf
	Else
		Response.Write "<a href=" & filename & "?page=" & (CurrentPage + 1) & ">下一页</a>"
		Response.Write "&nbsp;&nbsp;<a href=" & filename & "?page=" & n & ">尾 页</a>" & vbCrLf
	End If
	Response.Write "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
	Response.Write "</td></tr></table>" & vbCrLf
End Sub

Private Sub delarticle()
	DownsysClass.Execute ("delete from NC_Article where id in (" & selArticleid & ")")
        If CInt(DownsysClass.Setting(5)) = 0 Then
        DelArticleHtml=split(selArticleid, ", ")
	Dim DownloadClass, j
	Set DownloadClass = New Create_Article_Cls
	For j = 0 To Ubound(DelArticleHtml)
		DownloadClass.DelArticle(Cint(DelArticleHtml(j)))
	Next
		Set DownloadClass = Nothing
	End If
	'NC_Admin.Succeed_Msg ("<li>批量删除操作成功！</li>")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

Private Sub comeback()
	DownsysClass.Execute ("update NC_article set isLock=0 where id in (" & selArticleid & ")")
        If CInt(DownsysClass.Setting(5)) = 0 Then
        GetArticleHtml=split(selArticleid, ", ")
	Dim DownloadClass, j
	Set DownloadClass = New Create_Article_Cls
	For j = 0 To Ubound(GetArticleHtml)
		DownloadClass.GetArticle(Cint(GetArticleHtml(j)))
	Next
		Set DownloadClass = Nothing
	End If
	'NC_Admin.Succeed_Msg ("<li>你选择的文件已成功还原！</li>")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

Private Sub UpdateAllArticle()
	DownsysClass.Execute ("update NC_Article set isUpdate=1")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub
%>
