<!--#include file="../fy.Function.asp"-->
<!--#include file="../../fy_inc/cls_pageview.asp"-->
<!--#include file="../include/fy.F.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>评论管理</title>
<link rel="stylesheet" type="text/css" href="../css/base.css">
<link rel="stylesheet" type="text/css" href="../css/content.css">
</head>
<body>
<% 
Dim ShowErr,ModeID,Rsp,Rsd
 ModeID = ChkNumeric(Request("ModeID"))
 if ModeID=0 or ModeID="" Then ModeID=1
		If Not fycms.fycms_QXYZ(ModeID,"","") Then   Call fycms.Alert("对不起，您没有"&fycms.ACT_C(ModeID,1)&"系该项操作权限！","")

	IF Request.QueryString("Action") = "hf" Then
		Dim ID:ID =Request.Form("ID")
		IF ID = "" Then
			Call fycms.ActErr("请先选定文章！","","1")
			Response.End
		End IF		
			Conn.execute("Update  "&fycms.ACT_C(ModeID,2)&"  set delif=0 where ID in ("&ID&")")
			set conn=nothing
			ShowErr = "<li>批量恢复成功！</li>"
 	 	 Call fycms.ActErr(ShowErr,"fy_Mode/fy.Recyle.asp?ModeID="&ModeID&"&Type=New","")
	End IF
	
	
	
	IF Request.QueryString("Action") = "hf1" Then
		ID = ChkNumeric(Request.QueryString("ID"))
		Conn.execute("Update  "&fycms.ACT_C(ModeID,2)&"  set delif=0 where ID ="&ID&"")
		set conn=nothing
		ShowErr = "<li>文章恢复成功 </li>"
 	 	 Call fycms.ActErr(ShowErr,"fy_Mode/fy.Recyle.asp?ModeID="&ModeID&"&Type=New","")
		Response.end
	End IF
	
	
	IF Request.QueryString("Action") = "dels" Then
		ID = ChkNumeric(Request.QueryString("ID"))
			Conn.Execute ("Delete From  "&fycms.ACT_C(ModeID,2)&"  Where ID=" & ID)		
			ShowErr = "<li>文章已经彻底删除</li>"
			set conn=nothing
 	 	 Call fycms.ActErr(ShowErr,"fy_Mode/fy.Recyle.asp?ModeID="&ModeID&"&Type=New","")
		Response.end
	End IF

		IF Request.QueryString("Action") = "del" Then
			ID =Request.Form("ID")
			IF ID = "" Then
				Call fycms.ActErr("请先选定文章！","","1")
				Response.End
			End IF		
			ID = Split(ID,",")
		
			 For I = LBound(ID) To UBound(ID)
				set Rsd=fycms.ActExe("Select * from "&fycms.ACT_C(ModeID,2)&"  Where ID=" & ID(I) & "")
				If rsd.eof And rsd.bof Then
					Call fycms.ActErr("参数错误","","1")
 				Else
					If  fycms.fycms_QXYZ(ModeID,"4",Rsd("classid")) Then  
						Set Rsp = server.CreateObject("adodb.recordset")'删除图片
						Rsp.open "Select * from Upload_fy Where AID=" & ID(I) & " and modeid="&ModeID&"", conn, 1, 3
						If Not  rsp.eof  Then
							Do While Not rsp.eof
							Call fycms.DeleteFile(Rsp("UpfileDir"))
							Conn.execute("Delete from Upload_fy  Where id= "&Rsp("id"))
							rsp.movenext
							loop
						End If 
						Dim Tmps,TmpUs 
						If Right(fycms.ACT_C(ModeID,10),1)<>"/" Then 
								Call fycms.DeleteFile(fycms.ActSys&fycms.ACT_C(ModeID,6)&Rsd("FileName")&fycms.ACT_C(ModeID,11))
						Else
								Call fycms.DeleteFile(fycms.ActSys&fycms.ACT_C(ModeID,6)&Rsd("FileName")&"/Index"&fycms.ACT_C(ModeID,11))
						End If 
						Conn.execute("Delete from "&fycms.ACT_C(ModeID,2)&"  Where ID=" & ID(I) & "")
						Conn.execute("Delete from Comment_fy  Where ID=" & ID(I) & " and ModeID="&ModeID&"")
						Conn.execute("Delete from Digg_fy  Where NewsID=" & ID(I) & " and ModeID="&ModeID&"")
					End If 
				End If 
		 	 Next
				set conn=nothing	
				ShowErr = "<li>文章已经彻底删除！</li>"
 	 	 Call fycms.ActErr(ShowErr,"fy_Mode/fy.Recyle.asp?ModeID="&ModeID&"&Type=New","")
	  End IF

	

	
	
	
	
	Dim strLocalUrl
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	
	Dim intPageNow
	intPageNow = request.QueryString("page")
	
	Dim intPageSize, strPageInfo
	intPageSize = 30
	
	Dim arrinfo, i
	Dim sql, sqlCount,Sqls
	Select Case Request.QueryString("Action")
		Case "ListID"
			Sqls = " where classid='"&Request.QueryString("ClassID")&"' and delif=1  "
		Case "ListisAccept"
			Sqls = "  where isAccept=0 and delif=1 "
		Case "ListNoAccept"
			Sqls = "  where isAccept=2 and delif=1 "
		Case "Listcg"
			Sqls = "  where isAccept=1 and delif=1 "
		Case "Listtg"
			Sqls = "  where isAccept=3 and delif=1 "
		Case "Listpic"
			Sqls = "  where ArticlePic=1 and delif=0 "
		Case Else
			Sqls = " where delif=1 "
	End Select
	sql = "SELECT [ID], [Title], [ArticleInput], [Hits], [isAccept], [IsTop],  [ClassID], [FileName]" & _
		" FROM ["&fycms.ACT_C(ModeID,2)&"]" &Sqls& _
		"ORDER BY [ID] DESC"
 	sqlCount = "SELECT Count([ID])" & _
			" FROM ["&fycms.ACT_C(ModeID,2)&"]"&Sqls

		Dim clsRecordInfo
		Set clsRecordInfo = New Cls_PageView
		
		Rem 记录集总数取值优先顺序: strSqlCount >>  intRecordCount
		Rem 即当 strSqlCount 有值时, intRecordCount 无作用
		Rem 因此, 若要手工设置记录总数, 请设置 intRecordCount, strSqlCount 留空
		Rem 若以上两者都没有设置, 则取 strSql 执行后的 RecordCount 属性.
			clsRecordInfo.intRecordCount = 2816
			clsRecordInfo.strSqlCount = sqlCount
		Rem 此处因设置了 strSqlCount, 则记录总数将由此语句计算得出.
		
		Rem 设置 SQL 查询语句
			clsRecordInfo.strSql = sql
		
		Rem 设置每页显示数
			clsRecordInfo.intPageSize = intPageSize
		
		Rem 设置当前显示页
			clsRecordInfo.intPageNow = intPageNow
		
		Rem 设置转向页面
			clsRecordInfo.strPageUrl = strLocalUrl
		
		Rem 设置页面转向参数
			clsRecordInfo.strPageVar = "page"

		clsRecordInfo.objConn = Conn		
		arrinfo = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
	 %><div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 回收站管理</div>
    <div class="opers">
		选择模型:<select name='ModeID' style='width:110px' onChange="location=this.value;">
	  <%=AF.ACT_URL_Mode(ModeID,"&ClassID="&request("ClassID"))%>
	  </select>

	</div>
   
<form name="Article" method="post" action="?Action=">
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>选中</th><th>ID</th><th>文章标题</th><th>栏目</th><th>管理操作</th>
	  </tr>
    </thead>

  


	 <%
		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
			Dim Rs ,ClassName,ClasseName
			  Set Rs = server.CreateObject("adodb.recordset")
					Rs.Open "select ClassName,ClasseName from Class_fy where ClassID="& arrinfo(6,i) &"",Conn,1,1
					if  Not Rs.bof then
							ClassName =Rs("ClassName")
							ClasseName =Rs("ClasseName")
					Else

							ClassName ="<font color=red>程序出现错误</font>"
							ClasseName ="<font color=red>意外错误</font>"
					End if 
	%>
    <tr>
      <td  >
	  <input type="checkbox" name="ID" value="<%= arrinfo(0,i) %>">	  </td>
      <td><%= arrinfo(0,i) %></td>
      <td><a target="_blank" href="<%= fycms.actsys&fycms.act_c(ModeID,5)&"/index.asp?id=" &arrinfo(0,i)  %>"><%= arrinfo(1,i) %></a></td>
      <td>
	 <a href="?Action=ListID&ClassID=<%= arrinfo(6,i) %>&ModeID=<%=ModeID%>"><%= classname %></a>	  </td>
      <td colspan="2" >
	  <a href="?Action=dels&ID=<%= arrinfo(0,i) %>&ModeID=<%=ModeID%>" onClick="return confirm('确认删除此文章吗?删除后您可以从回收站还原!')">删除</a>┆
	  <a href="?Action=hf1&ID=<%= arrinfo(0,i) %>&ModeID=<%=ModeID%>">恢复</a> 
   
	  </td>
    </tr>
	<% 
	Next
	End If
	%>


	   <tr >
      <td colspan="8" class="tl">
	 <label for=chk>
<input id="chk" type="checkbox" name="chkall" value="checkbox" onClick="CheckAll(this.form)">选择全部文章</label>
	  <input type="button" class="btn btn_primary" name="Submit" value="批量恢复"  onClick="hfpost()"> 
	  <input type="button" class="btn btn_primary" name="yd" value="批量删除" onClick="delpost()"></td>
    </tr>



	</table>
    <div class="pagelist">
<%= strPageInfo%>
   </div>
   </form>
</div>

<script language="javascript">
function CheckAll(form)  
  {  
 for (var i=0;i<form.elements.length;i++)  
    {  
    var e = Article.elements[i];  
   if (e.name != 'chkall')  
      e.checked = Article.chkall.checked;  
   }  
  }



function delpost(){
    document.Article.method="post";
    document.Article.action="?ModeID=<%=ModeID%>&Action=del";
{
	if(confirm('确认要删除选中的文章吗?此操作不可恢复!')){
	this.document.Article.submit();
	return true;}return false;
}
	}



	
function hfpost(){
    document.Article.method="post";
    document.Article.action="?ModeID=<%=ModeID%>&Action=hf";
{
	if(confirm('确认要恢复选中的文章吗?本操作将选中的文章移到回收站当中.必要时您可以从回收站恢复!')){
	this.document.Article.submit();
	return true;}return false;
}
	}




</script>
<%
	Public Function DeleteFile(FileStr)
	   Dim FSO
	   On Error Resume Next
	   Set FSO = CreateObject("scripting.FileSystemObject")
		If FSO.FileExists(Server.MapPath(FileStr)) Then
			FSO.DeleteFile Server.MapPath(FileStr), True
		Else
		DeleteFile = True
		End If
	   Set FSO = Nothing
	   If Err.Number <> 0 Then
	   Err.Clear:DeleteFile = False
	   Else
	   DeleteFile = True
	   End If
	End Function

CloseConn %> </body>
</html>
