📄 ad_uploadfile.asp
字号:
<%@language=vbscript codepage=936 %>
<%
option explicit
response.buffer=true
Const PurviewLevel=2 '操作权限
Const CheckChannelID=0 '所属频道,0为不检测所属频道
Const PurviewLevel_Others="UpFile"
%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="ad_ChkPurview.asp"-->
<!--#include file="inc/func.asp"-->
<%
Const MaxPerPage=20
dim strFileName
dim Action
dim totalPut,CurrentPage,TotalPages
dim UploadDir,TruePath,fso,theFolder,theFile,thisfile,FileCount,TotalSize,TotalSize_Page
dim strFileType
dim sql,rs,strFiles,i
dim strDirName
Action=trim(Request("Action"))
if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
select case trim(request("UploadDir"))
case "UploadFiles"
UploadDir="UploadFiles"
strDirName="文章频道的上传文件"
sql="select UploadFiles from Article"
rs.open sql,conn,1,1
do while not rs.eof
if rs(0)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
rs.movenext
loop
case "UploadThumbs"
UploadDir="UploadThumbs"
strDirName="图片频道的缩略图"
sql="select PhotoUrl_Thumb,PhotoUrl,PhotoUrl2,PhotoUrl3,PhotoUrl4 from Photo"
rs.open sql,conn,1,1
do while not rs.eof
if rs(0)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
if rs(1)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
if rs(2)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
if rs(3)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
if rs(4)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
rs.movenext
loop
case "UploadPhotos"
UploadDir="UploadPhotos"
strDirName="图片频道的上传图片"
sql="select PhotoUrl_Thumb,PhotoUrl,PhotoUrl2,PhotoUrl3,PhotoUrl4 from Photo"
rs.open sql,conn,1,1
do while not rs.eof
if rs(0)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
if rs(1)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
if rs(2)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
if rs(3)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
if rs(4)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
rs.movenext
loop
case "UploadSoftPic"
UploadDir="UploadSoftPic"
strDirName="下载频道的软件图片"
sql="select SoftPicUrl from Soft"
rs.open sql,conn,1,1
do while not rs.eof
if rs(0)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
rs.movenext
loop
case "UploadSoft"
UploadDir="UploadSoft"
strDirName="下载频道的上传软件"
sql="select DownloadUrl1,DownloadUrl2,DownloadUrl3,DownloadUrl4 from Soft"
rs.open sql,conn,1,1
do while not rs.eof
if rs(0)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
if rs(1)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
if rs(2)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
if rs(3)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
rs.movenext
loop
case "UploadAdPic"
UploadDir="UploadAdPic"
strDirName="网站广告的上传图片"
sql="select ImgUrl from Advertisement"
rs.open sql,conn,1,1
do while not rs.eof
if rs(0)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
rs.movenext
loop
case else
UploadDir="UploadFiles"
strDirName="文章频道的上传文件"
sql="select UploadFiles from Article"
rs.open sql,conn,1,1
do while not rs.eof
if rs(0)<>"" then
strFiles=strFiles & "|" & rs(0)
end if
rs.movenext
loop
end select
rs.close
set rs=nothing
strFileName="ad_UploadFile.asp?UploadDir=" & UploadDir
if right(UploadDir,1)<>"/" then
UploadDir=UploadDir & "/"
end if
TruePath=Server.MapPath(UploadDir)
%>
<html>
<head>
<title>上传文件管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="ad_Style.css" rel="stylesheet" type="text/css">
</head>
<SCRIPT language=javascript>
function unselectall()
{
if(document.myform.chkAll.checked){
document.myform.chkAll.checked = document.myform.chkAll.checked&0;
}
}
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll")
e.checked = form.chkAll.checked;
}
}
</script>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">
<tr class="topbg">
<td height="22" colspan=2 align=center><b>上 传 文 件 管 理</b></td>
</tr>
<tr class="tdbg">
<td width="70" height="30"><strong>管理导航:</strong></td>
<td height="30"><a href="ad_UploadFile.asp?UploadDir=UploadFiles">文章频道的上传文件</a> | <a href="ad_UploadFile.asp?UploadDir=UploadThumbs">图片频道的缩略图</a> | <a href="ad_UploadFile.asp?UploadDir=UploadPhotos">图片频道的上传图片</a> | <a href="ad_UploadFile.asp?UploadDir=UploadSoftPic">下载频道的软件图片</a> | <a href="ad_UploadFile.asp?UploadDir=UploadSoft">下载频道的上传软件</a> | <a href="ad_UploadFile.asp?UploadDir=UploadAdPic"> 网站广告的上传图片</a> <br>
<a href="ad_UploadFile.asp?Action=Clear">清除无用文件</a> | </td>
</tr>
</table>
<%
If not IsObjInstalled("Scripting.FileSystemObject") Then
Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
Else
set fso=CreateObject("Scripting.FileSystemObject")
if Action="Del" then
call DelFiles()
elseif Action="DelAll" then
call DelAll()
elseif Action="Clear" or Action="DoClear" then
call ClearFile()
else
call main()
end if
end if
sub main()
if fso.FolderExists(TruePath)=False then
response.write "找不到文件夹!可能是配置有误!"
exit sub
end if
response.write "<br>您现在的位置:<a href='ad_UploadFile.asp'>上传文件管理</a> >> <a href='ad_UploadFile.asp?UploadDir=" & UploadDir & "'><font color=red>" & strDirName & "</font></a>"
FileCount=0
TotalSize=0
Set theFolder=fso.GetFolder(TruePath)
For Each theFile In theFolder.Files
FileCount=FileCount+1
TotalSize=TotalSize+theFile.Size
next
totalPut=FileCount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage2 strFileName,totalput,MaxPerPage
response.write "<br><div align='center'>本页共显示 <b>" & FileCount & "</b> 个文件,占用 <b>" & TotalSize_Page\1024 & "</b> K</div>"
else
if (currentPage-1)*MaxPerPage<totalPut then
showContent
showpage2 strFileName,totalput,MaxPerPage
response.write "<br><div align='center'>本页共显示 <b>" & FileCount & "</b> 个文件,占用 <b>" & TotalSize_Page\1024 & "</b> K</div>"
else
currentPage=1
showContent
showpage2 strFileName,totalput,MaxPerPage
response.write "<br><div align='center'>本页共显示 <b>" & FileCount & "</b> 个文件,占用 <b>" & TotalSize_Page\1024 & "</b> K</div>"
end if
end if
end sub
sub showContent()
dim c
FileCount=0
TotalSize_Page=0
%>
<br>
<table width='100%' border="0" cellpadding="0" cellspacing="0">
<tr>
<form name="myform" method="Post" action="ad_UploadFile.asp" onsubmit="return confirm('确定要删除选中的文件吗?');">
<td>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="3" class="border">
<tr class="tdbg">
<%
For Each theFile In theFolder.Files
c=c+1
if FileCount>=MaxPerPage then
exit for
elseif c>MaxPerPage*(CurrentPage-1) then
%>
<td>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td colspan="2" align="center">
<%
strFileType=lcase(mid(theFile.Name,instrrev(theFile.Name,".")+1))
response.write "<a href='" & UploadDir & theFile.Name & "'>"
select case strFileType
case "jpg","gif","bmp","png"
if instr(strFiles,theFile.Name)>0 then
response.write "<img src='" & UploadDir & theFile.Name & "' width='140' height='100' border='0'></a>"
else
response.write "<img src='" & UploadDir & theFile.Name & "' width='140' height='100' border='2' Title='无用的上传文件'></a>"
end if
case "swf"
if instr(strFiles,theFile.Name)>0 then
response.write "<img src='images/filetype_flash.gif' width='140' height='100' border='0'></a>"
else
response.write "<img src='images/filetype_flash.gif' width='140' height='100' border='2' Title='无用的上传文件'></a>"
end if
case "wmv","avi","asf","mpg"
if instr(strFiles,theFile.Name)>0 then
response.write "<img src='images/filetype_media.gif' width='140' height='100' border='0'></a>"
else
response.write "<img src='images/filetype_media.gif' width='140' height='100' border='2' Title='无用的上传文件'></a>"
end if
case "rm","ra","ram"
if instr(strFiles,theFile.Name)>0 then
response.write "<img src='images/filetype_rm.gif' width='140' height='100' border='0'></a>"
else
response.write "<img src='images/filetype_rm.gif' width='140' height='100' border='2' Title='无用的上传文件'></a>"
end if
case "rar"
response.write "<img src='images/filetype_rar.gif' width='140' height='100' border='0'></a>"
case "zip"
response.write "<img src='images/filetype_zip.gif' width='140' height='100' border='0'></a>"
case "exe"
response.write "<img src='images/filetype_exe.gif' width='140' height='100' border='0'></a>"
case else
if instr(strFiles,theFile.Name)>0 then
response.write "<img src='images/filetype_other.gif' width='140' height='100' border='0'></a>"
else
response.write "<img src='images/filetype_other.gif' width='140' height='100' border='2' Title='无用的上传文件'></a>"
end if
end select
%>
</td>
</tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -