<!--#include file="../../fy.Function.asp"-->
<!--#include file="../../fycms.asp" -->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>fso操作</title>
<link rel="stylesheet" type="text/css" href="../../css/base.css">
<link rel="stylesheet" type="text/css" href="../../css/content.css">
</head>
<body>
<%
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0 
Response.CacheControl = "no-cache"
 If Not fycms.ChkAdmin() Then '超级管理员检测
	Call fycms.fycmsErr("")
 End If 

Dim ACT_Path,ACT_TypePath,str_ShowPath,strShowErr
ACT_TypePath=replace(replace(Request("ShowPath"),"'",""),"""","")
If ACT_TypePath="" Then
	ACT_TypePath=fycms.fycms_Sys(3)&fycms.fycms_Sys(19)
	str_ShowPath = fycms.fycms_Sys(3)&fycms.fycms_Sys(19)
Else
	str_ShowPath =ACT_TypePath
End If
 ACT_Path = Mid(ACT_TypePath,1,InstrRev(ACT_TypePath,"/")-1)
Dim ACT_FSO,ACT_FolderObj,ACT_SubFolderObj,p_FileObj,FileIconDic
Dim ACT_FileItem
Set ACT_FSO = Server.CreateObject("scripting.filesystemobject")
Set ACT_FolderObj = ACT_FSO.GetFolder(Server.MapPath(ACT_TypePath))
Set ACT_SubFolderObj = ACT_FolderObj.SubFolders
Set p_FileObj = ACT_FolderObj.Files
Set FileIconDic = CreateObject("Scripting.Dictionary")
FileIconDic.Add "txt","FileIcon/txt.gif"
FileIconDic.Add "gif","FileIcon/gif.gif"
FileIconDic.Add "exe","FileIcon/exe.gif"
FileIconDic.Add "asp","FileIcon/asp.gif"
FileIconDic.Add "html","FileIcon/html.gif"
FileIconDic.Add "htm","FileIcon/html.gif"
FileIconDic.Add "jpg","FileIcon/jpg.gif"
FileIconDic.Add "jpeg","FileIcon/jpg.gif"
FileIconDic.Add "pl","FileIcon/perl.gif"
FileIconDic.Add "perl","FileIcon/perl.gif"
FileIconDic.Add "zip","FileIcon/zip.gif"
FileIconDic.Add "rar","FileIcon/zip.gif"
FileIconDic.Add "gz","FileIcon/zip.gif"
FileIconDic.Add "doc","FileIcon/doc.gif"
FileIconDic.Add "xml","FileIcon/xml.gif"
FileIconDic.Add "xsl","FileIcon/xml.gif"
FileIconDic.Add "dtd","FileIcon/xml.gif"
FileIconDic.Add "vbs","FileIcon/vbs.gif"
FileIconDic.Add "js","FileIcon/vbs.gif"
FileIconDic.Add "wsh","FileIcon/vbs.gif"
FileIconDic.Add "sql","FileIcon/script.gif"
FileIconDic.Add "bat","FileIcon/script.gif"
FileIconDic.Add "tcl","FileIcon/script.gif"
FileIconDic.Add "eml","FileIcon/mail.gif"
FileIconDic.Add "swf","FileIcon/flash.gif"
if Request.QueryString("Type") = "FileReName" then
		Dim NewFileName,OldFileName,Path,PhysicalPath,FileObj
		Path = replace(replace(Request("Path"),"'",""),"""","")
		if Path <> "" then
			NewFileName = Request("NewFileName")
			OldFileName = Request("OldFileName")
			if (NewFileName <> "") And (OldFileName <> "") then
				PhysicalPath = Server.MapPath(Path) & "\" & OldFileName
				if ACT_FSO.FileExists(PhysicalPath) = True then
					PhysicalPath = Server.MapPath(Path) & "\" & NewFileName
					if ACT_FSO.FileExists(PhysicalPath) = False then
						Set FileObj = ACT_FSO.GetFile(Server.MapPath(Path) & "\" & OldFileName)
						FileObj.Name = NewFileName
						Set FileObj = Nothing
					end if
				end if
			end if
		end if
		Call fycms.ActErr("修改文件成功","","")
 		Response.end
End if

if Request.QueryString("Type") = "FolderReName" then
		Dim NewPathName,OldPathName
		Path = replace(replace(Request("Path"),"'",""),"""","")
		if Path <> "" then
			NewPathName = replace(replace(Request("NewFileName"),"'",""),"""","")
			OldPathName = replace(replace(Request("OldFileName"),"'",""),"""","")
			if (NewPathName <> "") And (OldPathName <> "") then
				PhysicalPath = Server.MapPath(Path) & "\" & OldPathName
				if ACT_FSO.FolderExists(PhysicalPath) = True then
					PhysicalPath = Server.MapPath(Path) & "\" & NewPathName
					if ACT_FSO.FolderExists(PhysicalPath) = False then
						Set FileObj = ACT_FSO.GetFolder(Server.MapPath(Path) & "\" & OldPathName)
						FileObj.Name = NewPathName
						Set FileObj = Nothing
					end if
				end if
			end if
		end if
		Call fycms.ActErr("修改目录成功&nbsp;&nbsp;","","")
		Response.end
End if

if Request.QueryString("Type") = "AddFolder" then
		Path = replace(replace(Request("Path"),"'",""),"""","")
		Path = replace(Path,".","")
		if Path <> "" then
			Path = Server.MapPath(Replace(Path,"//","/"))
			if ACT_FSO.FolderExists(Path) = True then
				Call fycms.ActErr("目录已经存在&nbsp;&nbsp;","","1")
				Response.end
			else
				ACT_FSO.CreateFolder Path
			end if
		end if
		Call fycms.ActErr("创建目录成功&nbsp;&nbsp;","","")
		Response.end
end if

if Request.QueryString("Action") = "Delfolder" then
	Path = replace(replace(Request.QueryString("Dir"),"'",""),"""","") &"/"&replace(replace(Request.QueryString("File"),"'",""),"""","")
	if Path <> "" then
		Path = Server.MapPath(Path)
		if ACT_FSO.FolderExists(Path) = true then ACT_FSO.DeleteFolder Path
	end if
	Call fycms.ActErr("删除目录成功！&nbsp;&nbsp;","","")
	Response.end
End if
if Request.QueryString("Action") = "Delfile" then
	Dim DelFileName
	Path = replace(replace(Request.QueryString("Dir"),"'",""),"""","")
	DelFileName = replace(replace(Request.QueryString("File"),"'",""),"""","")
	if (DelFileName <> "") And (Path <> "") then
		Path = Server.MapPath(Path)
		if ACT_FSO.FileExists(Path & "\" & DelFileName) = true then ACT_FSO.DeleteFile Path & "\" & DelFileName
	end if
	Call fycms.ActErr("删除文件成功！&nbsp;&nbsp;","","")
	Response.end
End if
%>





<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 模板管理</div>
 
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>名称</th><th>类型</th><th>大小(kb)</th><th>最后修改时间</th><th>操作</th>
	  </tr>
    </thead>
        <% If ACT_Path <> fycms.fycms_Sys(3) And ACT_Path <> "/" Then %>
	<tr>
        <td colspan="5" class="tl"><a title="上级目录<% = ACT_Path %>" href="?ShowPath=<% = ACT_Path %>">上级目录</span>(<font color=red>点击进入目录</font>)</td>
        </tr>

<%
	End If
	For Each ACT_FileItem In ACT_SubFolderObj
		%>

  <tr>
        <td  class="tl"><img src="FileIcon/folder.gif" width="20" height="16"><a href="?ShowPath=<%=ACT_TypePath%>/<% = ACT_FileItem.name %>"> 
              <% = ACT_FileItem.name %>
              </a></td>
		 <td>文件夹</td>
		 <td><%
		  if ACT_FileItem.Size<100 then
			 echo ACT_FileItem.Size &"Byte"
		  Else
			 echo FormatNumber(ACT_FileItem.Size/1024,1,-1) &"KB"
		  End if
		  %></td>
        <td><% = ACT_FileItem.DateLastModified %></td>
        <td><span class="t_success"><a href="#" onClick="EditFolder('<% = ACT_FileItem.name %>','<%=str_ShowPath%>')">改名</a>｜<a href="?Action=Delfolder&File=<% = ACT_FileItem.name %>&Dir=<%=str_ShowPath%>" onClick="{if(confirm('确定删除此目录吗？')){return true;}return false;}">删除</a> </span></td>
      </tr>
  <%
		Next
		For Each ACT_FileItem In p_FileObj
			Dim p_FileIcon,p_FileExtName
			p_FileExtName = Mid(CStr(ACT_FileItem.Name),Instr(CStr(ACT_FileItem.Name),".")+1)
			If lcase(p_FileExtName)="html" Or lcase(p_FileExtName)="htm" Or lcase(p_FileExtName)="css" Then 
				p_FileIcon = FileIconDic.Item(LCase(p_FileExtName))
				If p_FileIcon = "" Then
					p_FileIcon = "FileIcon/unknown.gif"
				End If
		%>



  <tr>
        <td class="tl"><img src="<% = p_FileIcon %>"><a href="TempletEdit.asp?File=<% = ACT_FileItem.name %>&Dir=<%=str_ShowPath%>"> <% = ACT_FileItem.Name %></a></td>
         <td><% = ACT_FileItem.Type %></td>
        <td > <%
		  if ACT_FileItem.Size<100 then
			 echo ACT_FileItem.Size &"字节"
		  Else
			 echo FormatNumber(ACT_FileItem.Size/1024,1,-1) &"KB"
		  End if
		  %></td>
		<td><% = ACT_FileItem.DateLastModified %></td>
        <td><span class="t_success"><a href="TempletEdit.asp?A=T&File=<% = ACT_FileItem.name %>&Dir=<%=str_ShowPath%>">在线编辑</a>｜<a href="#" onClick="Editfile('<% = replace(ACT_FileItem.name,"'","\'") %>','<%=str_ShowPath%>')">改名</a>｜<a href="<%=str_ShowPath%>/<% = ACT_FileItem.name %>" target="_blank">预览</a>｜<a href="?Action=Delfile&File=<% = ACT_FileItem.name %>&Dir=<%=str_ShowPath%>" onClick="{if(confirm('确定删除此文件吗？')){return true;}return false;}">删除</a></span></td>

      </tr>





 <%
	  else
	  end if
	next
	%>

		<tr>
        <td colspan="5"><span  class="tx">小提示：点击目录进入下一级目录</span>
          <input type="button" class="btn btn_primary" onClick="window.location.href='TempletEdit.asp?Action=Add&Dir=<%=str_ShowPath%>'" value="新建模板">
		  <input type="button" class="btn btn_primary"  name="Submit2" value="新建目录" onClick="AddFolder();">
        </div>
		</td>
        </tr>
    </table>

</div>








 

<%
Set ACT_FSO = Nothing
Set ACT_FolderObj = Nothing
Set ACT_SubFolderObj = Nothing
Set FileIconDic = Nothing
%>
<script>


function AddFolder()
{
	var CurrPath='<% = ACT_TypePath %>';
	var ReturnValue=prompt('新建目录名：','');
	if ((ReturnValue!='') && (ReturnValue!=null))
	window.location.href='?Path=<%=ACT_TypePath%>/'+ReturnValue+'&Type=AddFolder&CurrPath=<%=ACT_TypePath%>';
}

function Editfile(filename,path)
{
		var ReturnValue='';
		ReturnValue=prompt('修改的名称：',filename.replace(/'|"/g,''));
		if ((ReturnValue!='') && (ReturnValue!=null)) window.location.href='?Type=FileReName&Path='+path+'&OldFileName='+filename+'&NewFileName='+ReturnValue;
		else if(ReturnValue!=null){alert('请填写要更名的名称');}
}
function EditFolder(filename,path)   
{
	var ReturnValue='';
	ReturnValue=prompt('修改的名称：',filename.replace(/'|"/g,''));
	if ((ReturnValue!='') && (ReturnValue!=null)) window.location.href='?Type=FolderReName&Path='+path+'&OldFileName='+filename+'&NewFileName='+ReturnValue;
		else if(ReturnValue!=null){alert('请填写要更名的名称');}
}
</script>
</body>
</html>