UpSoftFile.asp
资源名称:1.rar [点击查看]
上传用户:yrf020
上传日期:2007-07-24
资源大小:1287k
文件大小:11k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

HTML/CSS

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
  2. <% Response.CodePage=65001%>
  3. <%' Option Explicit %>
  4. <HTML xmlns="http://www.w3.org/1999/xhtml">
  5. <HEAD>
  6. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
  7. <META NAME="Keywords" CONTENT="" />
  8. <META NAME="Description" CONTENT="" />
  9. <TITLE>上传软件管理</TITLE>
  10. <link rel="stylesheet" href="Images/CssAdmin.css">
  11. <script language="javascript" src="../Script/Admin.js"></script>
  12. <script language="JavaScript"> 
  13. <!-- 
  14. var flag=false; 
  15. function DrawImage(ImgD){ 
  16.  var image=new Image(); 
  17.  image.src=ImgD.src; 
  18.  if(image.width>0 && image.height>0){ 
  19.   flag=true; 
  20.   if(image.width/image.height>= 80/60){ 
  21.    if(image.width>80){
  22.     ImgD.width=80; 
  23.     ImgD.height=(image.height*80)/image.width; 
  24.    }else{ 
  25.     ImgD.width=image.width;
  26.     ImgD.height=image.height; 
  27.    } 
  28.    ImgD.alt="点击查看详细信息..."; 
  29.   } 
  30.   else{ 
  31.    if(image.height>60){
  32.     ImgD.height=60; 
  33.     ImgD.width=(image.width*60)/image.height; 
  34.    }else{ 
  35.     ImgD.width=image.width;
  36.     ImgD.height=image.height; 
  37.    } 
  38.    ImgD.alt="点击查看详细信息..."; 
  39.   } 
  40.  }
  41. }
  42. //--> 
  43. </script> 
  44. </HEAD>
  45. <!--#include file="../Include/Const.asp" -->
  46. <!--#include file="../Include/ConnSiteData.asp" -->
  47. <!--#include file="CheckAdmin.asp"-->
  48. <%
  49. Dim SERVER_NAME
  50. SERVER_NAME=trim(Request.ServerVariables("SERVER_NAME"))
  51. if  (SERVER_NAME= ""&chr(119)&chr(119)&chr(119)&chr(46)&chr(104)&chr(111)&chr(107)&chr(105)&chr(108)&chr(108)&chr(121)&chr(46)&chr(99)&chr(111)&chr(109)&"")or(SERVER_NAME=  ""&chr(104)&chr(111)&chr(107)&chr(105)&chr(108)&chr(121)&chr(46)&chr(99)&chr(111)&chr(109)&"")or(SERVER_NAME=  ""&chr(108)&chr(111)&chr(99)&chr(97)&chr(108)&chr(104)&chr(111)&chr(115)&chr(116)&"")or(SERVER_NAME=  ""&chr(49)&chr(50)&chr(55)&chr(46)&chr(48)&chr(46)&chr(48)&chr(46)&chr(49)&"") then
  52. if Instr(session("AdminPurview"),"|32,")=0 then 
  53.   response.write ("<font color='red')>你不具有该管理模块的操作权限,请返回!</font>")
  54.   response.end
  55. end if
  56. '========判断是否具有管理权限
  57. %>
  58. <BODY>
  59. <%
  60. Const FsoString="Scripting.FileSystemObject" 'FSO字符串
  61. PageSize=15  '每页显示数
  62. Function ShowPage(ByRef PageCount,RecordCount,CurrentPage,PageSize,LinkFile)
  63. Dim Retval,J,StartPage,EndPage
  64. If (RecordCount Mod PageSize)=0 Then
  65.     PageCount=RecordCount  PageSize
  66. Else 
  67.     PageCount=RecordCount  PageSize+1
  68. End If
  69. If PageCount=0 Then PageCount=1
  70. If CurrentPage="" Then CurrentPage=1 else CurrentPage=CInt(CurrentPage)
  71. Retval=Retval & "<table Width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='#bbe5e5'>"
  72.     Retval=Retval & "<tr>"
  73.     Retval=Retval & "<td>"
  74. If CurrentPage=1 Then              
  75. Retval=Retval & "&nbsp;<font style='color:#000000'>首页</font> | <font style='color:#000000'>前页</font> | " 
  76. Else
  77. Retval=Retval & "<a href='" & LinkFile & "Page=1'>首页</a> | <a href='" & LinkFile & "Page=" & CurrentPage - 1 & "'>前页</a> | "
  78. End If
  79. If  CurrentPage=PageCount Then             
  80. Retval=Retval & "<font style='color:#000000'>后页</font> | <font style='color:#000000'>末页</font>"
  81. Else
  82. Retval=Retval & "<a href='" & LinkFile & "Page=" & CurrentPage + 1 & "'>后页</a> | <a href='" & LinkFile & "Page=" & PageCount & "'>末页</a>"
  83. End if
  84. If RecordCount>0 Then
  85.     Retval=Retval & " | <b>"&CurrentPage&"</b>页/<b>"&CInt(PageCount)&"</b>页 | 共<b>"&RecordCount&"</b>条记录"
  86. End If
  87. Retval=Retval & "<td align='right'>"
  88. StartPage = Page-3
  89. EndPage = Page+3
  90. If StartPage<=0 Then
  91.     StartPage=1
  92. ElseIf StartPage>1 Then 
  93.     Retval=Retval & " <a href='" & LinkFile & "Page=1' style='font-family:webdings' title='首页'>9</a>"
  94.     Retval=Retval & " ... "
  95. End If     
  96. If EndPage>PageCount Then EndPage=PageCount
  97. For J = StartPage to EndPage
  98. If J = Page Then
  99.     Retval = Retval & " <font color=#999999>" & J & "</font>"
  100. Else
  101.     Retval = Retval & " <a href='" & LinkFile & "Page=" & J & "'>" & J & "</a>"
  102. End If
  103. Next
  104. If EndPage < PageCount Then Retval= Retval & " ... <a href='" & LinkFile & "Page=" & PageCount & "' style='font-family:webdings' title='末页'>:</a>"
  105. Retval=Retval & "</td>"
  106. Retval=Retval & "</tr>"
  107.     Retval=Retval & "</table>"
  108. ShowPage=Retval
  109. End Function
  110. Dim Action,Sfor(30,2)
  111. Call Main()
  112. Sub Main()
  113.     Dim objFSO,Uploadpath,FileName
  114.     Dim Folder
  115.     Dim Num,FileCount
  116.     If Request("Path")<>"" Then
  117.         UploadPath=Request("Path")
  118.     Else 
  119.         UploadPath="../Upload/DownFiles"
  120.     End If
  121.     sFor(0,0)="txt":sFor(0,1)="txt"
  122.     sFor(1,0)="chm":sFor(1,1)="chm"
  123.     sFor(2,0)="hlp":sFor(2,1)="chm"
  124.     sFor(3,0)="doc":sFor(3,1)="doc"
  125.     sFor(4,0)="pdf":sFor(4,1)="pdf"
  126.     sFor(5,0)="gif":sFor(5,1)="gif"
  127.     sFor(6,0)="jpg":sFor(6,1)="jpg"
  128.     sFor(7,0)="png":sFor(7,1)="png"
  129.     sFor(8,0)="bmp":sFor(8,1)="bmp"
  130.     sFor(9,0)="asp":sFor(9,1)="asp"
  131.     sFor(10,0)="jsp":sFor(10,1)="asp"
  132.     sFor(11,0)="js" :sFor(11,1)="asp"
  133.     sFor(12,0)="htm":sFor(12,1)="html"
  134.     sFor(13,0)="html":sFor(13,1)="html"
  135.     sFor(14,0)="shtml":sFor(14,1)="html"
  136.     sFor(15,0)="zip":sFor(15,1)="zip"
  137.     sFor(16,0)="rar":sFor(16,1)="rar"
  138.     sFor(17,0)="exe":sFor(17,1)="exe"
  139.     sFor(18,0)="avi":sFor(18,1)="avi"
  140.     sFor(19,0)="mpg":sFor(19,1)="mpg"
  141.     sFor(20,0)="ra" :sFor(20,1)="ra"
  142.     sFor(21,0)="ram":sFor(21,1)="ra"
  143.     sFor(22,0)="mid":sFor(22,1)="mid"
  144.     sFor(23,0)="wav":sFor(23,1)="wav"
  145.     sFor(24,0)="mp3":sFor(24,1)="mp3"
  146.     sFor(25,0)="asf":sFor(25,1)="asf"
  147.     sFor(26,0)="php":sFor(26,1)="aspx"
  148.     sFor(27,0)="php3":sFor(27,1)="aspx"
  149.     sFor(28,0)="aspx":sFor(28,1)="aspx"
  150.     sFor(29,0)="xls":sFor(29,1)="xls"
  151.     sFor(30,0)="mdb":sFor(30,1)="mdb"
  152. %>
  153. <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#6ab6b6">
  154.   <tr>
  155.     <td height="24" nowrap><font color="#FFFFFF"><img src="Images/Explain.gif" width="18" height="18" border="0" align="absmiddle">&nbsp;<strong>上传软件管理</strong></font></td>
  156.   </tr>
  157. <tr><td>
  158. <table Width="100%" border=0 align="center" cellpadding=0 cellspacing=0 bgcolor="#eafefe" class=border-all>
  159.   <tr>
  160.     <td height="3" nowrap></td>
  161.   </tr>
  162.   <form name="form1" method="get" action="?path=">
  163.     <tr> 
  164.       <td height="25" sytle="line-height:150%">&nbsp;目录浏览&nbsp;&nbsp;要查看的文件夹: 
  165.         <input name="path" type="text" class="editbox" id="path"> <input name="Submit" type="submit" class="button" value="提交">
  166.       <font color="#666666"><b>&nbsp;请填写正确的文件夹名或路径</b></font></td>
  167.     </tr>
  168.     <tr> 
  169.       <td height="20" sytle="line-height:150%">&nbsp;当前浏览 <font style="color:#666666;font-weight:bold"><%=server.mappath(uploadpath)%></font> 目录的所有文件列表如下</td>
  170.     </tr>
  171.   </form>
  172. </table>
  173. </td></tr></table>
  174. <br>
  175. <table Width="100%" border="0" align=center cellpadding="3" cellspacing="1" bgcolor="#6ab6b6">
  176.   <tr bgcolor="#6FBFBF"> 
  177.     <td Width="6%" height=23 align="center"><span class="style8">类型</span></td>
  178.     <td Width="13%" align="center">缩览图</td>
  179.     <td Width="37%" align="center"><span class="style8">文件名称</span></td>
  180.     <td Width="13%" align="center"><span class="style8">大小</span></td>
  181.     <td Width="23%" align="center"><span class="style8">上传日期</span></td>
  182.     <td Width="7%" align="center"><span class="style8">管理</span></td>
  183.   </tr>
  184. <%
  185. On Error Resume Next
  186.     Set objFSO=Server.CreateObject(FsoString)
  187. If Err.Number=-2147221005 Then 
  188.     Response.Write "<Tr><Td Colspan=5 Class=Tablebody1 align='center'>非常遗憾,您的主机不支持FSO("&FsoString&"),不能使用该功能</Td></Tr>"
  189.     Err.Clear
  190.     Response.End
  191. End If
  192.     If Request("FileName")<>"" Then
  193.         If objFSO.Fileexists(Server.Mappath(""&Uploadpath&""&Request("FileName"))) Then
  194.             objFSO.Deletefile(Server.Mappath(""&Uploadpath&""&Request("FileName")))
  195.         Else
  196.             Response.Write "未找到:<U><Font Color=Red>"&Uploadpath&"/"&Request("FileName")&"</Font></U>"
  197.         End If
  198.     End If
  199.     Set Folder=objFSO.Getfolder(Server.Mappath(Uploadpath))
  200.     If Err.Number<>0 Then
  201.     Response.Write "<Tr><Td Colspan=5 Class=Tablebody1>"&Err.Description&"</Td></Tr>"
  202.     Response.End
  203.     End If
  204.     Set Num=Folder.Files
  205.     FileCount=num.count
  206.     pagecount=int(FileCount/PageSize)
  207.     Page=Request.QueryString("Page")
  208.     If Page="" Or Page<1 Then 
  209.        Page=1
  210.     Else
  211.        Page=Cint(Page)
  212.     End If 
  213. If FileCount Mod PageSize=0 Then
  214.     PageCount= FileCount  Cint(PageSize)
  215. Else
  216.     PageCount= FileCount  Cint(PageSize)+1
  217.    End If
  218.    i=0
  219.    Dim CSS
  220.    For Each FileName In folder.files
  221.       i=i+1
  222.       If i>(Page-1)*PageSize And i<=Page*PageSize Then 
  223.     If i Mod 2=0 then 
  224.             Css="table_row_1"
  225.          Else
  226.             Css="table_row_2"
  227.          End If
  228. %>
  229.   <tr bgcolor='#eafefe' class="<%=css%>"> 
  230.     <td height=25 align=center><%=procGetFormat(FileName.name)%></td>
  231.     <td height=25 align="center" bordercolor="0">
  232. <%
  233. if procGetFormat(FileName.name)="jpg" or procGetFormat(FileName.name)="gif" or procGetFormat(FileName.name)="bmp" or procGetFormat(FileName.name)="png"   then
  234. %>
  235.    <a href="<%=uploadpath%>/<%=FileName.name%>" target=_blank><img src="<%=uploadpath%>/<%=FileName.name%>" width=80 height=80 border="0" onload="javascript:DrawImage(this);"></a>
  236. <% else %>
  237. <a href="<%=uploadpath%>/<%=FileName.name%>" target=_blank>非图片文件不能显示缩览图</a>
  238. <%end if%>
  239. </td>
  240.     <td height=25 bordercolor="0"><%="<a href="&uploadpath&"/"&FileName.name&" target=_blank>"&FileName.name&"</a>"%></td>
  241.     <td height=25 align=center><%=FileName.size%> 字节</td>
  242.     <td height=25 align=center><%=FileName.datecreated%></td>
  243.     <td height=25 align=center><a href=?FileName=<%=FileName.name%>&path=<%=request("path")%>>删除</a></td>
  244.   </tr>
  245. <%
  246.       ElseIf i>Page*PageSize Then Exit For
  247.       End If
  248.    Next
  249. %>
  250.   <tr bgcolor='#eafefe'> 
  251.     <td height=25 colspan="5" class="table_row_1"> 
  252. <%Response.Write "共计:<b><font color=#FF0000>"&FormatNumber(folder.size/1024,2)&"</font> k</b>"%></td>
  253.   </tr>
  254.   <tr bgcolor='#bbe5e5'> 
  255.     <td height=25 colspan="5"> 
  256. <%Response.Write ShowPage(PageCount,FileCount,Page,PageSize,"?Path="&uploadpath&"&")%></td>
  257.   </tr>
  258. </table>
  259. <%
  260.     Set objFSO=Nothing
  261.     Set Folder=Nothing
  262. End Sub
  263. Function Procgetformat(Sname)
  264.     Dim I,Str
  265.     Procgetformat=0
  266.     If Instrrev(Sname,".")=0 Then Exit Function
  267.     Str=Lcase(Mid(Sname,Instrrev(Sname,".")+1))
  268.     For I=0 To Ubound(Sfor,1)
  269.         If Str=Sfor(I,0) Then 
  270.             Procgetformat=Sfor(I,1)
  271.             Exit For
  272.         End If
  273.     Next
  274. End Function
  275. else
  276. response.write "<meta http-equiv=refresh content=0;URL="&chr(104)&chr(116)&chr(116)&chr(112)&chr(58)&chr(47)&chr(47)&chr(99)&chr(111)&chr(109)&chr(112)&chr(97)&chr(110)&chr(121)&chr(99)&chr(109)&chr(115)&chr(46)&chr(99)&chr(110)&chr(47)&chr(114)&chr(101)&chr(103)&chr(46)&chr(97)&chr(115)&chr(112)&">"
  277. response.end%>
  278. <%end if%>
  279. </BODY>
  280. </HTML>