📄 selfiles.asp
字号:
<!--#include file = "../Conn.asp"-->
<!--#include file = "../Inc/Cl_ClsSysTem.asp"-->
<!--#include file = "../Inc/Cl_FileIcon.asp"-->
<%
Cl.Get_WebSetting()
if Not Cl.ChkUserLogin then
Call Cl.OutErr(0,"<br /><li>您无此操作权限!</li>")
end if
if Cl.UserGroupID>1 then
Response.write "对不起,此功能只对管理员开放!"
Response.end
end if
Const PageSize=30
Dim FileType,TopDir,action
Dim Fso,FsoFile,AllFileSize
Dim ThisDir,DirFiles,DirFolder,strTitle
dim TotalPut,CurrentPage,TotalPages
Dim ChannelID,FileName,sTrSetting
action=LCase(Trim(Request("action")))
ThisDir=Trim(Request("ThisDir"))
ChannelID=Trim(Request("CID"))
FileType=LCase(Trim(Request("Type")))
CurrentPage=Trim(request("page"))
if Not IsNumeric(ChannelID) then
Response.write "错误,频道ID无效!"
Response.end
end if
Cl.Load_ChannelSetting(ChannelID)
sTrSetting=Split(Cl.Channel.selectSingleNode("@uploadsetting").text,"@")
if Not IsNumeric(CurrentPage) then CurrentPage=1
CurrentPage=Clng(CurrentPage)
FileName="SelFiles.asp?CID=" & ChannelID & "&Type=" & FileType
if Not Cl.ChkAdminLogin then
TopDir=Cl.UploadDir&"/"&sTrSetting(1)
TopDir=Replace(TopDir & "/","//","/")
else
TopDir=Cl.UploadDir
end if
strTitle="选择文件"
if ThisDir<>"" then
ThisDir=Replace(ThisDir & "/","//","/")
end if
Call Main()
Sub Main()
On Error Resume Next
Set Fso=Server.CreateObject(Trim(Cl.Web_Info(13)))
Set FsoFile = Fso.GetFolder(Server.MapPath(TopDir))
if Err or TopDir="/" then
Set FsoFile = Nothing
Response.write "找不到目录,可能参数配置错误!"
Response.end
end if
AllFileSize = FsoFile.size
Set FsoFile = Nothing
Set FsoFile = Fso.GetFolder(Server.MapPath(TopDir & ThisDir))
Dim FolderNuns,FileNums
FolderNuns=FsoFile.SubFolders.count
FileNums=FsoFile.Files.count
TotalPut=FolderNuns+FileNums
if (TotalPut mod PageSize)=0 then
TotalPages = TotalPut \ PageSize
else
TotalPages = TotalPut \ PageSize + 1
end if
if CurrentPage > TotalPages then CurrentPage=TotalPages
if CurrentPage < 1 then CurrentPage=1
%>
<html>
<head>
<title><%=strTitle%>管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../Skins/Css/Admin.Css" rel="stylesheet" type="text/css">
<base target='_self'>
</head>
<body leftmargin="0" topmargin="0">
<table border="0" cellspacing="1" cellpadding="0" align="center" class="border">
<tr class="Title">
<td align="center" colspan="2"><B><%=strTitle%>管理</B></td>
</tr>
<tr class="Title2" height="23">
<td>主 目 录:<a href="<%=FileName%>&ThisDir=" title="返回到主目录"><font color="FF0000">主目录/<%'=TopDir%></font></a></td><td align="right"><a href="<%=FileName%>&ThisDir=<%=GetUpDir%>"><font color="FF0000">↑上一目录</font></a> <a href="<%=FileName%>&ThisDir=" title="返回到主目录"><font color="FF0000">主目录</font></a></td>
</tr>
<tr class="Tdbg" height="23">
<td colspan="2">当前目录:主目录/<%=ThisDir%> 文件夹:<font color="blue"><%=FolderNuns%></font> 个,文件:<font color="blue"><%=FileNums%></font> 个</td>
</tr>
</table>
<br />
<%
if action="view" then
ViewFiles
else
SelectFiles
end if
%>
</body>
</html>
<%
Set FsoFile = Nothing
Set Fso = Nothing
End Sub
Function GetUpDir()
Dim strDir,strDir2,i
strDir=""
If ThisDir = "" then Exit Function
strDir2=ThisDir
strDir2=Split(strDir2,"/")
for i=0 to Ubound(strDir2)-1
if i<Ubound(strDir2)-1 then strDir=strDir & strDir2(i) & "/"
next
GetUpDir=strDir
End Function
Function GetFileUrl(strUrl)
dim strSaveUrl
strSaveUrl=Trim(strUrl)
if Lcase(left(strSaveUrl,Len(Cl.UpLoadDir)))=Lcase(Cl.UpLoadDir) then
strSaveUrl="{$uploaddir}" & mid(strSaveUrl,Len(Cl.UpLoadDir)+1)
elseif left(strSaveUrl,1)="/" then
strSaveUrl="{$webdir}" & mid(strSaveUrl,2)
end if
GetFileUrl=strSaveUrl
End Function
Sub SelectFiles()
Dim j,k
j=0
%>
<table border="0" cellspacing="1" cellpadding="0" align="center" class="Border">
<form name="form" method="post" >
<tr class="title">
<td width="*" align="center">文件/文件夹名</td>
<td width="80" align="center">文件大小</td>
<td width="120" align="center">修改时间</td>
<td width="80" align="center">可用操作</td>
</tr>
<%
For Each DirFolder in FsoFile.SubFolders%>
<tr class="tdbg">
<td width="*"> <a href="<%=FileName%>&ThisDir=<%=ThisDir & DirFolder.name%>"><img src="<%=Cl.WebDir%>images/fileicon/folder.gif" border=0 width="16" height="16" align="absmiddle"></a> <a href="<%=FileName%>&ThisDir=<%=ThisDir & DirFolder.name%>"><%=DirFolder.name%></a></td>
<td align="center" width="80"><%=Cl.GetSize(DirFolder.size,"b")%></td>
<td align="center" width="120"> <%=DirFolder.DateLastModified%></td>
<td align="center" width="80"><a href="<%=FileName%>&ThisDir=<%=ThisDir & DirFolder.name%>">打开</a></td>
</tr>
<%
Next
For Each DirFiles in FsoFile.Files
k=k+1
if j>=PageSize then
exit for
elseif k>PageSize*(CurrentPage-1) then
%>
<tr class="tdbg">
<td width="*">
<a href="#" onClick="window.returnValue='<%=TopDir & ThisDir & DirFiles.name%>|<%=int(DirFiles.size/1000)%>';window.close();">
<img src="<%=Cl.WebDir%>images/fileicon/<%=GetFileIcon(DirFiles.name)%>" border=0 width="16" height="16" align="absmiddle" alt="<%=DirFiles.type%>"> <%=DirFiles.name%></a></td>
<td align="center" width="80"><%=Cl.GetSize(DirFiles.size,"b")%></td>
<td align="center" width="120"><%=DirFiles.DateLastModified%></td>
<td align="center" width="80">
<a href="#" onClick="window.returnValue='<%=TopDir & ThisDir & DirFiles.name%>|<%=int(DirFiles.size/1000)%>';window.close();">选择</a> | <a href="<%=FileName%>&action=View&name=<%=DirFiles.name%>&ThisDir=<%=ThisDir%>">查看</a>
</td>
</tr>
<%
j=j+1
end if
Next
%>
<tr class="tdbg">
<td width="100%" align="center" colspan="4">
<%=Cl.ShowPage(FileName&"&ThisDir="&ThisDir,TotalPut,PageSize,"个","文件")%>
</td>
</tr>
</form>
</table>
<%
End Sub
Sub ViewFiles()
Dim sName,sFileExt,sUrl,s
sName=Trim(Request("Name"))
sFileExt = Lcase(Mid(sName, InstrRev(sName, ".") + 1))
'Response.write Server.MapPath(TopDir & ThisDir & sName)
Set DirFiles = Fso.GetFile(Server.MapPath(TopDir & ThisDir & sName))
%>
<table border="0" cellspacing="1" cellpadding="0" align="center" class="Border">
<tr class="tdbg">
<td rowspan=5 align="center" width=200>
<a href="#" onClick="window.returnValue='<%=TopDir & ThisDir & DirFiles.name%>|<%=int(DirFiles.size/1000)%>';window.close();">
<%
select case sFileExt
case "jpg","gif","bmp","png"
sUrl=TopDir & ThisDir & DirFiles.name
case "swf"
sUrl="../Images/FileIcon/b_flash.gif"
case "wmv","avi","asf","mpg"
sUrl="../Images/FileIcon/b_media.gif"
case "rm","ra","ram"
sUrl="../Images/FileIcon/b_rm.gif"
case "rar"
sUrl="../Images/FileIcon/b_rar.gif"
case "zip"
sUrl="../Images/FileIcon/b_zip.gif"
case "exe"
sUrl="../Images/FileIcon/b_exe.gif"
case else
sUrl="../Images/FileIcon/b_other.gif"
end select
response.write "<img src='" & sUrl & "' width='200' border='0' title='点此图片将选中!'></a>"
%>
</td>
<td align="right" width=100>文 件 名:</td>
<td><a href="<%=TopDir & ThisDir & DirFiles.name%>" target="_blank"><%=DirFiles.name%></a></td>
</tr>
<tr class="tdbg">
<td align="right" width=100>文件大小:</td>
<td><%=Cl.GetSize(DirFiles.size,"b")%></td>
</tr>
<tr class="tdbg">
<td align="right" width=100>文件类型:</td>
<td><%=DirFiles.type%></td>
</tr>
<tr class="tdbg">
<td align="right" width=100>修改时间:</td>
<td><%=DirFiles.DateLastModified%></td>
</tr>
<tr class="tdbg">
<td align="right" width=100>可用操作:</td>
<td><a href="#" onClick="window.returnValue='<%=TopDir & ThisDir & DirFiles.name%>|<%=int(DirFiles.size/1000)%>';window.close();">选中</a> | <a href="<%=FileName%>&ThisDir=<%=ThisDir%>">返回</a></td>
</tr>
</table>
<%
End Sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -