<!--#include file="../../Conn.asp" -->
<!--#include file="../YWNT_TMS_inc/YWNT_TMS_Function.asp" -->
<%IF Session("Admin")="" and Session("AdminGroup")="" and Session("AdminSession")<>true Then
	Response.write "<script>top.location.href='Admin_Login.asp'</script>"
END IF
call Execute()
		'主体部分
		Sub Execute()
		Dim CurrPath, FsoObj, SubFolderObj, FolderObj, FileObj, I, FsoItem, OType
		Dim ParentPath, FileExtName, AllowShowExtNameStr
		Dim ShowVirtualPath
		Dim CanBackFlag
		Set FsoObj = Server.CreateObject("Scripting.FileSystemObject")
		Dim WebiInstallDir, UpFilesDir
		
		WebiInstallDir = GetConfig("WebiInstallDir")
		UpFilesDir = WebiInstallDir
		
		On Error Resume Next
		OType = Request("Type")
		If OType <> "" Then
			Dim Path, PhysicalPath
			If OType = "DelFolder" Then
				Path = Request("Path")
				If Path <> "" Then
					Path = Server.MapPath(Path)
					If FsoObj.FolderExists(Path) = True Then FsoObj.DeleteFolder Path
				End If
			ElseIf OType = "DelFile" Then
				Dim DelFileName
				Path = Request("Path")
				DelFileName = Request("FileName")
				If (DelFileName <> "") And (Path <> "") Then
					Path = Server.MapPath(Path)
					If FsoObj.FileExists(Path & "\" & DelFileName) = True Then FsoObj.DeleteFile Path & "\" & DelFileName
				End If
			ElseIf OType = "AddFolder" Then
				Path = Request("Path")
				If Path <> "" Then
					Path = Server.MapPath(Path)
					If FsoObj.FolderExists(Path) = True Then
						Response.Write ("<script>alert('对不起，目录已经存在！');</script>")
					Else
						FsoObj.CreateFolder Path
					End If
				End If
			ElseIf OType = "FileReName" Then
				Dim NewFileName, OldFileName
				Path = Request("Path")
				If Path <> "" Then
					NewFileName = Request("NewFileName")
					OldFileName = Request("OldFileName")
					If (NewFileName <> "") And (OldFileName <> "") Then
						PhysicalPath = Server.MapPath(Path) & "\" & OldFileName
						If FsoObj.FileExists(PhysicalPath) = True Then
							PhysicalPath = Server.MapPath(Path) & "\" & NewFileName
							If FsoObj.FileExists(PhysicalPath) = False Then
								Set FileObj = FsoObj.GetFile(Server.MapPath(Path) & "\" & OldFileName)
								FileObj.name = NewFileName
								Set FileObj = Nothing
							End If
						End If
					End If
				End If
			ElseIf OType = "FolderReName" Then
				Dim NewPathName, OldPathName
				Path = Request("Path")
				If Path <> "" Then
					NewPathName = Request("NewPathName")
					OldPathName = Request("OldPathName")
					If (NewPathName <> "") And (OldPathName <> "") Then
						PhysicalPath = Server.MapPath(Path) & "\" & OldPathName
						If FsoObj.FolderExists(PhysicalPath) = True Then
							PhysicalPath = Server.MapPath(Path) & "\" & NewPathName
							If FsoObj.FolderExists(PhysicalPath) = False Then
								Set FileObj = FsoObj.GetFolder(Server.MapPath(Path) & "\" & OldPathName)
								FileObj.name = NewPathName
								Set FileObj = Nothing
							End If
						End If
					End If
				End If
			End If
		End If
		
		AllowShowExtNameStr = "jpg,txt,gif,bmp"
		CurrPath = Request("CurrPath")
			ParentPath = Mid(CurrPath, 1, InStrRev(CurrPath, "/") - 1)
			If ParentPath = "" Then
				ParentPath = WebiInstallDir
			End If
		Set FolderObj = FsoObj.GetFolder(Server.MapPath(CurrPath))
		Set SubFolderObj = FolderObj.SubFolders
		Set FileObj = FolderObj.Files
		
		
		Response.Write "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"">"
		Response.Write "<html>"
		Response.Write "<head>"
		Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
		Response.Write "<title>文件和目录列表</title>"
		Response.Write "</head>"
		Response.Write "<link href=""Admin_Style.CSS"" rel=""stylesheet"">"
		Response.Write "<body topmargin=""0"" leftmargin=""0"" onClick=""SelectFolder();"">"
		Response.Write "<table width=""99%"" border=""0"" align=""center"" cellpadding=""2"" cellspacing=""0"">"
		Response.Write "  <tr>"
		Response.Write "    <td width=""70%"" class=""sort"" align=""center"">文件/文件夹名</td>"
		Response.Write "    <td width=""30%"" class=""sort"" align=""center"">大小</td>"
		Response.Write "  </tr>"
		 
		   If (CurrPath <> WebiInstallDir & Left(UpFilesDir, Len(UpFilesDir) - 1)) And (ParentPath <> "") Then
			 CanBackFlag = 1 '设置状态为可返回
		  
		Response.Write "  <tr title=""上级目录" & ParentPath & """>"
		Response.Write "    <td><table width=""117"" border=""0"" cellpadding=""0"" cellspacing=""0"">"
		Response.Write "        <tr>"
		Response.Write "          <td width=""24""><font color=""#FFFFFF""><img src=""Folder/arrow.gif""></font></td>"
		Response.Write "          <td><span onClick=""SelectUpFolder(this);"" onDblClick=""OpenParentFolder();"">返回上级目录</span></td>"
		Response.Write "        </tr>"
		Response.Write "      </table></td>"
		Response.Write "    <td></td>"
		Response.Write "  </tr>"
		
		 Else
		 CanBackFlag = 0  '设置状态为不可返回
		End If
		For Each FsoItem In SubFolderObj
		
		Response.Write "  <tr>"
		Response.Write "    <td width=""30%""><table border=""0"" cellspacing=""0"" cellpadding=""0"">"
		Response.Write "        <tr title=""双击鼠标进入此目录"">"
		Response.Write "          <td  width=""24""><img src=""Folder/folderclosed.gif""></td>"
		Response.Write "         <td> <span class=""FolderItem"" Path=""" & FsoItem.name & """ onDblClick=""OpenFolder(this);"">"
		Response.Write FsoItem.name
		Response.Write "            </span> </td>"
		Response.Write "        </tr>"
		Response.Write "      </table></td>"
		Response.Write "    <td><div align=""Right"">"
		Response.Write FsoItem.size
		Response.Write "      字节 </div></td>"
		Response.Write "  </tr>"
		
		Next
		For Each FsoItem In FileObj
			FileExtName = LCase(Mid(FsoItem.name, InStrRev(FsoItem.name, ".") + 1))

		
		Response.Write "  <tr>"
		Response.Write "    <td width=""30%""><table border=""0"" cellspacing=""0"" cellpadding=""0"">"
		Response.Write "        <tr title=""双击鼠标进入此目录"">"
		Response.Write "          <td  width=""24""><img src='fileicon/"&GetFileIcon(FsoItem.name)&"' border=0 width=""16"" height=""16"" align=""absmiddle"" alt='"& FsoItem.Type&"'</td>"
		Response.Write "         <td> <span class=""FolderItem"" File=""" & FsoItem.name & """ onDblClick=""SetFile(this);"" onClick=""SelectFile(this);"">"
		Response.Write FsoItem.name
		Response.Write "            </span> </td>"
		Response.Write "        </tr>"
		Response.Write "      </table></td>"
		Response.Write "    <td><div align=""Right"">"
		Response.Write FsoItem.size
		Response.Write "        &nbsp;字节 </div></td>"
		Response.Write "  </tr>"
		
		Next
		
		Response.Write "</table>"
		Response.Write "</body>"
		Response.Write "</html>"
		
		Set FsoObj = Nothing
		Set SubFolderObj = Nothing
		Set FileObj = Nothing
		
		Response.Write "<script language=""JavaScript"">" & vbCrLf
		Response.Write "var CurrPath='" & CurrPath & "';" & vbCrLf
		Response.Write "var Hypothesized='" & WebiInstallDir & "';" & vbCrLf
		Response.Write "var ParentPath='" & ParentPath & "';" & vbCrLf
		Response.Write "var CanBackFlag=" & CanBackFlag & ";" & vbCrLf
		Response.Write "</script>"
		Response.Write "<script src=""FolderFIleList.JS"" language=""javascript""></script>"
		End Sub
		Function CheckFileShowTF(AllowShowExtNameStr, ExtName)
			If ExtName = "" Then
				CheckFileShowTF = False
			Else
				If InStr(1, AllowShowExtNameStr, ExtName) = 0 Then
					CheckFileShowTF = False
				Else
					CheckFileShowTF = True
				End If
			End If
		End Function
		
	Function GetFileIcon(strFilename)
	strFilename=Split(LCase(strFilename),".")
	Select Case strFilename(Ubound(strFilename))
	Case "asp"
		GetFileIcon="asp.gif"
	Case "aspx"
		GetFileIcon="asp.gif"
	Case "jsp"
		GetFileIcon="asp.gif"
	Case "html"
		GetFileIcon="html.gif"
	Case "shtml"
		GetFileIcon="html.gif"
	Case "htm"
		GetFileIcon="html.gif"
	Case "shtm"
		GetFileIcon="html.gif"
	Case "xml"
		GetFileIcon="xml.gif"
	Case "bmp"
		GetFileIcon="bmp.gif"
	Case "doc"
		GetFileIcon="doc.gif"
	Case "gif"
		GetFileIcon="gif.gif"
	Case "ico"
		GetFileIcon="ico.gif"
	Case "jpg"
		GetFileIcon="jpg.gif"
	Case "js"
		GetFileIcon="js.gif"
	Case "mdb"
		GetFileIcon="mdb.gif"
	Case "mp3"
		GetFileIcon="media.gif"
	Case "wma"
		GetFileIcon="media.gif"
	Case "mid"
		GetFileIcon="media.gif"
	Case "png"
		GetFileIcon="png.gif"
	Case "rar"
		GetFileIcon="rar.gif"
	Case "swf"
		GetFileIcon="swf.gif"
	Case "txt"
		GetFileIcon="txt.gif"
	Case "xls"
		GetFileIcon="xls.gif"
	Case "xlt"
		GetFileIcon="xlt.gif"
	Case "zip"
		GetFileIcon="zip.gif"
	Case "exe"
		GetFileIcon="exe.gif"
	Case "dll"
		GetFileIcon="dll.gif"
	Case Else
		GetFileIcon="other.gif"
	End Select
End Function
%>