⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user_uploadfile.asp

📁 个人博客
💻 ASP
字号:
<!--#include file="conn.asp"-->
<!--#include file="user_chkpass.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/usercode.asp"-->
<%
if CheckUserLogined()=False then
	response.Redirect "user_login.asp"
end if
const MaxPerPage=500
dim strFileName
dim totalPut,CurrentPage,TotalPages
dim rs, sql
dim userid,strField,srGuide
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)
Action=trim(request("Action"))

if request("page")<>"" then
    currentPage=cint(request("page"))
else
	currentPage=1
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="0" Class="border">
  <tr class="topbg"> 
    <td height="22" colspan=2 align=center><strong>我的上传文件管理</strong></td>
  </tr> 
    <tr class="tdbg">
      <td height="22"><div align="right">总空间:</div></td>
      <td height="22"><div align="left"><img src="images/bar.gif" width=<%
	  	dim themax,rsmax
		set rsmax=conn.execute("select upfile_user_maxsize,upfile_vip_maxsize,upfile_admin_maxsize from bloginfo")
		set rs=conn.execute("select upfiles_size,userlevel from [user] where username='"&username&"'")
				select case rs("userlevel")
				case 7
				themax=rsmax(0)
				case 8
				themax=rsmax(1)
				case 9
				themax=rsmax(2)
		end select		
		set rsmax=nothing
		response.Write ("80%")			
			%> height=10> <%=themax&"KB"%></div></td>
    </tr>
    <tr class="tdbg">
      <td height="22"><div align="right">已使用:</div></td>
      <td height="22"><div align="left"><img src="images/bar.gif" width=<%
			response.Write ((rs("upfiles_size")/1024)/themax)*100*0.8&"%"			
			%> height=10> <%=round(rs("upfiles_size")/1024)&"KB"%></div></td>
    </tr>
    <tr class="tdbg"> 
      <td width="100" height="22"><div align="right">剩余:</div></td>
      <td width="687" height="22"><div align="left"><img src="images/bar.gif" width=<%			
				response.Write ((themax-round(rs("upfiles_size")/1024))/themax)*100*0.8&"%"			
			%> height=10> <%=themax-round(rs("upfiles_size")/1024)&"KB"%></div></td>
    </tr>
</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
	sql="select upfiles,username,userid from [user] where username='"&username&"' order by userID desc"	
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,Conn,1,1
  	if rs.eof and rs.bof then
		response.write strGuide
	else
    	totalPut=rs.recordcount
		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,"个文件"
   	 	else
   	     	if (currentPage-1)*MaxPerPage<totalPut then
         	   	rs.move  (currentPage-1)*MaxPerPage
         		dim bookmark
           		bookmark=rs.bookmark
            	showContent
            	showpage strFileName,totalput,MaxPerPage,true,true,"个文件"
        	else
	        	currentPage=1
           		showContent
           		showpage strFileName,totalput,MaxPerPage,true,true,"个文件"
	    	end if
		end if
	end if
	rs.Close
	set rs=Nothing

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="user_uploadfile.asp?delmore=true" onsubmit="return confirm('确定要执行选定的操作吗?');">
     <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="236" align="center"><div align="center"><font color="#FFFFFF">文件名</font></div></td>
            <td width="117" height="22" align="center"><div align="center"><font color="#FFFFFF"> 所属用户</font></div></td>
            <td width="112" height="22" align="center"><div align="center"><font color="#FFFFFF">文件大小</font></div></td>
            <td width="189" align="center"><div align="center"><font color="#FFFFFF">上传时间</font></div></td>
            <td width="67" height="22" align="center"><div align="center"><font color="#FFFFFF"> 
              操作</font></div></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="236" align="center"><a href=<%=uppath&"/"&sfile(n)%> target="_blank"><%=sfile(n)%></a></td>
            <td width="117" align="center"><a href=blog.asp?name=<%=rs("username")%> target="_blank"><%=rs("username")%></a></td>
            <td align="center">&nbsp; <%=round(fileinfo.size/1024)&"K"%></td>
            <td align="center"><%=fileinfo.DateLastModified %>
            </td>
            <td width="67" align="center">
			<%		
        response.write "<a href='user_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">
              删除&nbsp;&nbsp;&nbsp;              &nbsp;&nbsp; 
              <input type="submit" name="Submit" value=" 执 行 "> </td>
  </tr>
</table>
</td>
</form></tr></table>
<%

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 "user_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 "user_uploadfile.asp"
end sub

%>
</p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -