%@language=vbscript codepage=936 %>
<%
option explicit
response.buffer=true
Const PurviewLevel=2 '操作权限
Const CheckChannelID=0 '所属频道,0为不检测所属频道
Const PurviewLevel_Others="UpFile"
%>
<%
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=SaveUpFilesPath
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=SaveUpFilesPath
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="Admin_UploadFile.asp?UploadDir=" & UploadDir
if right(UploadDir,1)<>"/" then
UploadDir=UploadDir & "/"
end if
TruePath=Server.MapPath(UploadDir)
%>
<%
If not IsObjInstalled("Scripting.FileSystemObject") Then
Response.Write "你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能"
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 " 您现在的位置:上传文件管理 >> " & strDirName & ""
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 "
"
end if
end if
end sub
sub showContent()
dim c
FileCount=0
TotalSize_Page=0
%>
<%
end sub
sub ClearFile()
%>
清理无用的上传文件
<%
if Action="Clear" then
%>
<%
else
call DoClear()
end if
%>
<%
end sub
%>
<%
sub showpage2(sfilename,totalnumber,maxperpage)
dim n, i,strTemp
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
strTemp= "
"
response.write strTemp
end sub
sub DelFiles()
dim whichfile,arrFileName,i
whichfile=trim(Request("FileName"))
if whichfile="" then exit sub
if instr(whichfile,",")>0 then
arrFileName=split(whichfile,",")
for i=0 to ubound(arrFileName)
if left(trim(arrFileName(i)),3)<>"../" and left(trim(arrFileName(i)),1)<>"/" then
whichfile=server.MapPath(UploadDir & trim(arrFileName(i)))
set thisfile=fso.GetFile(whichfile)
thisfile.Delete True
end if
next
else
if left(whichfile,3)<>"../" and left(whichfile,1)<>"/" then
Set thisfile = fso.GetFile(server.MapPath(UploadDir & whichfile))
thisfile.Delete True
end if
end if
call main()
end sub
sub DelAll()
Set theFolder=fso.GetFolder(TruePath)
For Each theFile In theFolder.Files
theFile.Delete True
next
call main()
end sub
sub DoClear()
set rs=server.CreateObject("adodb.recordset")
if trim(request("UploadFiles"))="Yes" then
strFiles=""
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
rs.close
call DelFile_Useless(UploadDir,"文章频道的上传文件")
end if
if trim(request("UploadThumbs"))="Yes" then
strFiles=""
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
rs.close
call DelFile_Useless("UploadThumbs","图片频道的缩略图")
end if
if trim(request("UploadPhotos"))="Yes" then
strFiles=""
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
rs.close
call DelFile_Useless("UploadPhotos","图片频道的上传图片")
end if
if trim(request("UploadSoftPic"))="Yes" then
strFiles=""
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
rs.close
call DelFile_Useless("UploadSoftPic","下载频道的软件图片")
end if
if trim(request("UploadSoft"))="Yes" then
strFiles=""
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
rs.close
call DelFile_Useless("UploadSoft","下载频道的上传软件")
end if
if trim(request("UploadAdPic"))="Yes" then
strFiles=""
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
rs.close
call DelFile_Useless("UploadAdPic","网站广告的上传图片")
end if
set rs=nothing
end sub
sub DelFile_Useless(strDir,strDirName)
dim i
i=0
Set theFolder=fso.GetFolder(server.MapPath(strDir))
For Each theFile In theFolder.Files
if instr(strFiles,theFile.Name)<=0 then
theFile.Delete True
i=i+1
end if
next
response.write "操作执行成功!在 " & strDirName & " 目录中共删除了 " & i & " 个无用的文件。