<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Admin.asp"-->
<!--#include file="Conn.asp"-->
<!--#include file="Inc/Function.asp"-->
<!--#include file="../Inc/Config.asp"-->
<%
dim ArticleID,Action,sqlDel,rsDel,FoundErr,ErrMsg,ObjInstalled
ArticleID=trim(request("ArticleID"))
Action=Trim(Request("Action"))
FoundErr=False
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")

if ArticleId="" then
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>²ÎÊý²»×ã£¡</li>"
end if
if FoundErr=False then
  dim idarr,i
  if Action="Del" then
	if instr(ArticleID,",")>0 then
		idArr=split(ArticleID)
		for i = 0 to ubound(idArr)
			call DelArticle(clng(idarr(i)))
		next
	else
		call DelArticle(clng(ArticleID))
	end if
  elseif Action="Elite" then
	if instr(ArticleID,",")>0 then
		idArr=split(ArticleID)
		for i = 0 to ubound(idArr)
			call SetArticle(clng(idarr(i)))
		next
	else
		call SetArticle(clng(ArticleID))
	end if
  elseif Action="Reset" then
	if instr(ArticleID,",")>0 then
		idArr=split(ArticleID)
		for i = 0 to ubound(idArr)
			call ReSetArticle(clng(idarr(i)))
		next
	else
		call ReSetArticle(clng(ArticleID))
	end if
  elseif Action="tjshow" then
	if instr(ArticleID,",")>0 then
		idArr=split(ArticleID)
		for i = 0 to ubound(idArr)
			call ReSetTjshow(clng(idarr(i)))
		next
	else
		call ReSetTjshow(clng(ArticleID))
	end if
  elseif Action="Reshow" then
	if instr(ArticleID,",")>0 then
		idArr=split(ArticleID)
		for i = 0 to ubound(idArr)
			call ReSetReshow(clng(idarr(i)))
		next
	else
		call ReSetReshow(clng(ArticleID))
	end if
  elseif Action="Orders" Then
	ordersID=trim(request("Orders"))
	if instr(ordersID,",")>0 then
		ORDarr=split(ordersID)
	end If

	if instr(ArticleID,",")>0 then
		idArr=split(ArticleID)
		for i = 0 to ubound(idArr)
			call ReSetOrders(clng(idarr(i)),clng(ORDarr(i)))
		next
	else
		call ReSetOrders(clng(ArticleID),ordersID)
	end if
  end if
end if
if FoundErr=False then
	call CloseConn()
	response.Redirect "News_Manage.asp?bigclassid="&request("bigclassid")&"&smallclassid="&request("smallclassid")&"&xinghao="&request("xinghao")&"&tw="&request("tw")&"&rd="&request("rd")&"&page="&request("page")
else
	call CloseConn()
	call WriteErrMsg()
end if

sub DelArticle(ID)
	PurviewChecked=False
	sqlDel="select * from conews where ArticleID=" & CLng(ID)
	Set rsDel= Server.CreateObject("ADODB.Recordset")
	rsDel.open sqlDel,conn,1,3
	if FoundErr=False then
		if DelUpFiles="Yes" and ObjInstalled=True then
			dim fso,strUploadFiles,arrUploadFiles
			strUploadFiles=rsDel("UploadFiles") & ""
			if strUploadFiles<>"" then
				Set fso = CreateObject("Scripting.FileSystemObject")
				if instr(strUploadFiles,"|")>1 then
					arrUploadFiles=split(strUploadFiles,"|")
					for i=0 to ubound(arrUploadFiles)
						if fso.FileExists(server.MapPath("../" & arrUploadfiles(i))) then
							fso.DeleteFile(server.MapPath("../" & arrUploadfiles(i)))
						end if
					next
				else
					if fso.FileExists(server.MapPath("../" & strUploadfiles)) then
						fso.DeleteFile(server.MapPath("../" & strUploadfiles))
					end if
				end if
				Set fso = nothing
			end if
		end if
		rsDel.delete
		rsDel.update
		set rsDel=nothing
		'conn.execute "delete from Comment where ArticleID=" & CLng(ID)
	end if
end sub

sub SetArticle(ID)
	PurviewChecked=False
	sqlSet="update conews set Passed=true where ArticleID=" & CLng(ID)
	conn.execute sqlSet
end sub

sub ReSetArticle(ID)
	PurviewChecked=False
	sqlSet="update conews set Passed=false where ArticleID=" & CLng(ID)
	conn.execute sqlSet
end sub

sub ReSetTjshow(ID)
	PurviewChecked=False
	sqlSet="update conews set Elite=true where ArticleID=" & CLng(ID)
	conn.execute sqlSet
end sub

sub ReSetReshow(ID)
	PurviewChecked=False
	sqlSet="update conews set Elite=false where ArticleID=" & CLng(ID)
	conn.execute sqlSet
end Sub

sub ReSetOrders(ID,orders)
	PurviewChecked=False
	sqlSet="update conews set orders="&orders&" where ArticleID=" & CLng(ID)
	conn.execute sqlSet
end sub
%>