<!--#include file="QvodCms_Conn.asp"-->
<!--#include file="QvodCms_Check.asp"-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<TITLE>模板管理页面</TITLE>
<link href="skins/css/jaja_main.css" rel="stylesheet" type="text/css" />
<script language = "javaScript" src = "QvodCms_All.js" type="text/javascript"></script>
</head>
<body>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr><th colspan=2 background="Skins/images/tdbg.gif" class="title">&nbsp;图片管理中心</th>
</tr>
<tr><td class="td2">
<%Server.Scripttimeout=900
Dim rootPath,action,picpath
action = Trim(Request.queryString("action"))
rootPath = Trim(Request.queryString("rootPath"))
Select Case action
Case "del"
    Call DelHtml(rootPath)
	Response.Redirect Request.ServerVariables("Http_Referer")
Case Else
    Call OpenConn
	picpath=replace(AdminId(13),"/","")
	If instr(rootPath,picpath)<1 Then rootPath = "../"&picpath
	'If rootPath = "" Then rootPath = "../"&picpath
%>
<table style="background:#cad9ea;" cellSpacing="1" cellPadding="5" width="100%" align="center" border="0">
  <tr align="center" bgcolor="#f5fafe">
	<td><strong>文件名</strong></td>
	<td width="10%"><strong>文件大小</strong></td>
	<td width="20%"><strong>修改时间</strong></td>
	<td width="12%"><strong>操作</strong></td>
  </tr>
  <%Call bianliFolder(rootPath)%>
</table>
<%Call CloseConn
End Select%>
</td></tr>
</table>
<%Function bianliFolder(currentPath)
	path = server.mapPath(currentPath)
    set fso=server.CreateObject("scripting.filesystemobject")    
	on error resume next
	Set objFolder=fso.GetFolder(path)
    upperFolder = left(currentPath,(InStrRev(currentPath,"/")-1))
	If upperFolder <> ".." then
			Response.Write "<tr bgcolor=""#ffffff"">"
			Response.Write "<td colspan=""5""><img src=""images/dir2.gif""> <a href=""?rootPath=" &upperFolder&""">上级目录</a></td>"
			Response.Write "</tr>"
	End If
	Set objSubFolders=objFolder.Subfolders
	for each objSubFolder in objSubFolders 
		nowpath=objSubFolder.name
		nextPath = currentPath & "/" & objSubFolder.name
		Response.Write "<tr bgcolor=""#ffffff"" onmouseover=""this.bgColor='#f5fafe'"" onmouseout=""this.bgColor='#ffffff'"">"
		Response.Write "<td colspan=""5""><img src=""images/dir.gif""> <a href=""?rootPath="&nextPath&""">"&nowpath&"</a></td>"
		Response.Write "</tr>"
	next 
	Call bianliFile(currentPath)
	set objFolder=nothing
	set objSubFolders=nothing
	set fso=nothing
End Function

Function bianliFile(currentPath)
    on error resume next
	path = server.mapPath(currentPath)
	set fso=server.CreateObject("scripting.filesystemobject")   
	set objFolder=fso.GetFolder(path)
		nowpath = path
		set objFiles=objFolder.Files
		For each objFile in objFiles
		    'Call CheckPic(currentPath&"/"&objFile.name)
			PicPath=currentPath&"/"&objFile.name				
			Response.Write "<tr bgcolor=""#ffffff"" onmouseover=""this.bgColor='#f5fafe'"" onmouseout=""this.bgColor='#ffffff'"">"
			Response.Write "<td><img src=""images/asp.gif""> "&objFile.name&"</td>"
			Response.Write "<td align=""center"">"&round(objFile.size/1024,3)&" KB</td>"
			Response.Write "<td align=""center"">"&objFile.DateLastModified&"</td>"
			Response.Write "<td align=""center""><a href='"&PicPath&"' target=""_blank"">观看</a> <a href=""?action=del&rootPath="&PicPath&""">删除</a>"
			If cint(AdminId(30))=1 Then Call CheckPic(PicPath)
			Response.Write "</td></tr>"
		Next
	Set objFolder=nothing
	Set objSubFolders=nothing
	Set fso=nothing
End Function

Sub CheckPic(PicPath)
	PicPath=replace(PicPath,"../","")
	Set rs = Conn.Execute(" select name_id,data_picbig,data_picsmall from qvodcms_name where data_picurl='"&PicPath&"' ")
	If rs.bof Then
		Call DelHtml("../"&PicPath) 
		Response.Write " <font color=red>×</font>"
	End If
	set rs=nothing	
End Sub
%>
</body>
</html>