<!--#include file="Top.asp" -->
<table width="99%" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr> 
    <td height="30" bgcolor="#FFFFFF" class="h1"><img src="img/GuestBook.gif" width="23" height="21"> 
      上传文件列表 <a href="Rar_Add.asp">文件打包</a> <hr size="0"></td>
  </tr>
  <tr> 
    <td valign="top" bgcolor="#FFFFFF" class="h1"><SCRIPT language=javascript src="../inc/js.js"></SCRIPT> 
      <table width="100%" height="400" border="0" align="center" cellpadding="5" cellspacing="0">
        <tr> 
          <td valign="top" bgcolor="#FFFFFF" class="box"> <div align="center"> 
<%
Dim Fso,Path,UserSize,Obj,sAction, sPosition,Width,StarTime
StarTime=Timer()
Path=Server.MapPath(CblogObj.GetUpLoadDir(Session("UserID"))&"/")
Set Fso = CreateObject("Scripting.FileSystemObject")
Set obj  =  Fso.GetFolder(Path)
UserSize=obj.Size
Set Obj=nothing
Set Fso=nothing
Width=(Round(UserSize/1024/1024/Session("UpFileSize"),2))*100 & "%"
sAction = UCase(Trim(Request.QueryString("action")))
sPosition = sPosition & "上传文件管理"
Call Content()
Sub Content()
	If IsObjInstalled("Scripting.FileSystemObject") = False Then
		Response.Write "对不起,您的系统不支持FSO!!"
		Exit Sub
	End If
	Select Case sAction
	Case "DELALL"
		Call DoDelAll()
	Case "DEL"
		Call DoDel()
	End Select
	Call ShowList()
End Sub
Sub ShowList()
%>
              <form action='?action=del' method=post name=myform>
                <table width="99%" border=0 align="center" cellpadding=8 cellspacing=1 bgcolor="#CCCCCC" class=list1>
                  <tr align=center bgcolor="#FFFFFF"> 
                    <th height="25" colspan="5">您的上传空间为 <%=Session("UpFileSize")%> M,已使用 
                      <%=Round(UserSize/1024,2)%> K,占总空间的 <%=Width%> </th>
                  </tr>
                  <tr align=center bgcolor="#FFFFFF"> 
                    <th height="25" colspan="5"><table width="500" border="0" align="center" cellspacing="1" bgcolor="#000000">
                        <tr> 
                          <td height="10" bgcolor="#0074bc"> <table width=<%=Width%> border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
                              <tr> 
                                <td bgcolor="#ffffff" height="10"></td>
                              </tr>
                            </table></td>
                        </tr>
                      </table></th>
                  </tr>
                  <tr align=center bgcolor="efefef"> 
                    <th width="273" height="25">缩略图</th>
                    <th width=138>大小</th>
                    <th width=169>最后访问</th>
                    <th width=147>上传时间</th>
                    <th width=47>删除</th>
                  </tr>
                  <%	
	Dim sCurrPage, nCurrPage, nFileNum, nPageNum, nPageSize
	nPageSize = 10
	Dim oFSO, oUploadFolder, oUploadFiles, oUploadFile, sFileName
	Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
	Set oUploadFolder = oFSO.GetFolder(Server.MapPath(CblogObj.GetUpLoadDir(Session("UserID"))&"/"))
	Set oUploadFiles = oUploadFolder.Files
	nFileNum = oUploadFiles.Count
	IF nFileNum MOD nPageSize = 0 THEN
		nPageNum = Int(nFileNum \ nPageSize)
	Else
		nPageNum= Int(nFileNum \ nPageSize)+1
	End IF
	MaxP=nPageNum
	sCurrPage = CblogObj.QueryPage
	If sCurrpage = "" Or Not IsNumeric(sCurrPage) Then
		nCurrPage = 1
	Else
		nCurrPage = CLng(sCurrPage)
	End If
	If nFileNum Mod nPageSize > 0 Then
		nPageNum = nPageNum+1
	End If
	If nCurrPage > nPageNum Then
		nCurrPage = 1
	end If
	Dim i
	i = 0
	For Each oUploadFile In oUploadFiles
		i = i + 1
		If i > (nCurrPage - 1) * nPageSize And i <= nCurrPage * nPageSize Then
			sFileName = oUploadFile.Name
			%>
                  <tr align=center bgcolor="#FFFFFF"> 
                    <td align=center> <table width="1" height="1" border="0" cellpadding="6" cellspacing="1" bgcolor="#333333">
                        <tr> 
                          <td bgcolor="#FFFFFF"> <div align="center"><a href=<%=CblogObj.GetUpLoadDir(Session("UserID"))%>/<%=sFileName%> target=_blank><img src=<%=CblogObj.GetUpLoadDir(Session("UserID"))%>/<%=sFileName%> width="200"  height=100 border=0></a> 
                            </div></td>
                        </tr>
                      </table>
                      <table width="200" border="0" cellpadding="6" cellspacing="1">
                        <tr> 
                          <td><div align="center"><a href=<%=CblogObj.GetUpLoadDir(Session("UserID"))%>/<%=sFileName%> target=_blank> 
                              <%=sFileName%> </a></div></td>
                        </tr>
                      </table></td>
                    <td> <%=oUploadFile.size%> b ( <%=Round(oUploadFile.size/1024,2)%> 
                      )k</td>
                    <td> <%=oUploadFile.datelastaccessed%> </td>
                    <td> <%=oUploadFile.datecreated%> </td>
                    <td><input type=checkbox name=delfilename value="<%=sFileName%>"></td>
                  </tr>
                  <%
		Elseif i > nCurrPage * nPageSize Then
			Exit For
		End If
	Next
	Set oUploadFolder = Nothing
	Set oUploadFiles = Nothing
	If nFileNum <= 0 Then
	%>
                  <tr bgcolor="#FFFFFF"> 
                    <td colspan=6> <div align="center">还没有上传任何文件</div></td>
                  </tr>
                  <%
	End If
	%>
                </table>
                <br>
                <table width='99%' border=0 align=center cellpadding=3 cellspacing=1 bgcolor="#CCCCCC">
                  <tr> 
                    <td bgcolor="#FFFFFF"> <div align="center"><br>
                        <%
				  CblogObj.PageList nFileNum,CblogObj.QueryPage,10,20,false
				  %>
                      </div>
                      <p></p></td>
                  </tr>
                </table>
                <%
Response.Write "<p align=center><input type=submit name=b value='删除选中的文件' class=in> <input type=button name=b1 value='清空所有文件' class=in onclick=""javascript:if (confirm('你确定要清空所有文件吗？')) {location.href='Uploadfile_list.asp?action=delall';}""></p>"
%>
              </form>
              <%
End Sub
Sub DoDel()
	Dim sFileName, oFSO, sMapFileName
	Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
	For Each sFileName In Request.Form("delfilename")
		sMapFileName = Server.MapPath(CblogObj.GetUpLoadDir(Session("UserID"))&"/" & sFileName)
		If oFSO.FileExists(sMapFileName) Then
			oFSO.DeleteFile(sMapFileName)
		End If
	Next
	Set oFSO = Nothing
End Sub
Sub DoDelAll()
	On Error Resume Next
	Dim sFileName, oFSO, sMapFileName, oFolder, oFiles, oFile
	Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
	Set oFolder = oFSO.GetFolder(Server.MapPath(CblogObj.GetUpLoadDir(Session("UserID"))&"/"))
	Set oFiles = oFolder.Files
	For Each oFile In oFiles
		sFileName = oFile.Name
		sMapFileName = Server.MapPath(CblogObj.GetUpLoadDir(Session("UserID"))&"/" & sFileName)
		If oFSO.FileExists(sMapFileName) Then
			oFSO.DeleteFile(sMapFileName)
		End If
	Next
	Set oFile = Nothing
	Set oFolder = Nothing
	Set oFSO = Nothing
End Sub
Function IsObjInstalled(strClassString)
	On Error Resume Next
	IsObjInstalled = False
	Err = 0
	Dim xTestObj
	Set xTestObj = Server.CreateObject(strClassString)
	If 0 = Err Then IsObjInstalled = True
	Set xTestObj = Nothing
	Err = 0
End Function
%>
              <br>
              <br>
            </div></table></td>
  </tr>
  <tr> 
    <td bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr bgcolor="#0066CC" height="2"> 
    <td height="2"></td>
  </tr>
</table>


<!--#include file="Foot.asp" -->
