<!--#include file="../FreeJs/Cls_JS.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P0107") then Call ReturnError2()

Dim TempNum,RecRikerNewsObj,RecRikerClassObj
Set RecRikerClassObj = Conn.Execute("Select count(ClassID) from NewsClass where DelFlag=1")
TempNum = RecRikerClassObj(0)
Set RecRikerNewsObj = Conn.Execute("Select count(NewsID) from News where DelTF=1")
TempNum = Clng(TempNum) + Clng(RecRikerNewsObj(0))

Dim RecaSysRootDir
if SysRootDir = "" then
	RecaSysRootDir = ""
else
	RecaSysRootDir = "/" & SysRootDir
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<style type="text/css">
<!--
body{
	cursor: default;

}
input{
	background-color: #FFFFFF;
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: solid;
	border-right-style: solid;
	border-bottom-style: solid;
	border-left-style: solid;
	border-top-color: #CCCCCC;
	border-right-color: #000000;
	border-bottom-color: #000000;
	border-left-color: #CCCCCC;

}
-->
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>回收站</title>
</head>
<link href="../../CSS/css.css" rel="stylesheet">
<body topmargin="0" leftmargin="0" oncontextmenu="return false;" ondragstart="return false;" onselectstart="return false;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td><img src="../Images/Recycle.gif" width="120" height="70"></td>
  </tr>
  <tr> 
    <td height="30">要永久的删除回收站中所有的栏目和新闻</td>
  </tr>
  <tr> 
    <td height="30">
<div align="center"> 
        <input type="button" onClick="OperateFun('DelAll');" <%If Clng(TempNum)<=0 then Response.Write("disabled")%> name="Submit" value="清空回收站">
      </div></td>
  </tr>
  <tr> 
    <td height="30">要还原回收站中所有的栏目和新闻</td>
  </tr>
  <tr> 
    <td height="30">
<div align="center"> 
        <input type="button" onClick="OperateFun('UnDoAll');" <%If Clng(TempNum)<=0 then Response.Write("disabled")%> name="Submit2" value="全部还原">
      </div></td>
  </tr>
</table>
</body>
</html>
<script language="JavaScript">
function OperateFun(Type)
{
	var PromptInfo='';
	switch (Type)
	{
		case 'DelAll':
			PromptInfo='删除全部';
			break;
		case 'UnDoAll':
			PromptInfo='还原全部';
			break;
		default :
			alert('操作无效');
			return;
			break;
	}
	if (confirm('确定要'+PromptInfo+'吗？'))
	{
		window.location='?OperateType='+Type;
		window.parent.location='Index.asp';
	}
}
</script>
<%
Dim OperateType,Sql,MyFile
Set MyFile=Server.CreateObject("Scripting.FileSystemObject")
OperateType = Request("OperateType")
if OperateType = "DelAll" then
	'------------------删除栏目目录物理文件---------------------
	Dim DellNewsClassObjj,RsDellNewsObj,RssDelNewsTempClass
	Set DellNewsClassObjj = Conn.Execute("Select SaveFilePath,ClassEName from NewsClass where DelFlag=1")
	Do while Not DellNewsClassObjj.eof
		If MyFile.FolderExists(Server.Mappath(RecaSysRootDir&DellNewsClassObjj("SaveFilePath")&"/"&DellNewsClassObjj("ClassEName"))) then
			MyFile.DeleteFolder(Server.Mappath(RecaSysRootDir&DellNewsClassObjj("SaveFilePath")&"/"&DellNewsClassObjj("ClassEName")))
		End if
		DellNewsClassObjj.MoveNext
	Loop
	DellNewsClassObjj.Close
	Set DellNewsClassObjj = Nothing
	'----------------删除单个新闻文件---------------------------
	Set RsDellNewsObj = Conn.Execute("Select FileName,FileExtName,ClassID from News where DelTF=1 and ClassID in (Select ClassID from NewsClass where DelFlag=0)")
	Do while not RsDellNewsObj.eof
	Set RssDelNewsTempClass = Conn.Execute("Select ClassEName,SaveFilePath from NewsClass where ClassID='"&RsDellNewsObj("ClassID")&"'")
		If MyFile.FileExists(Server.Mappath(RecaSysRootDir&RssDelNewsTempClass("SaveFilePath")&"/"&RssDelNewsTempClass("ClassEName"))&"/"&RsDellNewsObj("FileName")&"."&RsDellNewsObj("FileExtName")) then
		   MyFile.DeleteFile(Server.Mappath(RecaSysRootDir&RssDelNewsTempClass("SaveFilePath")&"/"&RssDelNewsTempClass("ClassEName"))&"/"&RsDellNewsObj("FileName")&"."&RsDellNewsObj("FileExtName"))
		End if
		RssDelNewsTempClass.Close
		Set RssDelNewsTempClass = Nothing
		RsDellNewsObj.MoveNext
	Loop
	RsDellNewsObj.Close
	Set RsDellNewsObj = Nothing
	'------------------------------------------------------------
	Sql = "Delete from News where DelTF=1"
	Conn.Execute(Sql)
	Sql = "Delete from Contribution where ClassID in (Select ClassID from NewsClass where DelFlag=1)"
	Conn.Execute(Sql)
	Sql = "Delete from DownLoad where ClassID in (Select ClassID from NewsClass where DelFlag=1)"
	Conn.Execute(Sql)
	Sql = "Delete from NewsClass where DelFlag=1"
	Conn.Execute(Sql)
	Conn.Execute("Delete from FreeJsFile where DelFlag=1")
	
elseif OperateType = "UnDoAll" then
	Sql = "UpDate News Set DelTF=0 where DelTF=1"
	Conn.Execute(Sql)
	Sql = "UpDate NewsClass Set DelFlag=0 where DelFlag=1"
	Conn.Execute(Sql)
	'---------------重新生成相关自由JS------------------------
	Dim FunDelCreFreeJsObj,TemmpStrr,JsENameArr,Riker_ii,RikerCreTempObj
	Set FunDelCreFreeJsObj = Conn.Execute("Select distinct JSName from FreeJsFile where DelFlag=1")
	TemmpStrr = ""
	Do while Not FunDelCreFreeJsObj.eof
	If TemmpStrr = "" then
		TemmpStrr = FunDelCreFreeJsObj("JSName")
	Else
		TemmpStrr = TemmpStrr & "," & FunDelCreFreeJsObj("JSName")
	End If
		FunDelCreFreeJsObj.MoveNext
	Loop
	FunDelCreFreeJsObj.Close
	Set FunDelCreFreeJsObj = Nothing
	Conn.Execute("Update FreeJsFile set DelFlag=0 where DelFlag=1")
	JsENameArr = Array("")
	JsENameArr = Split(TemmpStrr,",")
	For Riker_ii = 0 to UBound(JsENameArr)
		Set RikerCreTempObj = Conn.Execute("Select Manner,EName from FreeJS where EName='"&JsENameArr(Riker_ii)&"'")
		If Not RikerCreTempObj.eof then
			Select case RikerCreTempObj("Manner")
			 case "1"   WCssA RikerCreTempObj("EName"),True
			 case "2"   WCssB RikerCreTempObj("EName"),True
			 case "3"   WCssC RikerCreTempObj("EName"),True
			 case "4"   WCssD RikerCreTempObj("EName"),True
			 case "5"   WCssE RikerCreTempObj("EName"),True
			 case "6"   PCssA RikerCreTempObj("EName"),True
			 case "7"   PCssB RikerCreTempObj("EName"),True
			 case "8"   PCssC RikerCreTempObj("EName"),True
			 case "9"   PCssD RikerCreTempObj("EName"),True
			 case "10"   PCssE RikerCreTempObj("EName"),True
			 case "11"   PCssF RikerCreTempObj("EName"),True
			 case "12"   PCssG RikerCreTempObj("EName"),True
			 case "13"   PCssH RikerCreTempObj("EName"),True
			 case "14"   PCssI RikerCreTempObj("EName"),True
			 case "15"   PCssJ RikerCreTempObj("EName"),True
			 case "16"   PCssK RikerCreTempObj("EName"),True
			 case "17"   PCssL RikerCreTempObj("EName"),True
		   End Select
	   End If
	   RikerCreTempObj.Close
	   Set RikerCreTempObj = Nothing
	Next
	'---------------------------------------------------------
end if
Set MyFile = Nothing
Set Conn = Nothing
%>
