<!--#include file="../login/0.asp"-->
<!--#include file="../../mycartconn/conn.asp" -->
<!--#INCLUDE FILE="HXINCLUDE/HXINCLUDEHEAD.ASP"-->
<!--#INCLUDE FILE="HXINCLUDE/HX_SYSTEM.ASP"-->
<!--#INCLUDE FILE="HXINCLUDE/HX_FILEICON.ASP"-->
<%if not IsObjInstalled("Scripting.FileSystemObject") then HX_GoBack "对不起,此服务器不支持FSO,所以不能使用此功能!",""%>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<title>网络硬盘</title>
<script> 
function newimg(imgurl) { 
newwin=window.open('showpic.asp?img='+imgurl,'picshow','top=150,left=300,width=300,height=300'); //先新打开一个小窗口
} 
</script>
</head>
<body>
<%
Function getOwner(nstr)
	If nstr<>"" then
		Set rst= Server.CreateObject("ADODB.Recordset")
		sqlt="select id from A_slide where slide_images like '%"&nstr&"%'"
		rst.open sqlt,conn,1,1
		If Not (rst.bof And rst.eof) Then
			getOwner=""
		Else
			getOwner="&nbsp;<img src='HXimages/FileIcon/delete.gif' align='absmiddle' border=0>"
		End if
	Else
		getOwner=""
	End if
End Function

Function isOwner(nstr)
	isOwner=true
	If nstr<>"" then
		Set rst= Server.CreateObject("ADODB.Recordset")
		sqlt="select id from A_slide where slide_images like '%"&nstr&"%'"
		rst.open sqlt,conn,1,1
		If Not (rst.bof And rst.eof) Then
			isOwner=true
		Else
			isOwner=false
		End if
	Else
		isOwner=true
	End if
End Function

LOGINUSERNAME="mofahe"   '设置默认登陆用户

NetDiskPath="..\..\UploadFiles"


'on error resume next
ComeUrl=Cstr(Request.ServerVariables("HTTP_REFERER"))
if ComeUrl<>"" then
   ComeUrl=PathFileReplace(ComeUrl)
end if
'response.Write ComeUrl
action=LCase(Trim(Request("action")))
ThisDir=PathReplace(Trim(Request("ThisDir")))&"\"
ThisDir=Replace(ThisDir,"?","200")
TopDir=NetDiskPath&"\"
TopThisDir=PathReplace(TopDir & ThisDir)

Session("FileUpLoadPath")=empty
strTitle=OutName&"网络硬盘"
if ThisDir<>"" then
  if left(ThisDir,1)<>"\" then ThisDir="\"&ThisDir
end If

'CreateDir TopDir
Set Fso=Server.CreateObject("Scripting.FileSystemObject")
Select Case action
Case "del"	Call DelAll
Case "rname" Call Rname
Case "newfolder" Call NewFolder
Case "cutfile" Call CopyFile
Case "copyfile" Call CopyFile
Case "paste" Call Paste
Case "clear" Call Clear
Case "searchfile" MySearchFile
Case Else Call Main
End Select
Set Fso = Nothing

Sub Main()
	'On Error Resume Next
	If Fso.FolderExists(server.MapPath(TopDir))=False Then
		Set	Fso = Nothing
		Response.write "<BR><BR><BR><div align=center>找不到目录，可能参数配置错误！<a href='javascript:history.go(-1);'>返回</a></div>"
		Response.end
	End If
	Set FsoFile = Fso.GetFolder(Server.MapPath(TopDir))
	AllFileSize = FsoFile.size
	Session("AllFileSize")=AllFileSize
	Set	FsoFile = Nothing
	if TopThisDir<>"" Then
	   'CreateDir TopThisDir
       TopThisDir=PathReplace(TopThisDir)
    end If
	If Fso.FolderExists(server.MapPath(TopThisDir))=False Then
		Set	Fso = Nothing
		Response.write "<BR><BR><BR><div align=center>找不到目录，可能参数配置错误！<a href='javascript:history.go(-1);'>返回</a></div>"
		Response.end
	End If
	Set	FsoFile = Fso.GetFolder(Server.MapPath(TopThisDir))
	Dim FolderNuns,FileNums
	FolderNuns=FsoFile.SubFolders.count
	FileNums=FsoFile.Files.count
	TotalPut=FolderNuns+FileNums
%>
<script language=javascript>
function Checked()
{
	var j = 0
	for(i=0;i < document.form.elements.length;i++){
		if(document.form.elements[i].name == "FileId" || document.form.elements[i].name == "FolderId"){
			if(document.form.elements[i].checked){
				j++;
			}
		}
	}
	return j;
}
function CheckAll1()
{
	for(i=0;i<document.form.elements.length;i++)
	{
		if(document.form.elements[i].checked){
			document.form.elements[i].checked=false;
			document.form.CheckAll.checked=false;
		}
		else{
			document.form.elements[i].checked = true;
			document.form.CheckAll.checked = true;
		}
	}
}
function DelAll()
{
	if(Checked()  <= 0){
		alert("您必须选择其中的一个文件或文件夹");
	}	
	else{
		if(confirm("确定要删除选择的文件或文件夹么？\n此操作不可以恢复！")){
			form.action="?action=Del";
			form.submit();
		}
	}
}

function SearchFile()
	{
		var FileName = window.prompt("请输入搜索的文件名", "");	
		if(FileName!=null)
		{			 
		  if(IsNotStr(FileName)==0) 
		        {	
					form.action="?action=SearchFile&FileName="+FileName;
					form.target="_self";
					form.submit();
				  }
				  else
				  {				  
				  alert('文件或文件夹名称中不能含有 /:|& 特殊字符');
				  }
		 }	
			
	  }
			
function Rname()
{
	if(Checked() == 0){
		alert("您必须选择一个文件或文件夹");
	}
	else{
		if(Checked() != 1){
			alert("只能选择一个文件或一个文件夹");
		}
		else{
			for(i=0;i < document.form.elements.length;i++){
				if(document.form.elements[i].name == "FolderId" && document.form.elements[i].checked){
					var j = prompt("请输入新文件夹名",document.form.elements[i].value)
					break;					
				}
				else if(document.form.elements[i].name == "FileId" && document.form.elements[i].checked){
					var j = prompt("请输入新文件名",document.form.elements[i].value.split(".")[0])
					break;
				}
			}
			
			if(j != "" && j != null)
			{
				form.action="?action=Rname&NewName=" + j;
                form.target="_self";
				form.submit();				
			}	
			
			
		}
	}
}
function newFolder()
	{
		var folderName = window.prompt("请输入文件夹名称", "");	
		if(folderName!=null)
		{		
					form.action="?action=newFolder&NewName="+folderName;
					form.target="_self";
					form.submit();
					}
			else{
			alert('请输入文件夹名称');
			}	
		
			}
function CutFile()	
{
  if(Checked()  <= 0)
   {
	alert("您必须选择其中的一个文件或文件夹");
	}	
	else{
    form.action='?action=CutFile';
	form.submit();
	   }
}		
			
function CopyFile()
{
 if(Checked()  <= 0)
   {
	alert("您必须选择其中的一个文件或文件夹");
	}	
	else{
    form.action='?action=copyFile';
	form.submit();
	}
}

function Paste()
{
    form.action='?action=paste';
	form.submit();
}

function ShareFile(fname)
{  if(Checked()  <= 0){
		alert("您必须选择其中的一个文件或文件夹");
	}	
	else{
    form.action='NetDiskShare.asp?path='+'<%=UrlEncoded(trim(replace(ThisDir,"\","\/")))%>';
	form.submit();
	}
}

function downfile(fname)
{
	fname='<%=UrlEncoded(trim(replace(ThisDir,"\","\/")))%>'+fname;
	location.href="Downfile.asp?path="+fname;
}

function pageGoto(nUrl)
{
	location.href=nUrl;
}

function IsNotStr(w)
{  var str="/:|&";
    var j = 0;
   for(i=0;i<w.length;i++){
		if(str.indexOf(w.substr(i,1)) != -1){
			j++;
		}
   }
	return j;
  }
</script>
<table cellpadding='2' cellspacing='1' border='0' class='border' align=center>
<tr class="title"><td align="left"><%=strTitle%></td>
 </tr>
 <tr class="titletdbg"> 
  <td>使用空间：<font color="#ff0000"><%=GetSize(AllFileSize,"b")%></font><strong></strong>&nbsp;&nbsp;</td>
 </tr>
 <tr class="titletdbg"> 
  <td>当前目录：主目录<%=PathReplace(ThisDir)%>&nbsp;&nbsp;&nbsp;&nbsp;占用空间：<font color="#ff0000"><%=GetSize(FsoFile.size,"b")%></font>&nbsp;&nbsp;文件夹：<font color=blue><%=FolderNuns%></font>&nbsp;个，文件：<font color=blue><%=FileNums%></font>&nbsp;个 　共 <font color=blue><%=TotalPut%></font> 个</td>
  </tr>
</table>
<br>
<table cellpadding='2' cellspacing='1' border='0' class='border' align=center>
  <tr class="titletdbg">
	<td align=center><a href="?ThisDir=<%=GetUpDir%>"><img title="向上一级" src="pics/up.gif" border=0></a></td>
	<td align=center><a href="?ThisDir=" title=返回到主目录><img title="根目录" src="pics/home.gif" border=0></a></td>
	<td align=center><a   href="javascript:window.location.reload();"><img title="刷新本页" src="pics/fs_refresh.gif" border=0></a></td>
	<td align=center><a href='javascript:newFolder()'><IMG alt="新文件夹" src="pics/new_folder.gif" border="0"></a></td>
	<td align=center><a href="javascript:DelAll();"><img title="删除" src="pics/delete_big.gif"  border=0></a></td>
	<td align=center><a href="javascript:CutFile();"><img title="剪切" src="pics/cut.gif" border=0></a></td>
	<td align=center><a href="javascript:CopyFile();"><img itle="复制" src="pics/copy.gif" border=0></a></td>
	<td align=center><a href="javascript:<%if session("folders")<>"" or session("files")<>"" then response.write "Paste()" else response.write "alert('剪切板上没有数据，不能粘贴！\n请先剪切或复制文件夹或文件，然后进行此操作！')"%>;"><img title="粘贴" src="pics/pas.gif" border=0></a></td>
	<td align=center><a href="javascript:SearchFile();"><img title="搜索文件" src="pics/ab_search.gif" border=0></a></td>
	<td align=center><a href="javascript:Rname();"><img title="重命名" src="pics/spic.gif" border=0></a></td>
	<td align=center><a href="javascript:ShareFile();"><img title="共享" src="pics/sharing.gif" border=0></a></td>
  </tr>
</table>
<br>
<table cellpadding='2' cellspacing='1' border='0' class='border' align=center>	
	<form name="form" method="post" >
	 <tr class=title>
	   <td width="30" height="25" align="center"><input type="checkbox" name="CheckAll" value="checkbox" onClick="CheckAll1()" title=全部选择></td>
	   <td width="360" align="center">文件/文件夹名</td>
	  <td width="124" align="center">文件大小</td>
	  <td width="147" align="center">最后修改时间</td>
	  <td width="113" align="center">可用操作</td>
	 </tr>
	 <% 
	Const MaxPerPage_M=10
	if request("page")<>"" then
		currentPage=cint(request("page"))
	else
		currentPage=1
	end if
    totalPut_M=FolderNuns
	if currentpage<1 then
   		currentpage=1
   	end if
   	if (currentpage-1)*MaxPerPage_M>totalPut_M then
		if (totalPut_M mod MaxPerPage_M)=0 then
	  		currentpage= totalPut_M \ MaxPerPage_M
	  	else
	      	currentpage= totalPut_M \ MaxPerPage_M + 1
		end if

    end if
	if currentPage=1 then
   	else
   	   	if (currentPage-1)*MaxPerPage_M<totalPut_M then
       	else
        	currentPage=1
    	end if
	end if



   	dim c
	FileCount=0

	For Each DirFolder in FsoFile.SubFolders
	    c=c+1
		if FileCount>=MaxPerPage_M then
			exit for
		elseif c>MaxPerPage_M*(CurrentPage-1) Then
		
			Call DirFolderUpdate(ThisDir,trim(DirFolder.name),DirFolder.size,DirFolder.DateLastModified,LOGINUSERNAME,"")	  
	%>
	 <tr class="titletdbg"> 
	  <td align="center" width="30"> 
	   <input type="checkbox" name="FolderId" value="<%=DirFolder.name%>" class=radio>	  </td>
	  <td>&nbsp;<a href="?ThisDir=<%=ThisDir & DirFolder.name%>"><img src="<%=ShareFolderImg(DirFolder.name)%>" border=0 width="16" height="16" align="absmiddle"></a>&nbsp;<a href="?ThisDir=<%=ThisDir & DirFolder.name%>"><%=DirFolder.name%></a>　<%=UploadPersonFolderOut(LOGINUSERNAME,DirFolder.name,ThisDir,1)%></td>
	  <td align="center" width="124"><%=GetSize(DirFolder.size,"b")%></td>
	  <td align="center" width="147">&nbsp;<%=DirFolder.DateLastModified%></td>
	  <td align="center" width="113"><a href="?ThisDir=<%=ThisDir & DirFolder.name%>">打开</a></td>
	 </tr>
	 <%
			FileCount=FileCount+1
		end if
	Next



	If totalPut_M>0 then
	dim n, i,strTemp
	if totalPut_M mod MaxPerPage_M=0 then
    	n= totalPut_M \ MaxPerPage_M
  	else
    	n= totalPut_M \ MaxPerPage_M+1
  	end if
  	strTemp= "<tr class='titletdbg'><td align='center' colspan=5><table width='100%' cellpadding=0 cellspacing=0 align='center'><tr><td align=right class=forumrowHighlight>"
	strTemp=strTemp & "共 <b>" & totalPut_M & "</b> 个文件，&nbsp;&nbsp;&nbsp;"
  	if CurrentPage<2 then
    		strTemp=strTemp & "首页 上一页&nbsp;"
  	else
    		strTemp=strTemp & "<a href='Netdisk.asp?ThisDir="&ThisDir&"&page_F="&CurrentPage_F&"&page=1'>首页</a>&nbsp;"
    		strTemp=strTemp & "<a href='Netdisk.asp?ThisDir="&ThisDir&"&page_F="&CurrentPage_F&"&page=" & (CurrentPage-1) & "'>上一页</a>&nbsp;"
  	end if

  	if n-currentpage<1 then
    		strTemp=strTemp & "下一页 尾页"
  	else
    		strTemp=strTemp & "<a href='Netdisk.asp?ThisDir="&ThisDir&"&page_F="&CurrentPage_F&"&page=" & (CurrentPage+1) & "'>下一页</a>&nbsp;"
    		strTemp=strTemp & "<a href='Netdisk.asp?ThisDir="&ThisDir&"&page_F="&CurrentPage_F&"&page=" & n & "'>尾页</a>"
  	end if
   	strTemp=strTemp & "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
    strTemp=strTemp & "&nbsp;<b>" & MaxPerPage_M & "</b>" & "个文件/页"
	strTemp=strTemp & "&nbsp;转到：<select name='page' size='1' onchange='javascript:pageGoto(""Netdisk.asp?ThisDir="&ThisDir&"&page_F="&currentPage_F&"&page=""+document.form.page.options[document.form.page.selectedIndex].value)'>"   
    for i = 1 to n   
   		strTemp=strTemp & "<option value='" & i & "'"
		if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
		strTemp=strTemp & ">第" & i & "页</option>"   
	next
	strTemp=strTemp & "</select>"
	strTemp=strTemp & "</td></tr></table></td></tr>"
	response.write strTemp
	End if

	If Request("ThisDir")="" Or  Request("ThisDir")="\" Then
		MaxPerPage_F=10
	Else
		MaxPerPage_F=20
	End If

	if request("page_f")<>"" then
		currentPage_F=cint(request("page_f"))
	else
		currentPage_F=1
	end if
    totalPut_F=FileNums
	if currentPage_F<1 then
   		currentPage_F=1
   	end if
   	if (currentPage_F-1)*MaxPerPage_F>totalPut_F then
		if (totalPut_F mod MaxPerPage_F)=0 then
	  		currentPage_F= totalPut_F \ MaxPerPage_F
	  	else
	      	currentPage_F= totalPut_F \ MaxPerPage_F + 1
		end if

    end if
	if currentPage_F=1 then
   	else
   	   	if (currentPage_F-1)*MaxPerPage_F<totalPut_F then
       	else
        	currentPage_F=1
    	end if
	end if


   	c=0
	FileCount=0
	For Each DirFiles in FsoFile.Files
	    c=c+1
		if FileCount>=MaxPerPage_F then
			exit for
		elseif c>MaxPerPage_F*(currentPage_F-1) Then
			Call DirFileUpdate(ThisDir,trim(DirFiles.name),DirFiles.size,DirFiles.DateLastModified,LOGINUSERNAME,"")
	%>
	 <tr class="titletdbg"> 
	  <td align="center" width="30"> 
	   <input type="checkbox" name="FileId" value="<%=DirFiles.name%>" class=radio>	  </td>
	  <td>&nbsp;<%=ShareFileImg(DirFiles.name)%>
	  <a href="javascript:newimg('<%=trim(Replace(ThisDir,"\","/")&DirFiles.name)%>');">	  
	  <img src="HXIMAGES/fileicon/<%=GetFileIcon(DirFiles.name)%>" border=0 width="16" height="16" align="absmiddle" alt="<%=DirFiles.type%>"><%=getOwner(DirFiles.name)%>&nbsp;<%=DirFiles.name%></a>　<%=UploadPersonFileOut(LOGINUSERNAME,DirFiles.name,ThisDir,1)%></td>
	  <td align="center" width="124"><%=GetSize(DirFiles.size,"b")%></td>
	  <td align="center" width="147"><%=DirFiles.DateLastModified%></td>
	  <td align="center" width="113">
	 <a href="javascript:newimg('<%=trim(Replace(ThisDir,"\","/")&DirFiles.name)%>');">查看</a> | <a href="?action=Del&ThisDir=<%=ThisDir%>&FileId=<%=DirFiles.name%>" onClick="return confirm('确定要删除选择的文件么？\n此操作不可以恢复！')">删除</a>	  </td>
	 </tr>
	 <%
			FileCount=FileCount+1
		end if
	Next

	If totalPut_F>0 then
	dim n_F
	strTemp=""
	if totalPut_F mod MaxPerPage_F=0 then
    	n_F= totalPut_F \ MaxPerPage_F
  	else
    	n_F= totalPut_F \ MaxPerPage_F+1
  	end if
  	strTemp= "<tr class='titletdbg'><td align='center' colspan=5><table width='100%' cellpadding=0 cellspacing=0 align='center'><tr><td align=right class=forumrowHighlight>"
	strTemp=strTemp & "共 <b>" & totalPut_F & "</b> 个文件，&nbsp;&nbsp;&nbsp;"
  	if currentPage_F<2 then
    		strTemp=strTemp & "首页 上一页&nbsp;"
  	else
    		strTemp=strTemp & "<a href='Netdisk.asp?ThisDir="&ThisDir&"&page="&currentPage&"&page_F=1'>首页</a>&nbsp;"
    		strTemp=strTemp & "<a href='Netdisk.asp?ThisDir="&ThisDir&"&page="&currentPage&"&page_F=" & (currentPage_F-1) & "'>上一页</a>&nbsp;"
  	end if

  	if n_F-currentPage_F<1 then
    		strTemp=strTemp & "下一页 尾页"
  	else
    		strTemp=strTemp & "<a href='Netdisk.asp?ThisDir="&ThisDir&"&page="&currentPage&"&page_F=" & (currentPage_F+1) & "'>下一页</a>&nbsp;"
    		strTemp=strTemp & "<a href='Netdisk.asp?ThisDir="&ThisDir&"&page="&currentPage&"&page_F=" & n_F & "'>尾页</a>"
  	end if
   	strTemp=strTemp & "&nbsp;页次：<strong><font color=red>" & currentPage_F & "</font>/" & n_F & "</strong>页 "
    strTemp=strTemp & "&nbsp;<b>" & MaxPerPage_F & "</b>" & "个文件/页"
	strTemp=strTemp & "&nbsp;转到：<select name='page_F' size='1' onchange='javascript:pageGoto(""Netdisk.asp?ThisDir="&ThisDir&"&page="&currentPage&"&page_F=""+document.form.page_F.options[document.form.page_F.selectedIndex].value)'>" 
    for i = 1 to n_F   
   		strTemp=strTemp & "<option value='" & i & "'"
		if cint(currentPage_F)=cint(i) then strTemp=strTemp & " selected "
		strTemp=strTemp & ">第" & i & "页</option>"   
	next
	strTemp=strTemp & "</select>"
	strTemp=strTemp & "</td></tr></table></td></tr>"
	response.write strTemp
	End if

	if TotalPut<=0 then response.write "<tr><td height=25 colspan=5 align=center>此文件夹下没有文件</td></tr>"
	%>
<input type="hidden" name="ThisDir" value="<%=ThisDir%>">
	</form> 
</table>
</td></tr> 
</table>
<%
Set FsoFile = Nothing
End Sub




Sub Clear()     '*********************************一键清理无用图片
	'On Error Resume Next
	If Fso.FolderExists(server.MapPath(TopDir))=False Then
		Set	Fso = Nothing
		Response.write "<BR><BR><BR><div align=center>找不到目录，可能参数配置错误！<a href='javascript:history.go(-1);'>返回</a></div>"
		Response.end
	End If
	if TopThisDir<>"" Then
       TopThisDir=PathReplace(TopThisDir)
    end If
	If Fso.FolderExists(server.MapPath(TopThisDir))=False Then
		Set	Fso = Nothing
		Response.write "<BR><BR><BR><div align=center>找不到目录，可能参数配置错误！<a href='javascript:history.go(-1);'>返回</a></div>"
		Response.end
	End If

	Set	FsoFile = Fso.GetFolder(Server.MapPath(TopThisDir))
	FileNum=0
	For Each DirFiles in FsoFile.Files
		If datediff("n",cdate(DirFiles.DateLastModified),now())>60 then
			If Not isOwner(DirFiles.name) Then
				FilePath = Server.MapPath(TopThisDir & DirFiles.name)
				If Fso.FileExists(FilePath) then
					Fso.DeleteFile FilePath,true
					FileNum = FileNum + 1
				End If
			end If
		End if
	Next

	Set FsoFile = Nothing
	Response.write "<BR><BR><BR><div align=center>共清理掉 <font color=red><b>"&FileNum&"</b></font> 张图片， <a href='javascript:history.go(-1);'>返回</a></div>"
	Response.end
End Sub



Sub MySearchFile()
    keywords=Request("FileName")
	
 %>
 <script>
 function downfile(fname)
{
	window.open('Downfile.asp?path='+fname,'','');
    window.close;
}
 </script>
<table cellpadding='2' cellspacing='1' border='0' class='border' align=center><tr><td class="Navigation" colspan="3">搜索文件　　　　
  <a href="NetDisk.asp">网络硬盘</a></td>
 </tr>
	 <tr class=title>
	  <td width="475" align="center">目录和文件</td>
	  <td width="121" align="center">文件大小</td>
	  <td width="180" align="center">最后修改时间</td>
	 </tr>
	 <%
	 SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and DirName like '%"&keywords&"%' or FileName like '%"&keywords&"%'")
	 if rs.recordcount>0 then
	    rs.PageSize =15 '每页记录条数
	iCount=rs.RecordCount '记录总数
	iPageSize=rs.PageSize
    	maxpage=rs.PageCount 
    	page=request("page")
    
    if Not IsNumeric(page) or page="" then
        page=1
    else
        page=cint(page)
    end if
    
    if page<1 then
        page=1
    elseif  page>maxpage then
        page=maxpage
    end if
    
    rs.AbsolutePage=Page

	if page=maxpage then
		x=iCount-(maxpage-1)*iPageSize
	else
		x=iPageSize
	end if
	ii=0
	do while not rs.EOF
	 %>
	 <tr height="25" class=titletdbg> 
	  <td><a href="<%
	if rs("DirName")<>"" then
	   response.Write "netdisk.asp?ThisDir="&rs("Postion")&rs("DirName")
	elseif rs("FileName")<>"" then
	   response.Write "javascript:newimg('"&trim(rs("Postion"))&trim(rs("FileName"))&"');"
	end if
	%>"><%=rs("Postion")&HX_ColorOn(rs("DirName"),keywords)&HX_ColorOn(rs("FileName"),keywords)%></a></td>
	  <td align="center" width="121"><%=GetSize(rs("FileSize"),"b")%></td>
	  <td align="center" width="180"><%=rs("LastTime")%></td>
	 </tr>
	 <%
	   ii=ii+1
	  if ii>=rs.PageSize then Exit Do
	  rs.movenext
      loop
      call PageControl(iCount,maxpage,page,"border=0 align=right bgcolor=f1f1f1","<p align=right>",5)
	  else
	    response.write "<tr><td colspan=5 align=center class=titletdbg>没有搜索到你要找到文件或文件夹！</td></tr>"
	   end if
	  call HX_RSClose(rs) 
	%>
</table></td></tr> 
</table> 
 <%
End Sub


Function GetUpDir()
	Dim strDir,strDir2,i
	strDir=""
	If ThisDir = "" then Exit Function
	strDir2=ThisDir
	strDir2=Split(strDir2,"\")
	for i=0 to Ubound(strDir2)-1
		if i<Ubound(strDir2)-1 then strDir=strDir & strDir2(i) & "\"
	next
	GetUpDir=strDir
End Function

Sub DelAll()
	Dim FolderId,FileId,FileNum,FolderNum,FilePath,FolderPath
	Dim FsoFolder,sSize
	FolderId = Split(Request.Form("FolderId"),",")
	FileId = Trim(Request("FileId"))
	FileNum=0
	FolderNum=0
	if TopThisDir<>"" then
       TopThisDir=PathReplace(TopThisDir)
    end if
	If instr(FileId,",")>0 then 
		FileId = Split(FileId,",")
		If Ubound(FileId) > -1 then
			For i = 0 to Ubound(FileId)
				FilePath = Server.MapPath(PathReplace(TopThisDir & Trim(FileId(i))))
				If Fso.FileExists(FilePath) then
					Fso.DeleteFile FilePath,true
			        DirFileDel LOGINUSERNAME,Trim(FileId(i)),PathReplace(ThisDir)
					FileNum = FileNum + 1
				End If
			Next
		End If		
	else
		FilePath = Server.MapPath(PathReplace(TopThisDir & FileId))
		If Fso.FileExists(FilePath) then
			Fso.DeleteFile FilePath,true
			DirFileDel LOGINUSERNAME,FileId,PathReplace(ThisDir)
			FileNum = FileNum + 1
		End If
	end if

	If Ubound(FolderId) > -1 then
	    Msg=""
		For i = 0 to Ubound(FolderId)
			FolderPath = Server.MapPath(PathReplace(TopThisDir & Trim(FolderId(i))))
			If Fso.FolderExists(FolderPath) then
				Set FsoFolder = Fso.GetFolder(FolderPath)
				if FsoFolder.size <=0 then
				   Fso.DeleteFolder FolderPath,true
				   DirFolderDel LOGINUSERNAME,FolderId(i),PathReplace(ThisDir)
				   FolderNum = FolderNum + 1
				else
				   Msg=Msg&"《"&Trim(FolderId(i))&"》"
				end if
			End If
		Next		
	End If
	if Msg<>"" then Msg=Msg&"下有文件或文件夹,故不能删除\n请清空里面的文件再删除!"
HX_GoBack "\n成功删除 "& FileNum &" 个文件\n成功删除 "& FolderNum &" 个文件夹\n\n"&Msg,ComeUrl
End Sub
Sub Rname()
	FolderName = Trim(Request("FolderId"))
	FileName = Trim(Request("FileId"))
	NewName = FileReplace(Trim(Request("NewName")))
	if TopThisDir<>"" then TopThisDir=PathReplace(TopThisDir)
	if NewName="" then HX_GoBack "请输入新文件名！",ComeUrl
	If len(FolderName) <> 0 then
		Conn.execute("update HX_NetDiskFolderOrFile set DirName='"&NewName&"' where UserName='"&LOGINUSERNAME&"' and DirName='"&FolderName&"' and Postion='"&PathReplace(ThisDir)&"'")
		SET URS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion like '%\"&FolderName&"\%'")
		if URS.recordcount>0 then
          do until URS.eof
		   URS("Postion")=replace(URS("Postion"),"\"&FolderName&"\","\"&NewName&"\")
		   URS.update
		  URS.movenext
		  loop 
		end if
		Conn.execute("update HX_NetDiskFolderOrFile set DirName='"&NewName&"' where UserName='"&LOGINUSERNAME&"' and DirName='"&FolderName&"' and Postion='"&PathReplace(ThisDir)&"'")
		strNewName = Server.MapPath(PathReplace(TopThisDir & NewName))
		OldName = Server.MapPath(PathReplace(TopThisDir & FolderName))
		If not Fso.FolderExists(strNewName) then
			Fso.MoveFolder OldName,strNewName
			HX_GoBack "文件夹“"& FolderName &"”已经成功改名为“"& NewName &"”",ComeUrl
		Else
			HX_GoBack "有同名文件夹，请换个文件夹名试试！",ComeUrl
		End If
	End If
	If len(FileName) <> 0 then
		FileExt=Split(FileName,".")
		NewFileExt=Trim(FileExt(Ubound(FileExt)))
		if Instr(NewName,".")>0 then
			HX_GoBack "文件名中不能带“.”，换个文件名！",ComeUrl
			Response.end
		end if
		NewName=NewName & "." & NewFileExt
		Conn.execute("update HX_NetDiskFolderOrFile set FileName='"&NewName&"' where UserName='"&LOGINUSERNAME&"' and FileName='"&FileName&"' and Postion='"&PathReplace(ThisDir)&"'")
		strNewName = Server.MapPath(PathReplace(TopThisDir & NewName))
		OldName = Server.MapPath(PathReplace(TopThisDir & FileName))
		If not Fso.FileExists(strNewName) then
			Fso.MoveFile OldName,strNewName
			HX_GoBack "文件“"& FileName &"”已经成功改名为“"& NewName &"”",ComeUrl
		Else
			HX_GoBack "有同名文件，请换个文件名试试！",ComeUrl
		End If
	End If
End Sub

Function NewFolder()
	NewName=request("NewName")
	if NewName="" then HX_GoBack "请输入新文件名！",ComeUrl
	If len(NewName) <> 0 then
		strNewName = Server.MapPath(PathReplace(TopThisDir & NewName))
		If not Fso.FolderExists(strNewName) then
			Fso.CreateFolder strNewName
			HX_GoBack "文件夹“"&NewName &"”新建成功！",ComeUrl
		Else
			HX_GoBack "此文件夹已存在，请换个文件夹名试试！",ComeUrl
		End If
	End If
End Function


Function CopyFile()
   dim basepath,n_folder,n_file,folder_name,file_name
   basepath=TopThisDir
   if basepath<>"" then basepath=PathReplace(basepath)
	session("folders")=""
	session("files")=""
	n_folder=0
	n_file=0
	for each folder_name in request.Form("FolderId")
		session("folders")=session("folders")&chr(9)&folder_name
		n_folder=n_folder+1
	next
	if left(session("folders"),1)=chr(9) then
		session("folders")=right(session("folders"),len(session("folders"))-1)
	end if
	for each file_name in Request("FileId")
		session("files")=session("files")&chr(9)&file_name
		n_file=n_file+1
	next
	if left(session("files"),1)=chr(9) then
		session("files")=right(session("files"),len(session("files"))-1)
	end if
	if session("folders")="" and session("files")="" then
		session("action")=""
		session("basepath")=""
		HX_GoBack "你没有选中任何文件和文件夹哦！",""
	else
		session("action")=action
		session("basepath")=server.mappath(basepath)&"\"
		response.redirect ComeUrl
	end if
End Function

Function Paste()
    dim n_errfile,n_errfolder,m,a_files,a_folders,s_sourcefolder,n,s_folderpath,s_targetfolder
     n_errfile=0:n_errfolder=0:s_folderpath=TopThisDir
	 NetDiskIsNot ComeUrl
   Select case session("action")
    Case "copyfile"
	 if session("folders")<>"" then
		a_folders=split(session("folders"),chr(9))
		m=ubound(a_folders)
		for i=0 to m
			s_sourcefolder=PathReplace(session("basepath")&"\"&a_folders(i))
			s_targetfolder=PathReplace(s_folderpath&a_folders(i))
			if fso.folderexists(s_sourcefolder) then
				fso.copyfolder s_sourcefolder,server.mappath(s_targetfolder),true
			else
				n_errfolder=n_errfolder+1
			end if
		next
	else
		m=0-1
	end if
	
	dim s_sourcefile,s_targetfile
	if session("files")<>"" then
		a_files=split(session("files"),chr(9))
		n=ubound(a_files)
		for i=0 to n
			s_sourcefile=PathReplace(session("basepath")&"\"&a_files(i))
			s_targetfile=PathReplace(s_folderpath&a_files(i))
			if fso.fileexists(s_sourcefile) then
				fso.copyfile s_sourcefile,server.mappath(s_targetfile),true
			else
				n_errfile=n_errfile+1
			end if
		next
	else
		n=0-1
	end if
   Case "cutfile"
	 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 fso.folderexists(s_sourcefolder) then
				s_sourcefolder=PathReplace(session("basepath")&"\"&a_folders(i))
			    s_targetfolder=PathReplace(s_folderpath&a_folders(i))
				fso.copyfolder s_sourcefolder,server.mappath(s_targetfolder),true
				fso.deletefolder s_sourcefolder,true
				DirFolderDel LOGINUSERNAME,a_folders(i),replace(session("basepath"),server.mappath(TopDir),"")
			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=PathReplace(session("basepath")&"\"&a_files(i))
			s_targetfile=PathReplace(s_folderpath&a_files(i))
			if fso.fileexists(s_sourcefile) then
				fso.copyfile s_sourcefile,server.mappath(s_targetfile),true
				fso.deletefile s_sourcefile,true
				DirFileDel LOGINUSERNAME,a_files(i),replace(session("basepath"),server.mappath(TopDir),"")
			else
				n_errfile=n_errfile+1
			end if
		next
	else
		n=0-1
	end if
	session("action")=""
	session("basepath")=""
	session("folders")=""
	session("files")=""
   End Select
   response.redirect ComeUrl
End Function
%>
</body>
