<% Option Explicit %>
<!--#include file="../../Inc/Function.asp" -->
<!--#include file="../../Inc/Const.asp" -->
<!--#include file="../../Inc/Cls_DB.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P0602") then Call ReturnError1()
Dim UpFilesPath,FS,FolderObj,SubFolderObj,FileObj,FileItem,FolderItem,FileIconDic
UpFilesPath = Request("Path")
Set FS = Server.CreateObject("Scripting.FileSystemObject")
Set FolderObj = FS.GetFolder(Server.MapPath(UpFilesPath))
Set SubFolderObj = FolderObj.SubFolders
Set FileObj = FolderObj.Files

Set FileIconDic = CreateObject("Scripting.Dictionary")
FileIconDic.Add "txt","../Images/FileIcon/txt.gif"
FileIconDic.Add "gif","../Images/FileIcon/gif.gif"
FileIconDic.Add "exe","../Images/FileIcon/exe.gif"
FileIconDic.Add "asp","../Images/FileIcon/asp.gif"
FileIconDic.Add "html","../Images/FileIcon/html.gif"
FileIconDic.Add "htm","../Images/FileIcon/html.gif"
FileIconDic.Add "jpg","../Images/FileIcon/jpg.gif"
FileIconDic.Add "jpeg","../Images/FileIcon/jpg.gif"
FileIconDic.Add "pl","../Images/FileIcon/perl.gif"
FileIconDic.Add "perl","../Images/FileIcon/perl.gif"
FileIconDic.Add "zip","../Images/FileIcon/zip.gif"
FileIconDic.Add "rar","../Images/FileIcon/zip.gif"
FileIconDic.Add "gz","../Images/FileIcon/zip.gif"
FileIconDic.Add "doc","../Images/FileIcon/doc.gif"
FileIconDic.Add "xml","../Images/FileIcon/xml.gif"
FileIconDic.Add "xsl","../Images/FileIcon/xml.gif"
FileIconDic.Add "dtd","../Images/FileIcon/xml.gif"
FileIconDic.Add "vbs","../Images/FileIcon/vbs.gif"
FileIconDic.Add "js","../Images/FileIcon/vbs.gif"
FileIconDic.Add "wsh","../Images/FileIcon/vbs.gif"
FileIconDic.Add "sql","../Images/FileIcon/script.gif"
FileIconDic.Add "bat","../Images/FileIcon/script.gif"
FileIconDic.Add "tcl","../Images/FileIcon/script.gif"
FileIconDic.Add "eml","../Images/FileIcon/mail.gif"
FileIconDic.Add "swf","../Images/FileIcon/flash.gif"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>虚拟目录列表</title>
</head>
<link href="../../CSS/css.css" rel="stylesheet">
<script src="../JS/PublicJS.js" language="JavaScript"></script>
<body onselectstart="return false;" topmargin="0" leftmargin="0" oncontextmenu="ClickFileName(document.all('MainTable'));showMenu(MouseRightMenu);return false;">
<table id="MainTable" onClick="ClickFileName(this);" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" class="TempletItem">
  <tr> 
    <td valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="ButtonList"> <div align="center">名称</div></td>
          <td class="ButtonList"><div align="center">大小</div></td>
          <td class="ButtonList"><div align="center">类型</div></td>
          <td class="ButtonList"><div align="center">修改时间</div></td>
        </tr>
        <%
For Each FolderItem in SubFolderObj
%>
        <tr> 
          <td><div align="left"> 
              <table border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td><img src="../Images/Folder.gif" width="18" height="18"></td>
                  <td><span FolderName="<% = FolderItem.Name %>">
                    <% = FolderItem.Name %>
                    </span></td>
                </tr>
              </table>
            </div></td>
          <td><div align="center"> 
              <% = FolderItem.Size %>
              字节 </div></td>
          <td><div align="center">文件夹</div></td>
          <td><div align="center"> 
              <% = FolderItem.DateLastModified %>
            </div></td>
        </tr>
        <%
Next
%>
        <%
For Each FileItem in FileObj
	Dim FileIcon,FileExtName
	FileExtName = Mid(CStr(FileItem.Name),Instr(CStr(FileItem.Name),".")+1)
	FileIcon = FileIconDic.Item(LCase(FileExtName))
	if FileIcon = "" then
		FileIcon = "../Images/FileIcon/unknown.gif"
	end if
%>
        <tr> 
          <td> <div align="left"> 
              <table border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td><img src="<% = FileIcon %>" width="16" height="16"></td>
                  <td><span FileName="<% = FileItem.Name %>">
                    <% = FileItem.Name %>
                    </span></td>
                </tr>
              </table>
            </div></td>
          <td><div align="center"> 
              <% = FileItem.Size %>
              字节 </div></td>
          <td><div align="center"> 
              <% = FileItem.Type %>
            </div></td>
          <td><div align="center"> 
              <% = FileItem.DateLastModified %>
            </div></td>
        </tr>
        <%
Next
%>
      </table></td>
  </tr>
</table>
</td>
</tr> </table>
<!-- 鼠标右键菜单 -->
<div id=MouseRightMenu onclick="ClickMenu(this);" onmouseover="MouseOverRightMenu();" onmouseout="MouseOverRightMenu();" class="menu"> 
  <div class="MouseRightItem" id="UpFile" ExeFunction="OpenWindow('../Inc/UpFileFrame.asp?Path='+UpFilePath,350,150,window);">上传文件</div>
  <hr id="HR2">
  <div class="MouseRightItem" id="SetUpFilePara" ExeFunction="AddFolderOperation();">新建目录</div>
  <div class="MouseRightItem" id="Del" ExeFunction="if (confirm('确定要删除吗？')==true) DelFolderFile();">删除</div>
  <hr id="HR1">
  <div class="MouseRightItem" id="Refresh" ExeFunction="window.location.reload();">刷新</div>
   <hr id="HR2">
  <div class="MouseRightItem" id="Pros" ExeFunction="javascript:window.prompt('本页面路径属性' , '<%=Request.ServerVariables("SCRIPT_NAME")%>');">路径属性</div>
</div>
</body>
</html>
<%
Set FS = Nothing
Set FolderObj = Nothing
Set FileObj = Nothing
Set SubFolderObj = Nothing
Set FileIconDic = Nothing
%>
<script language="JavaScript">
var FolderName='';
var FileName='';
var UpFilePath='<% = UpFilesPath %>';
function ClickFileName(Obj)
{
	for (var i=0;i<Obj.all.length;i++) if (Obj.all(i).className=='TempletSelectItem') Obj.all(i).className='TempletItem';
	if ((event.srcElement.FolderName!=null) ||(event.srcElement.FileName!=null))
	{
		event.srcElement.className='TempletSelectItem';
		if (event.srcElement.FolderName!=null)
		{
			FolderName=event.srcElement.FolderName;
			FileName='';
			Del.className='MouseRightItem';
		}
		if (event.srcElement.FileName!=null)
		{
			FolderName='';
			FileName=event.srcElement.FileName;
			Del.className='MouseRightItem';
		}
	}
	else
	{
		Del.className='MenuItemDisable';
	}
}

function AddFolderOperation()
{
	var ReturnValue=prompt('新建目录名：','');
	if ((ReturnValue!='') && (ReturnValue!=null))
	{
		OpenWindow('FolderFileOperate.asp?Type=AddFolder&Path='+UpFilePath+'/'+ReturnValue,0,0,window);
		window.location.reload();
	}
}

function DelFolderFile()
{
	var ReturnValue='';
	if (FolderName!='')
	{
		OpenWindow('FolderFileOperate.asp?Type=Del&Path='+UpFilePath+'/'+FolderName,0,0,window);
		window.location.reload();
	}
	if (FileName!='')
	{
		OpenWindow('FolderFileOperate.asp?Type=Del&Path='+UpFilePath+'&FileName='+FileName,220,220,window);
		window.location.reload();
	}
}
</script>