<!--#include file="../../inc/config.asp"-->
<!--#include file="../../inc/conn.asp"-->
<!-- #include file="../inc/Session.asp" -->
<!-- #include file="../inc/checkrole.asp" -->
<%
dim drv,fdr,imgRelaUrl
drv=trim(request.QueryString("drv"))
fdr=trim(request.QueryString("fdr"))
if(fdr="") then
	fdr=server.MapPath("../../pic")
end if
imgRelaUrl=replace(mid(fdr,instrrev(fdr,"pic")),"\","/")
%>
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {	color: #FFFFFF;
	font-weight: bold;
}
body,td,th {
	font-size: 12px;
}
form{margin:0; padding:0;}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	font-size:12px;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
function ConfirmDel()
{
   if(confirm("确认删除?并且不能恢复！确定要删除此文件？"))
     return true;
   else
     return false;	 
}
</script>
</head>
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"0000")
'''''''''''''''''''''''''''''''''''''''''''''''
Class clsIterate

Private m_oFS


Public Property Let oFS(objOFS)
	m_oFS = objOFS
End Property
		
Public Property Get oFS()
	Set oFS = Server.CreateObject("Scripting.FileSystemObject")
End Property

Sub BuildDriveList(strDrive)
	Set oDrives = oFS.Drives
	
	For Each DrivePath in oDrives
		If DrivePath.isReady Then
			IF strDrive = DrivePath.DriveLetter Then
				
			Else
				
			End IF
			EchoB("<img src=""../images/disk.gif"" width=""16"" height=""9"">&nbsp;本地磁盘&nbsp;<a href=folder.asp?drv="& DrivePath.DriveLetter &">"& DrivePath.DriveLetter & "</a><br>")
			
		End IF
	Next
	
	Cleanup oDrives
End Sub
	

Sub BuildFolderList(objParentFolder, strCurrentPath)
	
    Dim objFolder, objSubFolder, objFile

    Set objSubFolder = objParentFolder.SubFolders
	On Error Resume Next 'Some WILL Throw Permission Denied Errors -Just Skip Em
    For Each objFolder In objSubFolder
	IF strCurrentPath = objFolder.Path Then
		
	Else
		
	End IF
		Echo("<tr bgcolor=""#FFFFFF"">")
        Echo("<td width=""40%""><img src=""../images/folder.gif"" width=""15"" height=""13"">&nbsp;<a  href=""?fdr="& objFolder.Path& """>"& objFolder.Name & "</a>"&"</td>")
		Echo("<td width=""15%""></td>")
		Echo("<td width=""20%"">文件夹</td>")
		Echo("<td width=""25%"">"&objFolder.DateLastModified &"<a href=""file.asp?deledir="& server.URLEncode(objFolder.Path)&" "" onClick=""return ConfirmDel()"">删除文件夹</a></td>")
		Echo("</tr>")
      '  BuildFolderList objFolder, strCurrentPath 'Recursive Call To Iterate Entire Drive
	  
    Next
	BuildFileList(objParentFolder)
	Cleanup objSubFolder
	Cleanup objParentFolder
End Sub

Sub BuildFileList(strFolder)
	Set oFolder = oFS.getFolder(strFolder) 'We Know it Exists so Just Get it
	dim filetype
	For Each FileName in oFolder.Files
		if(instr(FileName.Type,"GIF")>0) then
			filetype="gif.gif"
		elseif(instr(FileName.Type,"JPEG")>0) then
			filetype="jpg.gif"
		elseif(instr(FileName.Type,"HTML")>0) then
			filetype="html.gif"
		elseif(instr(FileName.Type,"ASP")>0) then
			filetype="asp.gif"
		elseif(instr(FileName.Type,"RAR")>0) then
			filetype="rar.gif"
		elseif(instr(FileName.Type,"ZIP")>0) then
			filetype="zip.gif"
		else
			filetype="unknow.gif"
		end if
		Echo("<tr bgcolor=""#FFFFFF"">")
		Echo("<td width=""40%""><img src=""../images/file/"&filetype&""" width=""16"" height=""16"">&nbsp;")
		Echo("<a href=""../../"&imgRelaUrl&"/"&FileName.Name&""" target=""_blank"">")
		Echo("<img style=""border:1px dashed #999999;"" src=""../../"&imgRelaUrl&"/"&FileName.Name&""" height=50 width=50></a>")
		Echo("<a href=file.asp?files="&server.URLEncode(FileName.Path)&">"& FileName.Name &"</a></td>")
		Echo("<td width=""15%"">"&FileName.Size&"</td>")
		Echo("<td width=""20%"">"&FileName.Type&"</td>")
		Echo("<td width=""25%"">"&FileName.DateLastModified&"&nbsp;<a href=file.asp?del="&server.URLEncode(FileName.Path)&" onClick=""return ConfirmDel()"">删除</a>")
		'Echo("<a href=""../file_mod.asp?filetype=html&file="&FileName.Path&""">Edit</a>"&"</td>")
		Echo("</tr>")
	Next
	
	Cleanup oFolder
End Sub	
  
Function downloadFile(strFile)  
strFilename = strFile
 ' clear the buffer  
 Response.Buffer = True  
 Response.Clear  
  
 ' create stream  
 Set s = Server.CreateObject("ADODB.Stream")  
 s.Open  
  
 '二进制  
 s.Type = 1  
  
 ' load in the file  
 on error resume next  
  
  
 '检查文件是否存在  
 Set fso = Server.CreateObject("Scripting.FileSystemObject")  
 if not fso.FileExists(strFilename) then  
 Response.Write("<h1>Error:</h1>" & strFilename & " does not exist<p>")  
 Response.End  
end if  
  
  
 ' 文件长度 
 Set f = fso.GetFile(strFilename)  
 intFilelength = f.size  
  
  
 s.LoadFromFile(strFilename)  
 if err then  
 Response.Write("<h1>Error: </h1>" & err.Description & "<p>")  
 Response.End  
 end if  
  
 ' send the headers to the users browser  
 Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name  
 Response.AddHeader "Content-Length", intFilelength  
 Response.CharSet = "UTF-8"  
 Response.ContentType = "application/octet-stream"  
  
 ' 输出文件流 
 Response.BinaryWrite s.Read  
 Response.Flush  
  
  
 ' 释放资源 
 s.Close  
 Set s = Nothing  
  
 set fso=nothing
 End Function    
Function Echo(str)
	Echo = Response.Write(str & vbCrLf)
End Function
	
Function EchoB(str)
	EchoB = Response.Write(str & "<BR>" & vbCrLf)
End Function
	
Sub Cleanup(obj)
	If isObject(obj) Then
		Set obj = Nothing
	End IF
End Sub
'delete file
Sub delFile(strFile)
	oFS.DeleteFile strFile
End Sub

'create folder
Sub mkDir(strFile)
	oFS.CreateFolder strFile
End Sub
'delete folder
Sub deleDir(strFile)
	oFS.DeleteFolder strFile
End Sub

End Class
%>
<body>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="../right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FF9900" style="border:1px solid #000000;">
  <tr>
    <td height="22"><div align="center"><span class="style1">◆ 文件/文件夹管理 ◆</span></div></td>
  </tr>
</table>
<%
set cls=new clsIterate

if(drv<>"") then
		Set objFS = Server.CreateObject("Scripting.FileSystemObject")
		Set oDrive = objFS.GetDrive(drv)
		Set oRootDir = oDrive.RootFolder
		'cls.Echo("<tr><td height=""22"" bgcolor=""#FFFFFF"" style=""padding:10px; line-height:20px;"">")
		cls.EchoB("<B><a href=# onClick=""javascript:history.back()"">../"&"</a></B>")
		cls.EchoB("当前位置："&drv)
		cls.Echo("<form name=""form1"" method=""post"" action=""file.asp?createfolder="&drv&":\"">")
  			cls.Echo("<input name=""folder"" type=""text"" size=""10"">")
  			cls.Echo("<input type=""submit"" name=""Submit"" value=""创建文件夹"">&nbsp;&nbsp;<input type=button value=刷新 onClick='window.location.reload();'>")
			cls.Echo("<input type=button value=上传文件 onClick='location.href=""upload.asp?updir="&server.URLEncode(drv&":\")&""";'>")
		cls.Echo("</form>")
		Call cls.BuildFolderList(oRootDir, "")		
		'cls.Echo("</td></tr>")
end if

if(fdr<>"") then
		Set objFS = Server.CreateObject("Scripting.FileSystemObject")
		Set oFolder = objFS.GetFolder(fdr)
		'cls.Echo("<tr><td height=""22"" bgcolor=""#FFFFFF"" style=""padding:10px; line-height:20px;"">")
		cls.EchoB("<table width=""100%""  border=""1""><tr><td><B><a href=# onClick=""javascript:history.back()"">../"&"</a></B>")
		cls.EchoB("当前位置："&fdr)
		cls.Echo("<form name=""form1"" method=""post"" action=""file.asp?createfolder="&fdr&""">")
  			cls.Echo("<input name=""folder"" type=""text"" size=""10"">")
  			cls.Echo("<input type=""submit"" name=""Submit"" value=""创建文件夹"">&nbsp;&nbsp;<input type=button value=刷新 onClick='window.location.reload();'>")
			cls.Echo("<input type=button value=上传文件 onClick='location.href=""upload.asp?updir="&server.URLEncode(fdr)&""";'>")
		cls.Echo("</form></td></tr></table>")		
		cls.Echo("<table width=""100%"" border=""0"" align=""center"" cellspacing=""1"" bgcolor=""#D4D0C8"">")
  		cls.Echo("<tr>")
    	cls.Echo("<td width=""40%"">名称</td>")
    	cls.Echo("<td width=""15%"">大小</td>")
    	cls.Echo("<td width=""20%"">类型</td>")
    	cls.Echo("<td width=""25%"">时间</td>")
  		cls.Echo("</tr>")
		Call cls.BuildFolderList(oFolder,"")
		cls.Echo("</table>")
		'cls.Echo("</td></tr>")
end if

cls.Cleanup oDrive
cls.Cleanup oRootDir
cls.Cleanup oFolder
cls.Cleanup objFS

set cls=nothing
%>
</table>
</body>
</html>
<%
call connclose()
%>