?? admin_uploadfile.asp
字號(hào):
<!--#include file="conn.asp"-->
<!--#include file="Admin_ChkPass.asp"-->
<!--#include file="inc/function.asp"-->
<%
const MaxPerPage=20
dim strFileName
dim totalPut,CurrentPage,TotalPages
dim rs, sql
dim userid,UserSearch,Keyword,strField
dim tmpDays,action
dim uppath,fso,thefile
dim del,fn,fn_userid,delmore
dim usermore
fn=trim(request("fn"))
fn_userid=trim(request("fn_userid"))
del=trim(request.QueryString("del"))
userid=trim(request.QueryString("userid"))
delmore=trim(request.QueryString("delmore"))
usermore=trim(request.QueryString("usermore"))
set rs=conn.execute("select upfile_path from bloginfo")
set fso=CreateObject("Scripting.FileSystemObject")
uppath=rs(0)
keyword=trim(request("keyword"))
if keyword<>"" then
keyword=ReplaceBadChar(keyword)
end if
UserSearch=trim(request("UserSearch"))
Action=trim(request("Action"))
if UserSearch="" then
UserSearch=0
else
UserSearch=Clng(UserSearch)
end if
strFileName="Admin_uploadfile.asp?UserSearch=" & UserSearch
if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if
dim upstr
if issqldate then
upstr="where datalength(upfiles)>0"
else
upstr="where upfiles<>''"
end if
%>
<html>
<head>
<title>上傳文件管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css">
<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>
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<br>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">
<tr class="topbg">
<td height="22" colspan=2 align=center><strong>上傳文件管理(文件列表)</strong></td>
</tr>
<form name="form1" action="admin_user.asp" method="get">
<tr class="tdbg">
<td width="100" height="30"><strong>管理導(dǎo)航:</strong></td>
<td width="687" height="30"> <a href="admin_uploadfile_user.asp">上傳文件管理用戶列表</a> | <a href="admin_uploadfile.asp">上傳文件管理文件列表</a></td>
</tr>
</form>
</table>
<br>
<%
if del<>"" then
call Delfile()
else
if delmore="true" then
call Delfilemore()
end if
call main()
end if
call CloseConn()
sub main()
dim theFolder,filecount,totalsize
if fso.FolderExists(Server.MapPath(uppath))=False then
response.write "找不到文件夾!可能是配置有誤!"
exit sub
end if
dim strGuide
strGuide="<table width='98%' align='center'><tr><td align='left'>您現(xiàn)在的位置:<a href='Admin_User.asp'>上傳文件管理--文件清單</a> >> "
if usermore="" then
if Keyword="" then
sql="select upfiles,username,userid from [user] "&upstr&" order by userID desc"
strGuide=strGuide & "所有文件"
else
sql="select upfiles,username,userid from [user] "&upstr&" and userName like '%" & Keyword & "%' order by userID desc"
strGuide=strGuide & "用戶名中含有“ <font color=red>" & Keyword & "</font> ”的用戶"
end if
else
sql="select upfiles,username,userid from [user] "&upstr&" and userid="&usermore&" order by userID desc"
strGuide=strGuide & "ID為“ <font color=red>" & usermore & "</font> ”的用戶"
end if
strGuide=strGuide & "</td><td align='right'>"
'response.Write(sql)
Set rs=Server.CreateObject("Adodb.RecordSet")
rs.Open sql,Conn,1,1
if rs.eof and rs.bof then
strGuide=strGuide & "共找到 <font color=red>0</font> 個(gè)文件</td></tr></table>"
response.write strGuide
else
totalPut=rs.recordcount
strGuide=strGuide & "共找到 <font color=red>" & totalPut & "</font> 個(gè)用戶</td></tr></table>"
response.write strGuide
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
showpage strFileName,totalput,MaxPerPage,true,true,"個(gè)文件"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"個(gè)文件"
else
currentPage=1
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"個(gè)文件"
end if
end if
end if
rs.Close
set rs=Nothing
call ShowSearch()
end sub
sub showContent()
dim i,fileinfo
i=0
%>
<table width='98%' border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<form name="myform" method="Post" action="Admin_uploadfile.asp?delmore=true" onsubmit="return confirm('確定要執(zhí)行選定的操作嗎?');">
<td>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
<tr class="title">
<td width="30" align="center"><font color="#FFFFFF">選中</font></td>
<td width="160" align="center"><font color="#FFFFFF">文件名</font></td>
<td width="83" height="22" align="center"><font color="#FFFFFF"> 所屬用戶</font></td>
<td width="80" height="22" align="center"><font color="#FFFFFF">文件大小</font></td>
<td width="135" align="center"><font color="#FFFFFF">上傳時(shí)間</font></td>
<td width="45" height="22" align="center"><font color="#FFFFFF">
操作</font></td>
</tr>
<%do while not rs.EOF
dim sfile,n
if rs("upfiles")<>"" then
sfile=split(rs("upfiles"),"|")
for n=0 to ubound(sfile)
if fso.FileExists(Server.MapPath(uppath&"/"&sfile(n))) then
Set fileinfo = fso.GetFile(Server.MapPath(uppath)&"/"&sfile(n))
%>
<tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'">
<td width="30" align="center"><input name='fn' type='checkbox' onclick="unselectall()" id="fn" value='<%=sfile(n)%>'>
<input name='fn_userid' type="hidden" id="fn_userid" value='<%=rs("userid")%>'>
</td>
<td width="160" align="center"><a href=<%=uppath&"/"&sfile(n)%> target="_blank"><%=sfile(n)%></a></td>
<td width="83" align="center"><a href=blog.asp?name=<%=rs("username")%> target="_blank"><%=rs("username")%></a></td>
<td align="center"> <%=round(fileinfo.size/1024)&"K"%></td>
<td align="center"><%=fileinfo.DateLastModified %></td>
<td width="45" align="center"><%
response.write "<a href='Admin_uploadfile.asp?del="&sfile(n)&"&userid="&rs("userid")&"'>刪除</a> "
%> </td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
end if
next
end if
rs.movenext
loop
%>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="200" height="30"><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
選中本頁顯示的所有文件</td>
<td> <strong>操作:</strong>
<input name="Action" type="radio" value="Del" checked onClick="document.myform.UserLevel.disabled=true">
刪除
<input type="submit" name="Submit" value=" 執(zhí) 行 "> </td>
</tr>
</table>
</td>
</form></tr></table>
<%
end sub
sub showsearch()
%>
<form name="form2" method="post" action="Admin_uploadfile.asp">
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
<tr class="tdbg">
<td width="184">按用戶名查詢<strong>:</strong></td>
<td width="236">
<input name="Keyword" type="text" id="Keyword" size="20" maxlength="30">
<input type="submit" name="Submit2" value=" 查 詢 ">
<input name="UserSearch" type="hidden" id="UserSearch" value="10">
</td>
<td width="346">若為空,則查詢所有用戶</td>
</tr>
</table>
</form>
<%end sub
sub delfile()
del=trim(del)
dim fn_size,fileinfo
if fso.FileExists(Server.MapPath(uppath&"/"&del)) then
Set fileinfo = fso.GetFile(Server.MapPath(uppath)&"/"&del)
fn_size=fileinfo.size
fso.DeleteFile Server.MapPath(uppath&"/"&del)
end if
set rs=server.createobject("adodb.recordset")
rs.open "select upfiles,upfiles_size from [user] where userid="&userid,conn,1,3
if not rs.eof then
if instr(rs(0),"|"&del)>1 then
rs(0)=replace(rs(0),"|"&del,"")
elseif instr(rs(0),"|")>1 then
rs(0)=replace(rs(0),del&"|","")
else
rs(0)=replace(rs(0),del,"")
end if
rs(1)=rs(1)-fn_size
rs.update
end if
rs.close
set rs=nothing
response.Redirect "admin_uploadfile.asp"
end sub
sub Delfilemore()
dim d_fn,d_fn_userid
dim i
dim fn_size,fileinfo
d_fn=split(fn,",")
d_fn_userid=split(fn_userid,",")
for i=0 to ubound(d_fn)
if fso.FileExists(Server.MapPath(uppath&"/"&trim(d_fn(i)))) then
Set fileinfo = fso.GetFile(Server.MapPath(uppath)&"/"&trim(d_fn(i)))
fn_size=fileinfo.size
fso.DeleteFile Server.MapPath(uppath&"/"&trim(d_fn(i)))
end if
set rs=server.createobject("adodb.recordset")
'response.Write "select upfiles,upfiles_size from [user] where userid="&d_fn_userid(i)
rs.open "select upfiles,upfiles_size from [user] where userid="&d_fn_userid(i),conn,1,3
if not rs.eof then
if instr(rs(0),"|"&trim(d_fn(i)))>1 then
rs(0)=replace(rs(0),"|"&trim(d_fn(i)),"")
elseif instr(rs(0),"|")>1 then
rs(0)=replace(rs(0),trim(d_fn(i))&"|","")
else
rs(0)=replace(rs(0),trim(d_fn(i)),"")
end if
rs(1)=rs(1)-fn_size
rs.update
end if
next
rs.close
set rs=nothing
response.Redirect "admin_uploadfile.asp"
end sub
%>
</p>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -