<!--#include file="user_top.asp"-->
<!--#include file="inc/class_blog.asp"-->
<script>
  function DivSetVisible(state)
  {
   var DivRef = document.getElementById('swin3');
   var IfrRef = document.getElementById('DivShim');
   if(state)
   {
    DivRef.style.display = "block";
    IfrRef.style.width = DivRef.offsetWidth;
    IfrRef.style.height = DivRef.offsetHeight;
    IfrRef.style.top = DivRef.style.top;
	//alert(DivRef.style.left);
    IfrRef.style.left = DivRef.style.left;
    IfrRef.style.zIndex = DivRef.style.zIndex - 1;
    IfrRef.style.display = "block";
   }
   else
   {
    DivRef.style.display = "none";
    IfrRef.style.display = "none";
   }
  }


</script>
<script src="inc/function.js" type="text/javascript"></script>
</head>
<body style="overflow-x:hidden;" class="user_iframe">
<%
Dim ssql,i,lPage,lAll,lPages,iPage,sGuide
iPage =15
Dim rs, sql, action
Dim id, cmd, Keyword, sField
Keyword = Trim(request("keyword"))
If Keyword <> "" Then
    Keyword = oblog.filt_badstr(Keyword)
End If
sField = Trim(request("Field"))
cmd = Trim(request("cmd"))
action = Trim(request("action"))
id = oblog.filt_badstr(Trim(request("id")))
If cmd = "" Then
    cmd = 0
Else
    cmd = Int(cmd)
End If
G_P_FileName = "user_files.asp?cmd=" & cmd & "&page="
'此处组织纪录集
 ssql = "userid,file_name,file_path,file_size,fileid,file_readme,file_ext,isphoto,logid"
    sGuide = "当前文件类型:<font color=red><b>"
    Select Case cmd
        Case 0
            sql="select "&ssql&" from [oblog_upfile] where userid="&oblog.l_uid&" order by fileid desc"
            sGuide = sGuide & "所有文件"
        Case 1
            sql="select "&ssql&" from [oblog_upfile] where userid="&oblog.l_uid&" and ( file_ext='gif' or file_ext='jpg' or file_ext='bmp' or file_ext='png' or file_ext='psd' or file_ext='pcx' ) order by fileid desc"
            sGuide = sGuide & "图片文件"
        Case 2
            sql="select "&ssql&" from [oblog_upfile] where userid="&oblog.l_uid&" and ( file_ext='rar' or file_ext='zip' or file_ext='arj' or file_ext='sit') order by fileid desc"
            sGuide = sGuide & "压缩文件"
        Case 3
            sql="select "&ssql&" from [oblog_upfile] where userid="&oblog.l_uid&" and ( file_ext='doc' or file_ext='xsl' or file_ext='txt') order by fileid desc"
            sGuide = sGuide & "文档文件"
        Case 4
            sql="select "&ssql&" from [oblog_upfile] where userid="&oblog.l_uid&" and ( file_ext='mp3' or file_ext='wmv' or file_ext='wma' or file_ext='rm' or file_ext='swf') order by fileid desc"
            sGuide = sGuide & "媒体文件"
        Case 5
            sql="select "&ssql&" from [oblog_upfile] where userid="&oblog.l_uid&" and isphoto=1 order by fileid desc"
            sGuide = sGuide & "相册"
        Case Else
    End Select
    Set rs = Server.CreateObject("Adodb.RecordSet")
   rs.open sql, conn, 1, 3
   lAll=INT(rs.recordcount)
	'分页
	If Request("page") = "" Or Request("page") ="0" then
		lPage = 1
	Else
		lPage = Int(Request("page"))
	End If
	
	'设置缓存大小 = 每页需显示的记录数目
	rs.CacheSize = iPage
	rs.PageSize = iPage
	If lAll>0 Then
		rs.movefirst		
		lPages = rs.PageCount
		If lPage>lPages Then lPage=lPages
		rs.AbsolutePage = lPage
	End If
'在后面进行实际的内容显示
%>	
<ul id="user_page_top">
	<li id="p7"><a href="#" onClick="CheckAll(myform,1)">全部选择</a></li>
	<li id="p8"><a href="#" onClick="CheckAll(myform,0)">全部取消</a></li>
	<li id="p4"><a href="#" onclick="if (chk_idBatch(myform,'删除选中的文件吗?')==true) {document.myform.submit();}">文件删除</a></li>
	<li id="p3"><a href="#" onClick="return doMenu('swin3');">上传文件</a></li>
</ul>
<div id="showpage">
<%If lAll>0 Then Response.Write MakeMiniPageBar(lAll,iPage,lPage,G_P_FileName)%>
</div>
<div id="list">
   <div class="list_left">
   	<%
   Dim freesize, maxsize,maxsize1,thisPercent
		maxsize1 = oblog.l_Group(24,0)
		If maxsize1>0 Then
			maxsize = oblog.showsize(maxsize1 * 1024)
			freesize = oblog.showsize(Int(maxsize1*1024 - oblog.l_uUpUsed))
				thisPercent=oblog.l_uUpUsed/(maxsize1*1024)*100
		Elseif maxsize1=0 Then
			maxsize = "不限"
			freesize = "不限"
			thisPercent=0
		Elseif maxsize1=-1 Then
			maxsize = 0
			freesize = 0
			thisPercent=100
		End If
%>

   <form name="myform1" method="post" action="user_files.asp">
   <select size=1 name='cmd' onChange='javascript:submit()'>
    <option value=10 selected>请选择文件类型</option>
    <option value=0>列出所有文件</option>
    <option value=1>图片文件</option>
    <option value=2>压缩文件</option>
    <option value=3>文档文件</option>
    <option value=4>媒体文件</option>
    <option value=5>相册照片</option>
    </select>
    </form>
	<br />
	<img align=absmiddle src='images/touming.gif' border="1" width='10' height='10' style='background:#cccccc;'>&nbsp;已用空间:<%=oblog.showsize(oblog.l_uUpUsed)%><br />
	<img align=absmiddle src='images/touming.gif' border="1" width='10' height='10' style='background:#ffffff;'>&nbsp;可用空间:<%=freesize%><br />
	<TABLE class="user_space_table" cellSpacing="0" cellPadding="0" width="120" align="center">
  <TBODY>
  <TR>
    <TD class="user_space_used" width="<%=thisPercent%>%" height="12"></TD>
    <TD width="100%"></TD></TR></TBODY></TABLE>
    <p><%=sGuide & "</b></font>"%></p>
</div>
<div class="list_right">
<%
Select Case action
    Case "modifyphoto"
    	Call modify
    Case "savemodify"
    	Call savemodify
    Case "delfile"
    	Call delfile
    Case Else
    	Call main()
End Select
Set rs = Nothing
%>
    </div>

<div id="swin1" style="display:none;position:absolute;top:41px;left:10px;z-index:100;"></div>
<div id="swin2" style="display:none;position:absolute;top:41px;left:10px;z-index:100;"></div>
<div id="swin3" style="display:none;position:absolute;top:41px;left:10px;z-index:100;">
	<table class='win_table' align='center' border='0' cellpadding='0' cellspacing='1'>
		<tr>
			<td align='center' class='win_table_top'>上传文件</td>
		</tr>
		<tr>
			<td><iframe id='d_file' frameborder='0' src='upload.asp?tMode=<%=t%>&re=' width='100%' height='60' scrolling='no'></iframe></td>
		</tr>
		<tr>
			<td class="win_table_end"><input type="button" onClick="return doMenu('swin3');" value="确 定" title="确 定" /></td>
		</tr>
	</table>
</div>
<div id="swin4" style="display:none;position:absolute;top:41px;left:10px;z-index:100;"></div>
<div id="swin5" style="display:none;position:absolute;top:41px;left:10px;z-index:100;"></div>
<iframe id="DivShim" scrolling="no" frameborder="0" style="position:absolute;top:0px; left:0px;display:none">
</iframe>
</body>
</html>
<%
Sub main()
    Dim ext
    %>
    <form name="myform" method="post" action="user_files.asp?action=delfile" onSubmit="return confirm('确定要删除选定的文件吗？');">
    <%
    i=0
    Do while not rs.eof
        ext=rs("file_ext")%>
    <div class="filepic">
    	<div class="fileimg"><a href='<%=rs("file_path")%>' target=_blank>
    		<%	response.Write showfilepic(rs("file_ext"),rs("file_path"),OB_IIF(rs("isphoto"),0))%></a></div>
    <span class="en"><%=oblog.showsize(rs("file_size"))%></span><br />
    <a href="user_files.asp?action=delfile&id=<%=rs("fileid")%>" onclick="return confirm('确定要删除这个文件吗？');">删除</a>
    <br /><input name='id' type='checkbox' id="id" value='<%=cstr(rs("fileid"))%>'><span class="en"><%="<a href="&rs("file_path")&" target=_blank>"&rs("file_name")&"</a>"%></span>
    </div>
<%
    i = i + 1
    If i >= iPage Then Exit Do
    rs.movenext
Loop
%>

    </form>
  </div>
<%
 rs.Close
    Set rs = Nothing
End Sub

function showfilepic(ext,filepath,isPhoto)
	Dim sReturn,sPhoto
	ext=lcase(ext)
	If isPhoto=1 Then 
		sPhoto=",相册文件"
	Else
		sPhoto=""
	End If
	Select Case ext
		Case "jpg" 
			sReturn="<img src=""images/filetype/jpg.gif"" class=""fileimg"" alt=""JPG文件"&sPhoto&""" />"
		Case "gif"
			sReturn="<img src=""images/filetype/gif.gif"" class=""fileimg"" alt=""GIF文件"&sPhoto&""" />"
		Case "bmp" 
			sReturn="<img src=""images/filetype/bmp.gif"" class=""fileimg"" alt=""BMP文件"&sPhoto&""" />"
		Case "png" 
			sReturn="<img src=""images/filetype/png.gif"" class=""fileimg"" alt=""PNG文件"&sPhoto&""" />"
		Case "psd" 
			sReturn="<img src=""images/filetype/psd.gif"" class=""fileimg"" alt=""PSD文件"" />"
		Case "rar" ,"zip","arj","sit" 
			sReturn="<img src=""images/filetype/rar.gif"" class=""fileimg"" alt=""压缩文件"" />"
		Case "xsl" 
			sReturn="<img src=""images/filetype/excel.gif"" class=""fileimg"" alt=""Excel文件"" />"
		Case "doc" 
			sReturn="<img src=""images/filetype/word.gif"" class=""fileimg"" alt=""Word文件"" />"
		Case "mp3" 
			sReturn="<img src=""images/filetype/mp3.gif"" class=""fileimg"" alt=""mp3文件"" />"
		Case "rm","ram" 
			sReturn="<img src=""images/filetype/rm.gif"" class=""fileimg"" alt=""Real文件"" />"
		Case "wmv" ,"wma","mpg" ,"avi" 
			sReturn="<img src=""images/filetype/media.gif"" class=""fileimg"" alt=""媒体文件"" />"
		Case else
			sReturn="<img src=""images/filetype/blank.gif"" class=""fileimg"" alt=""其他文件"" />"
	end Select
	If InStr("jpg,gif,bmp,png,psd",ext) Then sReturn="<img src="""&filepath&""" width=64 height=64 alt=""图片"&sPhoto&"""/>"
	showfilepic=sReturn
end function

Sub delfile()
    If id = "" Then
        oblog.adderrstr ("错误：请指定要删除的文件！")
        oblog.showusererr
        Exit Sub
    End If
    If InStr(id, ",") > 0 Then
        Dim n, i
        id = FilterIDs(id)
        n = Split(id, ",")
        For i = 0 To UBound(n)
            delonefile (n(i))
        Next
    Else
        delonefile (id)
    End If
    Set rs = Nothing
    oblog.showok "删除文件成功！", ""
End Sub

Sub delonefile(id)
    id = Int(id)
    Dim userid, filesize, filepath, fso, photofile, isphoto, imgsrc
    sql="select * from [oblog_upfile] where fileid=" & id&" and userid="&oblog.l_uid
    Set rs = Server.CreateObject("adodb.recordset")
    rs.open sql, conn, 1, 3
    If Not rs.EOF Then
        userid = rs("userid")
        filesize = Int(rs("file_size"))
        filepath = rs("file_path")
        photofile = rs("photofile")
        isphoto = rs("isphoto")
        rs.Delete
        rs.Update
        rs.Close
        oblog.execute("update [oblog_user] set user_upfiles_num=user_upfiles_num-1,user_upfiles_size=user_upfiles_size-"&filesize&" where userid="&userid)
        If filepath <> "" Then
            imgsrc = filepath
            Set fso = Server.CreateObject(oblog.CacheCompont(1))
            If InStr("jpg,bmp,gif,png,pcx", Right(imgsrc, 3)) > 0 Then
                imgsrc = Replace(imgsrc, Right(imgsrc, 3), "jpg")
                imgsrc = Replace(imgsrc, Right(imgsrc, Len(imgsrc) - InStrRev(imgsrc, "/")), "pre" & Right(imgsrc, Len(imgsrc) - InStrRev(imgsrc, "/")))
                If fso.FileExists(Server.MapPath(imgsrc)) Then
                    fso.DeleteFile Server.MapPath(imgsrc)
                End If
            End If
            If fso.FileExists(Server.MapPath(filepath)) Then
                fso.DeleteFile Server.MapPath(filepath)
            End If
            Set fso = Nothing
            End If
    Else
        rs.Close
    End If
    Set rs = Nothing
End Sub
%>