
<!--#include file="fsoconfig.asp"-->
<!--#include file="checklogin.asp"-->
<!--#include file="fsofunctions.asp"-->
<%
page=trim(request.querystring("page"))
act=trim(request.querystring("act"))
if page<>"" and isnumeric(page) then
	page=fix(page)
else
	page=1
end if
if path="/" then
	goparent="↑回上级目录..."
else
	goparent="<a href='"&selfname&"?path="&server.urlencode(left(path,instrrev(path,"/",len(path)-1)))&"&ntime="&ntime&"'>↑回上级目录...</a>"
end if
parent_url=server.urlencode(parent_url)
pathurl=server.urlencode(path)
s_folderpath=server.mappath(path)
set obj_fso=server.createobject("scripting.filesystemobject")
if act="paste" and session("act")="copy" and session("basepath")<>s_folderpath and obj_fso.folderexists(s_folderpath)=true then
	n_errfile=0
	n_errfolder=0
	if session("folders")<>"" then
		a_folders=split(session("folders"),chr(9))
		m=ubound(a_folders)
		for i=0 to m
			s_sourcefolder=session("basepath")&"\"&a_folders(i)
			s_targetfolder=s_folderpath&"\"&a_folders(i)
			if obj_fso.folderexists(s_sourcefolder) then
				obj_fso.copyfolder s_sourcefolder,s_targetfolder,true
			else
				n_errfolder=n_errfolder+1
			end if
		next
	else
		m=0-1
	end if
	if session("files")<>"" then
		a_files=split(session("files"),chr(9))
		n=ubound(a_files)
		for i=0 to n
			s_sourcefile=session("basepath")&"\"&a_files(i)
			s_targetfile=s_folderpath&"\"&a_files(i)
			if obj_fso.fileexists(s_sourcefile) then
				obj_fso.copyfile s_sourcefile,s_targetfile,true
			else
				n_errfile=n_errfile+1
			end if
		next
	else
		n=0-1
	end if
elseif act="paste" and session("act")="cut" and session("basepath")<>s_folderpath and obj_fso.folderexists(s_folderpath)=true then
	n_errfile=0
	n_errfolder=0
	if session("folders")<>"" then
		a_folders=split(session("folders"),chr(9))
		m=ubound(a_folders)
		for i=0 to m
			s_sourcefolder=session("basepath")&"\"&a_folders(i)
			s_targetfolder=s_folderpath&"\"&a_folders(i)
			if obj_fso.folderexists(s_sourcefolder) then
				obj_fso.copyfolder s_sourcefolder,s_targetfolder,true
				obj_fso.deletefolder s_sourcefolder,true
			else
				n_errfolder=n_errfolder+1
			end if
		next
	end if
	if session("files")<>"" then
		a_files=split(session("files"),chr(9))
		n=ubound(a_files)
		for i=0 to n
			s_sourcefile=session("basepath")&"\"&a_files(i)
			s_targetfile=s_folderpath&"\"&a_files(i)
			if obj_fso.fileexists(s_sourcefile) then
				obj_fso.copyfile s_sourcefile,s_targetfile,true
				obj_fso.deletefile s_sourcefile,true
			else
				n_errfile=n_errfile+1
			end if
		next
	end if
	session("act")=""
	session("basepath")=""
	session("folders")=""
	session("files")=""
end if
%>
<html>
<head>
<title><%=sysname%>--文件管理</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<meta name="author" content="netasp;EMAIL:netasp@sohu.com">
<style type="text/css">
<!--
body,table,td{font-size:12px;color:#000090;}
body{margin:0 0 1px;padding:0;background:#ffffff url(fsoimg/bgbrick.gif);}
table{width:760px}
table table{width:100%;background:#eeeeee}
td{vertical-align:top;}
table table td{padding-left:4px;vertical-align:middle;background:#ffffff}
img{vertical-align:bottom}
form{margin:0;padding:0}
a{color:#000080;text-decoration:none;}
a:hover{color:#ff3333;text-decoration:underline}
div{width:100%;background:#eeeeee}
.button{width:65px;height:20px;border:solid 1px;border-color:#ffffff #666666 #666666 #ffffff;margin:3px 0;}
.imgbutton{width:32px;height:32px;border:solid 1px #d6d3cc;cursor:hand;}
.imgbt{border:solid 1px;border-color:#ffffff #999999 #999999 #ffffff;cursor:hand;}
//-->
</style>
<script language="javascript">
<!--
function viewfile(path)
{
window.open(path,'','');
}
function editfile(fname)
{
	fname=urlencoding(fname);
	window.open("fsoedit.asp?path=<%=pathurl%>"+fname,'','');
}
function is_edit(fname)
{
	if(window.confirm('你确定该文件为ASCII类型文件，并编辑它吗？'))
		editfile(fname);
}
function dis_edit()
{
	alert('该类型文件为非ASCII文件，无法编辑！');
}
function renameit(fname,act)
{
	var newname=window.prompt("请输入文件(夹) ["+fname+"] 的新名称：","");
	if(newname!=null)
	{
		fname=urlencoding(fname);
		newname=urlencoding(newname);
		window.location.href="fsorename.asp?act="+act+"&path=<%=pathurl%>&fname="+fname+"&newname="+newname+"&epath=<%=pathurl%>&epage=<%=page%>&ntime=<%=ntime%>";
	}
}
function downfile(fname)
{
	fname=urlencoding(fname);
	window.open("downfile.asp?path=<%=pathurl%>"+fname,'','');
}
function delbatch()
{
	if (window.confirm("你真的要删除该文件或目录吗？"))
	{
		document.delthis.submit();
	}
}
function delfile(act,fname)
{
	fname=urlencoding(fname);
	if (window.confirm("你真的要删除该文件或目录吗？")==true)
	{
	window.location.href="fsodel.asp?act="+act+"&path=<%=pathurl%>"+fname+"&epath=<%=pathurl%>&epage=<%=page%>&ntime=<%=ntime%>";
	}
}
function selectall(objname,act)
{
	if(objname==null)
		alert("对不起，当前目录下没有文件（夹）可选择/清除");
	else if(objname.length==null)
		objname.checked=act;
	else
	{
		var n=objname.length;
		for (i=0;i<n;i++)
		{
			objname[i].checked=act;
		}
	}
}
//-->
</script>
<script language="vbscript">
<!--
function urlencoding(vstrin)
    dim i,strreturn,strSpecial
    strSpecial = "!""#$%&'()*+,/:;<=>?@[\]^`{|}~%"
    strreturn = ""
    for i = 1 to len(vstrin)
        thischr = mid(vstrin,i,1)
        if abs(asc(thischr)) < &hff then
        	if thischr=" " then
        		strreturn = strreturn & "+"
            elseif instr(strSpecial,thischr)>0 then
                strreturn = strreturn & "%" & hex(asc(thischr))
            else
                strreturn = strreturn & thischr
            end if
        else
            innercode = asc(thischr)
            if innercode < 0 then
                innercode = innercode + &h10000
            end if
            hight8 = (innercode  and &hff00)\ &hff
            low8 = innercode and &hff
            strreturn = strreturn & "%" & hex(hight8) &  "%" & hex(low8)
        end if
    next
    urlencoding = strreturn
end function
function create_it(act)
	fname=trim(inputbox("请输入要创建的文件(夹)的名称：","输入待创建的文件(夹)名"))
	if fname<>"" then
		fname=urlencoding(fname)
		window.location.href="fsodel.asp?act="&act&"&path=<%=pathurl%>"&fname&"&epath=<%=pathurl%>&page=<%=page%>&ntime=<%=ntime%>"
	end if
end function
//-->
</script>
<head>
<body>
<table align="center" cellspacing=0 style="border:solid 1px;border-color:#f6f6f6 #999999 #999999 #f6f6f6;background:#d6d3cc">
<tr>
<td width="40%" style="border-right:none;padding-left:12px;vertical-align:middle"> 文件管理器</td>
<td align="center" width="40%" style="border-right:none;border-left:none;">


<%if session("act")="copy" or session("act")="cut" then%>

<%end if%>
<img src="fsoimg/refresh.gif" class="imgbutton" onmouseover="this.className='imgbt'" onmouseout="this.className='imgbutton'" onclick="window.location.reload()" alt="刷新">&nbsp;&nbsp;
</td>
<td style="text-align:right;vertical-align:middle;padding-right:12px;border-left:none;">　</td>
</tr>
</table>
<table align="center" cellspacing=0 style="border:solid 1px;border-color:#f6f6f6 #999999 #999999 #f6f6f6;background:#d6d3cc">
<tr>
<td colspan=3 vertical-align="middle">

</td>
</tr>
</table>
<table align="center" border=0 cellspacing=0 cellpadding=1 bordercolor=999999 style="border-collapse: collapse">
<tr>
<%if obj_fso.folderexists(s_folderpath) then%>

<%
	set obj_folder=obj_fso.getfolder(s_folderpath)
	if obj_folder.files.count mod pagesize=0 then
		totalpage=obj_folder.files.count\pagesize
	else
		totalpage=obj_folder.files.count\pagesize+1
	end if
	if page<1 then
		page=1
	end if
	if page>totalpage then
		page=totalpage
	end if

%>

	<td width=100% align="right"><div>　
　

<br>
		</div><table cellspacing=1 border=0>
<%
	i=1
	startnum=(page-1)*pagesize
	for each s_file in obj_folder.files
		if i>startnum then
			response.write "<tr>"&vbcrlf&"<td>"&vbcrlf
			file_type=getname(s_file,".")
			select case file_type
				case "htm","html"
					response.write "<img src='fsoimg/html.gif'> "
				case "css"
					response.write "<img src='fsoimg/css.gif'> "
				case "asp"
					response.write "<img src='fsoimg/asp.gif'> "
				case "txt"
					response.write "<img src='fsoimg/text.gif'> "
				case "jpg","gif","png"
					response.write "<img src='fsoimg/img.gif'> "
				case "mdb"
					response.write "<img src='fsoimg/access.gif'> "
				case "doc"
					response.write "<img src='fsoimg/word.gif'> "
				case "mid","mp3"
					response.write "<img src='fsoimg/midi.gif'> "
				case "zip","rar"
					response.write "<img src='fsoimg/zip.gif'> "
				case "chm"
					response.write "<img src='fsoimg/chm.gif'> "
				case else
					response.write "<img src='fsoimg/unknown.gif'> "
			end select
			Response.Write "<a href=""javascript:viewfile('"&pathurl&"'+urlencoding('"&s_file.name&"'),'','');"">"
			if file_type="jpg" or file_type="gif" then Response.Write "<img border=0 width=80 height=80 src='"&pathurl&s_file.name&"'>"
			response.write s_file.name&"</a></td>"&vbcrlf
			
			select case file_type
				case "zip","rar","tar","exe","gif","jpg","jpe","jpeg","png","bmp","psd","mdb","doc","ppt","xls","mid","mp3","avi","chm"
					response.write "<td>"
				case "txt","bat","c","htm","html","css","js","vbs","inc","stm","shtm","shtml","asp","asa","aspx","asax","ascx","asmx","aspa","php","php3","php4","jsp","cgi"
					response.write "<td >"
				case else
					response.write "<td >"
			end select
			response.write " <a href=""javascript:delfile('delfile','"&s_file.name&"')"">删除</a> <a href=""javascript:downfile('"&s_file.name&"')"">下载</a></td>"&vbcrlf
			response.write "<td>"&s_file.size&"</td>"&vbcrlf
			response.write "<td>"&s_file.datelastmodified&"</td>"&vbcrlf&"</tr>"&vbcrlf
		end if
		if i>startnum+pagesize then
			exit for
		end if
		i=i+1
	next
	%>
		</td>
	</tr>
	<tr>
		<td colspan=4 align=center><%
	if page>1 then
		response.write "<a href='"&selfname&"?path="&pathurl&"&page="&(page-1)&"&ntime="&ntime&"'>上一页</a>　"
	end if
	response.write "共"&obj_folder.files.count&"个文件　当前第 "
	response.write "<select name='jtp' style='line-height:12px;border:none;height:12px;padding:0' onchange="&chr(34)&"window.location.href='"&selfname&"?page='+(this.options.selectedIndex+1)+'&path="&pathurl&"&ntime="&ntime&"'"&chr(34)&">"&vbcrlf
	for i=1 to totalpage
		if i=page then
			response.write "<option selected>"&i&vbcrlf
		else
			response.write "<option>"&i&vbcrlf
		end if
	next
	response.write "</select>"&vbcrlf
	response.write " 页"&vbcrlf
	response.write "　共 "&totalpage&" 页"
	if page<totalpage then
		response.write "　<a href='"&selfname&"?path="&pathurl&"&page="&(page+1)&"&ntime="&ntime&"'>下一页</a> "
	end if
	response.write "</td>"&vbcrlf&"</tr>"&vbcrlf
	response.write "</form>"&vbcrlf&"</table>"&vbcrlf
	set obj_folder=nothing
else
	response.write "<div style='width:100%;padding:25px 0 15px;text-align:center;background:transparent;color:#ff3333;font-weight:600'>文件夹不存在或者你没有访问权限</div>"
end if
set obj_fso=nothing
%>
</td>
</tr>
</table>

</body>
</html>

