<!--#include file="../../inc/config.asp"-->
<!--#include file="../../inc/conn.asp"-->
<!-- #include file="../inc/Session.asp" -->
<!-- #include file="../inc/checkrole.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {	color: #FFFFFF;
	font-weight: bold;
}
body,td,th {
	font-size: 15px;
}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</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"),"p15")
'''''''''''''''''''''''''''''''''''''''''''''''
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("<img src=""../images/folder.gif"" width=""15"" height=""13"">&nbsp;<a  href=""folder_mb.asp?fdr="& objFolder.Path& """>"& objFolder.Path & "</a>")
		EchoB("&nbsp;<a href=file.asp?deledir="& objFolder.Path&" onClick=""return ConfirmDel()"">删除文件夹</a>")
      '  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
	
	For Each FileName in oFolder.Files
		Echo("<img src=""../images/file.gif"" width=""16"" height=""16"">&nbsp;<a href=file.asp?files="&FileName.Path&">"& FileName.Path &"</a>")
		Echo("时间:"&FileName.DateLastModified)
		Echo("&nbsp;<a href=file.asp?del="&FileName.Path&" onClick=""return ConfirmDel()"">删除文件</a>")
		EchoB("&nbsp;<a href=""../file_mod.asp?filetype=html&file="&FileName.Path&""">修改文件</a>")
	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>
<%
dim drv,fdr

set cls=new clsIterate
drv=trim(request.QueryString("drv"))
fdr=trim(request.QueryString("fdr"))
if(fdr="") then
fdr=server.MapPath("../../templet")
end if
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.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("<B><a href=# onClick=""javascript:history.back()"">../"&"</a></B>")	
		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>")
		cls.Echo("</form>")
		Call cls.BuildFolderList(oFolder,"")
		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()
%>