<% Option Explicit %>
<!--#include file="../../Inc/Function.asp" -->
<!--#include file="../../Inc/Const.asp" -->
<!--#include file="../../Inc/Cls_DB.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P0602") then Call ReturnError1()
Dim Path,FileName,OType,FsoObj,FolderObj,SubFolderObj,FolderItem,ReturnValue
OType = Request("Type")
FileName = Request("FileName")
Path = Server.MapPath(Replace(Request("Path"),"//","/"))
if OType <> "" then
	Set FsoObj = Server.CreateObject("Scripting.FileSystemObject")
	if OType = "Del" then
		if Path <> "" then
			if FileName <> "" then
				FileName = Path &"\"& FileName
				if FsoObj.FileExists(FileName) = True then
					FsoObj.DeleteFile FileName
					Response.Write("<script>alert(""文件删除成功"");window.close();</script>")
					Response.End
				else
					Response.Write("<script>alert(""未找到文件"");window.close();</script>")
					Response.End
				end if
			else
				if FsoObj.FolderExists(Path) = True then
					FsoObj.DeleteFolder Path
					Response.Write("<script>alert(""文件夹删除成功"");window.close();</script>")
					Response.End
				else
					Response.Write("<script>alert(""未找到文件夹"");window.close();</script>")
					Response.End
				end if
			end if
		else
			Response.Write("<script>alert(""参数传递错误,请刷新页面后重试"");window.close();</script>")
			Response.End
		end if
	elseif OType = "AddFolder" then
		if FsoObj.FolderExists(Path) = True then
			Response.Write("<script>alert(""新建目录名称已经存在"");window.close();</script>")
			Response.End
		else
			FsoObj.CreateFolder Path
			Response.Write("<script>alert(""新建目录成功"");window.close();</script>")
			Response.End
		end if
	elseif OType = "ExtendFolder" then
		ReturnValue = ""
		Set FolderObj = FsoObj.GetFolder(Path)
		Set SubFolderObj = FolderObj.SubFolders
		for Each FolderItem In SubFolderObj
			if ReturnValue = "" then
				ReturnValue = FolderItem.Name
			else
				ReturnValue = ReturnValue & "$" & FolderItem.Name
			end if
		next
		if ReturnValue <> "" then
			Response.Write(EnCodeResponseStr(ReturnValue))
		else
			Response.Write(ReturnValue)
		end if
	else
		Response.Write("<script>alert(""参数传递错误,请刷新页面后重试"");window.close();</script>")
		Response.End
	end if
	Set FsoObj = Nothing
else
	Response.Write("<script>alert(""参数传递错误,请刷新页面后重试"");window.close();</script>")
	Response.End
end if

Function EnCodeResponseStr(Str)
	Dim i
	for i = 1 to Len(Str)
		if EnCodeResponseStr = "" then
			EnCodeResponseStr = AscW(Mid(Str,i,1))
		else
			EnCodeResponseStr = EnCodeResponseStr & "*" & AscW(Mid(Str,i,1))
		end if
	Next
End Function
%>