<!--#include file="Config.asp" -->
<!--#include file="../inc/fso.asp"-->
<div class='menu'>&nbsp;文件管理器 <font color="red">请慎重操作，删除后不可恢复！</font></div>
<%
Mgt("p99") 'Cookies : Permission
fPath="../attached/"
if trim(request("fPath"))<>"" then fPath=trim(request("fPath"))

if action="Del" then
xPath=trim(request("xPath"))
yPath=trim(request("yPath"))
fSize=csng(request("fSize"))
if xPath="" and yPath="" then WtMsg("路径错误！")
'删除文件夹 'isFolder(folder)
if xPath<>"" then 
if fSize>0 then WtMsg("请清空该文件夹中的文件再删除此文件夹！")
DelFolder(xPath)
end if
'删除文件
if yPath<>"" then DelFile(yPath) 'isFile(tfile)
end if

Path2=split(fPath,"/")
ParentPath=left(fPath,len(fPath)-(len(Path2(ubound(Path2)-1))+1))
%> 
<div class="title">
  <table width='100%' border='0' cellspacing='1' cellpAdding='1'>
      <tr>
        <td style="font-weight:normal; padding:3px; color:#000" bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
		当前路径：[<a href='?fPath=<%=fPath%>'><%=fPath%></a>] &gt; 
		<%if len(fPath)>12 then%>
		返回上级目录：[<a href="?fPath=<%=ParentPath%>"><%=ParentPath%></a>] &gt; 
		<%end if%>
		以下是此文件夹的所有文件：
	</td>
    <td>&nbsp;</td>
    <td align="right"><iframe src="Upload.asp?eType=file&fField=Photo" scrolling="no" frameborder="0" width="300" height="25"></iframe>
	<input type="hidden" name="Photo" size="50" value="<%=Photo%>"></td>
  </tr>
</table>
		</td>
      </tr>
      <tr>
        <td style="font-weight:normal;">
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fileobj = fso.GetFolder(server.mappath(fPath))
Set fsofolders = fileobj.SubFolders
Set fsofile = fileobj.Files

For Each folder in fsofolders
   response.Write("<span style='width:120px; margin:3px; float:left;'><a href='?fPath="&fPath&folder.name&"/'>"&folder.name&"-["&Round(folder.size/1024)&"KB]</a>")
   response.Write("-<a href='?action=Del&xPath="&fPath&folder.name&"/&fSize="&Round(folder.size/1024)&"'>删</a></span>")
Next 
%>
		</td>
      </tr>
  </table>
</div>

<%
Const FsoString="Scripting.FileSystemObject"	'FSO字符串
PageSize=20  '每页显示数
Function ShowPage(ByRef PageCount,RecordCount,CurrentPage,PageSize,LinkFile)
	Dim Retval,J,StartPage,EndPage
	If (RecordCount Mod PageSize)=0 Then
	    PageCount=RecordCount \ PageSize
	Else 
	    PageCount=RecordCount \ PageSize+1
	End If
	If PageCount=0 Then PageCount=1
	If CurrentPage="" Then CurrentPage=1 else CurrentPage=CInt(CurrentPage)
	If CurrentPage=1 Then              
		Retval=Retval & "&nbsp;首页 | 前页 | " 
	Else
		Retval=Retval & "<a href='" & LinkFile & "Page=1'>首页</a> | <a href='" & LinkFile & "Page=" & CurrentPage - 1 & "'>前页</a> | "
	End If
	If  CurrentPage=PageCount Then             
		Retval=Retval & "后页 | 末页"
	Else
		Retval=Retval & "<a href='" & LinkFile & "Page=" & CurrentPage + 1 & "'>后页</a> | <a href='" & LinkFile & "Page=" & PageCount & "'>末页</a>"
	End if
	If RecordCount>0 Then
	    Retval=Retval & " | "&CurrentPage&"页/"&CInt(PageCount)&"页 | 共"&RecordCount&"条记录"
	End If
	ShowPage=Retval
End Function

Dim Sfor(30,2)
Call Main()
Sub Main()
    Dim Folder,Num,FileCount
    sFor(0,0)="txt":sFor(0,1)="txt"
    sFor(1,0)="chm":sFor(1,1)="chm"
    sFor(2,0)="hlp":sFor(2,1)="chm"
    sFor(3,0)="doc":sFor(3,1)="doc"
    sFor(4,0)="pdf":sFor(4,1)="pdf"
    sFor(5,0)="gif":sFor(5,1)="gif"
    sFor(6,0)="jpg":sFor(6,1)="jpg"
    sFor(7,0)="png":sFor(7,1)="png"
    sFor(8,0)="bmp":sFor(8,1)="bmp"
    sFor(9,0)="asp":sFor(9,1)="asp"
    sFor(10,0)="jsp":sFor(10,1)="asp"
    sFor(11,0)="js" :sFor(11,1)="asp"
    sFor(12,0)="htm":sFor(12,1)="html"
    sFor(13,0)="html":sFor(13,1)="html"
    sFor(14,0)="shtml":sFor(14,1)="html"
    sFor(15,0)="zip":sFor(15,1)="zip"
    sFor(16,0)="rar":sFor(16,1)="rar"
    sFor(17,0)="exe":sFor(17,1)="exe"
    sFor(18,0)="avi":sFor(18,1)="avi"
    sFor(19,0)="mpg":sFor(19,1)="mpg"
    sFor(20,0)="ra" :sFor(20,1)="ra"
    sFor(21,0)="ram":sFor(21,1)="ra"
    sFor(22,0)="mid":sFor(22,1)="mid"
    sFor(23,0)="wav":sFor(23,1)="wav"
    sFor(24,0)="mp3":sFor(24,1)="mp3"
    sFor(25,0)="asf":sFor(25,1)="asf"
    sFor(26,0)="php":sFor(26,1)="aspx"
    sFor(27,0)="php3":sFor(27,1)="aspx"
    sFor(28,0)="aspx":sFor(28,1)="aspx"
    sFor(29,0)="xls":sFor(29,1)="xls"
    sFor(30,0)="mdb":sFor(30,1)="mdb"
%>
<!-- 主要内容开始 -->
<div class="content">
  <table width='100%' border='0' cellspacing='1' cellpAdding='1' align='center' class="table">
    <tr align='center'>
      <td Width="6%" align="center"><div class="title">类型</div></td>
      <td Width="51%" align="center"><div class="title">文件地址</div></td>
      <td Width="13%" align="center"><div class="title">大小</div></td>
      <td Width="23%" align="center"><div class="title">上传日期</div></td>
      <td Width="7%" align="center"><div class="title">管理</div></td>
    </tr>
    <%
	On Error Resume Next
    Set objFSO=Server.CreateObject(FsoString)
	If Err.Number=-2147221005 Then 
	    Response.Write "<Tr><Td Colspan=5 align='center'>非常遗憾,您的主机不支持FSO("&FsoString&"),不能使用该功能</Td></Tr>"
	    Err.Clear
	    Response.End
	End If

    Set Folder=objFSO.Getfolder(Server.Mappath(fPath))
    If Err.Number<>0 Then
    Response.Write "<Tr><Td Colspan=5>"&Err.Description&"</Td></Tr>"
    Response.End
    End If
    Set Num=Folder.Files

    FileCount=num.count
    pagecount=int(FileCount/PageSize)

    Page=Request.QueryString("Page")
    If Page="" Or Page<1 Then 
       Page=1
    Else
       Page=Cint(Page)
    End If 

	If FileCount Mod PageSize=0 Then
	    PageCount= FileCount \ Cint(PageSize)
	Else
	    PageCount= FileCount \ Cint(PageSize)+1
  	End If

  	i=0
  	Dim CSS
  	For Each FileName In folder.files
  	  	i=i+1
  	  	If i>(Page-1)*PageSize And i<=Page*PageSize Then
		imgstr=""
		'if instr(fPath,"image")>0 then imgstr="<img src='"&fPath&FileName.name&"' height='80' align='absmiddle'>"
%>
    <tr onMouseOver='trOver(this)' onMouseOut='trOut(this)'>
      <td align=center><%=procGetFormat(FileName.name)%></td>
      <td><%="<a href="&fPath&FileName.name&" target=_blank>"&imgstr&FileName.name&"</a>"%></td>
      <td align=center><%=formatnumber(FileName.size/1024)%> KB</td>
      <td align=center><%=FileName.datecreated%></td>
      <td align=center><a href='?action=Del&yPath=<%=fPath&FileName.name%>&fSize=<%=formatnumber(FileName.size/1024)%>&fPath=<%=fPath%>' onClick="return confirm('确定要删除吗？删除后不可恢复！')">删除</a></td>
    </tr>
    <%
  	  	ElseIf i>Page*PageSize Then Exit For
  	  	End If
  	Next
%>
    <tr bgcolor='#ffffff'>
      <td colspan="5"><div class="title">
          <%Response.Write "共计：<b><font color=#FF0000>"&FormatNumber(folder.size/1024,2)&"</font> k</b>"%>
        </div></td>
    </tr>
  </table>
  <div class="page">
    <%Response.Write ShowPage(PageCount,FileCount,Page,PageSize,"?fPath="&fPath&"&")%>
  </div>
</div>
<%
    Set objFSO=Nothing
    Set Folder=Nothing
End Sub

Function Procgetformat(Sname)
    Dim I,Str
    Procgetformat=0
    If Instrrev(Sname,".")=0 Then Exit Function
    Str=Lcase(Mid(Sname,Instrrev(Sname,".")+1))
    For I=0 To Ubound(Sfor,1)
        If Str=Sfor(I,0) Then 
            Procgetformat=Sfor(I,1)
            Exit For
        End If
    Next
End Function
%>
</div>
</body>
</html>
