<% 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
'==============================================================================
'软件名称：风讯网站信息管理系统
'当前版本：Foosun Content Manager System 2.0 
'最新更新：2004.12
'==============================================================================
'商业注册联系：028-85098980-601,602 技术支持：028-85098980-606、607,客户支持：608
'产品咨询QQ：159410,655071,66252421
'技术支持:所有程序使用问题，请提问到bbs.foosun.net我们将及时回答您
'程序开发：风讯开发组 & 风讯插件开发组
'论坛支持：风讯在线论坛(http://bbs.foosun.net)
'官方网站：www.Foosun.net  演示站点：test.cooin.com    
'网站建设专区：www.cooin.com
'==============================================================================
'免费版本请在新闻首页保留版权信息，并做上本站LOGO友情连接
'==============================================================================
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P0106") 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(true);showMenu(MouseRightMenu);return false;">
<table id="MainTable" onClick="ClickFileName(false);" 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 %>';
var ListObjArray=new Array();
IntialListObjArray();
function IntialListObjArray()
{
	var CurrObj=null,j=1;
	for (var i=0;i<document.all.length;i++)
	{
		CurrObj=document.all(i);
		if ((CurrObj.FileName!=null)||(CurrObj.FolderName!=null))
		{
			if (CurrObj.FileName!=null)
			{
				ListObjArray[ListObjArray.length]=new ListObj(CurrObj,0,j,false);
				j++;
			}
			if (CurrObj.FolderName!=null)
			{
				ListObjArray[ListObjArray.length]=new ListObj(CurrObj,1,j,false);
				j++;
			}
		}
	}
}
function ListObj(Obj,Type,Index,Selected)
{
	this.Obj=Obj;
	this.Index=Index;
	this.Type=Type;
	this.Selected=Selected;
}

function ClickFileName(MouseRight)
{
	var el=event.srcElement;
	var i=0;
	if (!MouseRight)
	{
		if ((event.ctrlKey==true)||(event.shiftKey==true))
		{
			if (event.ctrlKey==true)
			{
				for (i=0;i<ListObjArray.length;i++)
				{
					if (el==ListObjArray[i].Obj)
					{
						if (ListObjArray[i].Selected==false)
						{
							ListObjArray[i].Obj.className='TempletSelectItem';
							ListObjArray[i].Selected=true;
						}
						else
						{
							ListObjArray[i].Obj.className='TempletItem';
							ListObjArray[i].Selected=false;
						}
					}
				}
			}
			if (event.shiftKey==true)
			{
				var MaxIndex=0,ObjInArray=false,EndIndex=0,ElIndex=-1;
				for (i=0;i<ListObjArray.length;i++)
				{
					if (ListObjArray[i].Selected==true)
					{
						if (ListObjArray[i].Index>=MaxIndex) MaxIndex=ListObjArray[i].Index;
					}
					if (el==ListObjArray[i].Obj)
					{
						ObjInArray=true;
						ElIndex=i;
						EndIndex=ListObjArray[i].Index;
					}
				}
				if (MaxIndex!=0)
				{
					for (i=MaxIndex-1;i<EndIndex;i++)
					{
						ListObjArray[i].Obj.className='TempletSelectItem';
						ListObjArray[i].Selected=true;
					}
				}
				else
				{
					if (ElIndex!=-1)
					{
						ListObjArray[ElIndex].Obj.className='TempletSelectItem';
						ListObjArray[ElIndex].Selected=true;
					}
				}
			}
		}
		else
		{
			for (i=0;i<ListObjArray.length;i++)
			{
				if (el==ListObjArray[i].Obj)
				{
					ListObjArray[i].Obj.className='TempletSelectItem';
					ListObjArray[i].Selected=true;
				}
				else
				{
					ListObjArray[i].Obj.className='TempletItem';
					ListObjArray[i].Selected=false;
				}
			}
		}
	}
	else
	{
		var elInSelectArray=false;
		for (i=0;i<ListObjArray.length;i++)
		{
			if (el==ListObjArray[i].Obj)
			{
				if (ListObjArray[i].Selected==true)
				{
					elInSelectArray=true;
				}
			}
		}
		if (!elInSelectArray)
		{
			for (i=0;i<ListObjArray.length;i++)
			{
				if (el==ListObjArray[i].Obj)
				{
					ListObjArray[i].Obj.className='TempletSelectItem';
					ListObjArray[i].Selected=true;
				}
				else
				{
					ListObjArray[i].Obj.className='TempletItem';
					ListObjArray[i].Selected=false;
				}
			}
		}
		GetID();
		var NewsFlag,ClassFlag,SelectIDType=-1;
		ClassFlag=(FolderName!='')?1:0;
		NewsFlag=(FileName!='')?1:0;
		SelectIDType=(ClassFlag&&NewsFlag)?0:SelectIDType;  //栏目ID和新闻ID都不为空------0
		SelectIDType=(!ClassFlag&&!NewsFlag)?1:SelectIDType;  //栏目ID和新闻ID都为空--------1
		SelectIDType=(ClassFlag&&!NewsFlag)?2:SelectIDType;  //栏目ID不为空，新闻ID为空----2
		SelectIDType=(!ClassFlag&&NewsFlag)?3:SelectIDType;  //栏目ID为空，新闻ID不为空----3
		if (SelectIDType==2) SelectIDType=(FolderName.indexOf(',')==-1)?4:SelectIDType;  //只选择了一个栏目----4 
		if (SelectIDType==3) SelectIDType=(FileName.indexOf(',')==-1)?5:SelectIDType;  //只选择了一个新闻----5
		switch (SelectIDType)
		{
			case 0:
				Del.className='MenuItemDisable';
				break;
			case 1:
				Del.className='MenuItemDisable';
				break;
			case 2:
				Del.className='MouseRightItem';
				break;
			case 3:
				Del.className='MouseRightItem';
				break;
			case 4:
				Del.className='MouseRightItem';
				break;
			case 5:
				Del.className='MouseRightItem';
				break;
			default:
			
		}
	}
}

function GetID()
{
	FileName='';
	FolderName='';
	for (i=0;i<ListObjArray.length;i++)
	{
		if (ListObjArray[i].Selected==true)
		{
			if (ListObjArray[i].Type==0)
			{
				if (FileName=='') FileName=ListObjArray[i].Obj.FileName;
				else FileName=FileName+'***'+ListObjArray[i].Obj.FileName;
			}
			else
			{
				if (FolderName=='') FolderName=ListObjArray[i].Obj.FolderName;
				else FolderName=FolderName+'***'+ListObjArray[i].Obj.FolderName;
			}
		}
	}
}

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

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