<!--#include file="setup.asp"-->
<%
Dim FSO,f,j,i
Dim FolderName,FolderSize,FolderTime
Dim filename,FileType,FileSize,FileTime
Dim maxperpage,strFileName,CurrentPage
Dim FileCount,TotleSize,totalPut,Path
Dim TruePath,FsoDir,CurrentDir,ImageFolder
Dim Action
Set NC_Admin = New Check
Set FSO = Server.CreateObject(DownsysClass.Script_FSO)
maxperpage = 25
strFileName = "admin_filemanage.asp"
If Request("page") <> "" Then
	CurrentPage = Int(Request("page"))
Else
	CurrentPage = 1
End If
ImageFolder = "images/pic/" '存放本程序图标的文件夹，如果要更换图标文件夹请更新这里就可以拉
If Request("path") <> "" Then
	Path = Request("path")
Else
	Path = DownsysClass.SetupDir & "admin"
End If
Path = Replace(Path, "\", "/")
If Right(Path, 1) <> "/" Then
	FsoDir = Path & "/"
Else
	FsoDir = Path
End If
Session("NC_CurrentDir") = FsoDir
CurrentDir = Session("NC_CurrentDir")
TruePath = Server.MapPath(FsoDir)

Server.ScriptTimeOut = 9999999
NC_Admin.AdminChk = "55"
NC_Admin.Check
DownsysClass.admin_header
Action = Trim(Request("action"))
Select Case Action
	Case "edit"
		Call EditFile
	Case "del"
		Call DelAll
	Case "rename"
		Call rename
	Case "folder"
		Call CreateNewFolder
	Case "files"
		Call CreateNewFile
	Case Else
		Call FileMain
End Select
If Founderr = True Then
	NC_Admin.Error_Msg (ErrMsg)
End If
Set FSO = Nothing
DownsysClass.admin_footer
NothingObject

Sub FileMain()
	Response.Write "<script language=JavaScript>" & vbCrLf
	Response.Write "<!--//" & vbCrLf
	Response.Write "function uploadframe()" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "	document.getElementById(""Setupload"").style.display="""";" & vbCrLf
	Response.Write "	document.getElementById(""allupload"").style.display=""none"";" & vbCrLf
	Response.Write "	document.getElementById(""allupfile"").style.display=""none"";" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "function setid(upcount)" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write "	str='';" & vbCrLf
	Response.Write "	for(i=1;i<=window.form1.upcount.value;i++)" & vbCrLf
	Response.Write "	str+='文件'+i+':<input type=""file"" name=""upfile'+i+'"" style=""width:90%""><br>';" & vbCrLf
	Response.Write "	window.upid.innerHTML=str+'<br>';" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "//-->" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<table width=""98%"" border=""0"" align=""center"" cellpadding=""1"" cellspacing=""1"" class=""tableBorder"">" & vbCrLf
	Response.Write "<tr><th height=""22"" colspan=2>WEB文件管理</th></tr>" & vbCrLf
	Response.Write "<form method=""POST"" name=form1 action=""UpFiles.asp"" enctype=""multipart/form-data"">" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td class=""forumRow"" colspan=2 height=23>" & vbCrLf
	Response.Write "<table border=0 cellspacing=0 cellpadding=5 style=""width:100%;"">" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<TD noWrap valign=top>" & vbCrLf
	Response.Write "<DIV id=allupfile>" & vbCrLf
	Response.Write "<b>文件上传</b>： "
	Response.Write "</Div>" & vbCrLf
	Response.Write "<DIV id=Setupload style=""display:none"">" & vbCrLf
	Response.Write "选择上传数量:" & vbCrLf
	Response.Write "<select name=""upcount"" onChange=""setid(this.value)"">" & vbCrLf
	For i = 1 To CInt(DownsysClass.Setting(30))
		Response.Write " <option value='" & i & "'"
		If i = 1 Then Response.Write " selected"
		Response.Write ">" & i & "</option>" & vbCrLf
	Next
	Response.Write "</Div>" & vbCrLf
	Response.Write "</TD>" & vbCrLf
	Response.Write "<TD id=""upid"" align=center width='80%' noWrap valign=top>" & vbCrLf
	Response.Write "<input type=""file"" name=""upfile1"" style=""width:96%""></TD>" & vbCrLf
	Response.Write "<td width='8%' valign=top>" & vbCrLf
	Response.Write "<input type=""submit"" name=""Submit"" value=""上传文件"">" & vbCrLf
	Response.Write "</td>" & vbCrLf
	If CInt(DownsysClass.Setting(29)) = 1 Then
		Response.Write "<td id=allupload valign=top width='8%'>" & vbCrLf
		Response.Write "<input type=""button"" name=""setload"" onClick=""uploadframe();"" value=""批量上传"">" & vbCrLf
		Response.Write "</td>" & vbCrLf
	End If
	Response.Write "</tr>" & vbCrLf
	Response.Write "<tr vAlign=top>"
	Response.Write "<TD colspan=4 class=forumRow valign=top>" & vbCrLf
	Response.Write "允许上传的文件类型：" & DownsysClass.Setting(25) & "|" & DownsysClass.Setting(27) & " 　上传大小：" & GetFileSize((CStr(DownsysClass.Setting(22)) + CStr(DownsysClass.Setting(23)) * 1024)) & ""
	Response.Write "</td>"
	Response.Write "</tr>"
	Response.Write "</table>" & vbCrLf
	Response.Write "</td></tr></form>" & vbCrLf
	Response.Write "<form method=""POST"" action=""admin_filemanage.asp"">" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td class=""forumRow"" colspan=2 height=23>&nbsp; <input type=""text"" name=""path"" value=" & FsoDir & " size=""40"" class=""td2"">&nbsp;<input type=""submit"" value=""确认提交"" class=""button"">" & vbCrLf
	Response.Write " （<font color=red>请填写正确的文件夹名或路径</font>）</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "</form>" & vbCrLf
	Response.Write "<form method=""POST"" action=""admin_filemanage.asp"">" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td class=""forumRow"" colspan=2 height=23>" & vbCrLf
	Response.Write "&nbsp;<input type=radio name=""action"" value='files' checked>新建文件" & vbCrLf
	Response.Write "&nbsp;<input type=radio name=""action"" value='folder'>新建文件夹" & vbCrLf
	Response.Write "&nbsp;<input type=""text"" name=""CreateName"" value='' size=""30"">" & vbCrLf
	Response.Write "&nbsp;<input type=""hidden"" name=""ThisDir"" value='" & FsoDir & "'>" & vbCrLf
	Response.Write "&nbsp;<input type=""submit"" value=""确认新建"" class=""button"">" & vbCrLf
	Response.Write "</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "</form>" & vbCrLf
	Response.Write "<tr><td height=""22"" class=""forumRow"" style=""COLOR: #808080;"">" & vbCrLf
	Response.Write "&nbsp;<b>当前浏览的目录　" & FsoDir & "" & vbCrLf
	Response.Write "&nbsp;&nbsp;</td><td class=""forumRow"" align=right>" & vbCrLf
	Response.Write "&nbsp;<img align=absMiddle src='" & ImageFolder & "Btn_Backward.gif' width=20 height=20 alt='后退' onclick=""javascript:history.go(-1)"">"
	Response.Write "&nbsp;<img align=absMiddle src='" & ImageFolder & "Btn_Forward.gif' width=20 height=20 alt='前进' onclick=""javascript:history.go(1)"">"
	Response.Write "&nbsp;<a href=?action=Open&path=" & Left(FsoDir, InStrRev(Left(FsoDir, Len(FsoDir) - 1), "/")) & "><img align=absMiddle src='" & ImageFolder & "Btn_Up.gif' width=20 height=20 alt='向上' border=""0""></a>"
	Response.Write "&nbsp;&nbsp;</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "</table>" & vbCrLf
	Response.Write "<table align=center height=16><form method=""POST"" action=""admin_filemanage.asp""><tr><td align=center style=""COLOR: #FF6600;"">" & vbCrLf
	If Len(Trim(Request.QueryString("FolderName"))) <> 0 Or Len(Trim(Request.QueryString("FileName"))) <> 0 Then
		Dim NewName
		NewName = Trim(Request.QueryString("FolderName")) & Trim(Request.QueryString("FileName"))
		Response.Write "&nbsp;<input type=""hidden"" name=""action"" value='rename'>" & vbCrLf
		Response.Write "&nbsp;<input type=""hidden"" name=""ThisDir"" value='" & FsoDir & "'>" & vbCrLf
		Response.Write "&nbsp;<input type=""hidden"" name=""FolderName"" value='" & Trim(Request.QueryString("FolderName")) & "'>" & vbCrLf
		Response.Write "&nbsp;<input type=""hidden"" name=""FileName"" value='" & Trim(Request.QueryString("FileName")) & "'>" & vbCrLf
		Response.Write "&nbsp;<input type=""text"" name=""NewName"" value='" & NewName & "' size=""20"">" & vbCrLf
		Response.Write "&nbsp;<input type=""submit"" value=""确认更名"" class=""button"">" & vbCrLf
	End If
	Response.Write "</td><tr></form></table>" & vbCrLf
	If FSO.FolderExists(TruePath) Then
		Dim FsoFile, FsoFileSize
		Dim DirFiles, DirFolder
		Set FsoFile = FSO.GetFolder(TruePath)
		'FsoFileSize = FsoFile.size '空间大小统计
		Dim c, Pcount
		FileCount = FsoFile.Files.Count
		TotleSize = GetFileSize(FsoFile.Size)
		totalPut = FsoFile.Files.Count
		If CurrentPage < 1 Then
			CurrentPage = 1
		End If
		If (CurrentPage - 1) * maxperpage > totalPut Then
			If (totalPut Mod maxperpage) = 0 Then
				CurrentPage = totalPut \ maxperpage
			Else
				CurrentPage = totalPut \ maxperpage + 1
			End If
		End If
		Response.Write "<table width=""98%"" border=""0"" align=""center"" cellpadding=""1"" cellspacing=""1"" class=""tableBorder"">" & vbCrLf
		Response.Write "<tr><th>选择</th><th>文件/文件夹名</th>" & vbCrLf
		Response.Write "    <th>类 型</th>" & vbCrLf
		Response.Write "    <th>文件大小</th>" & vbCrLf
		Response.Write "    <th>最后修改时间</th>" & vbCrLf
		Response.Write "    <th>操 作</th>" & vbCrLf
		Response.Write "  </tr>" & vbCrLf
		Response.Write "  <tr> " & vbCrLf
		Response.Write "    <td colspan=""6"" class=""forumRowHighlight"">" & vbCrLf
		Call showpage2(strFileName, totalPut, maxperpage)
		Response.Write "  </td></tr>" & vbCrLf
		Response.Write "<form name=""myform"" method=""post"" action='admin_filemanage.asp' onsubmit=""return confirm('确定要删除选中的文件吗？');"">" & vbCrLf
		If Not DownsysClass.IsObjectFSO(DownsysClass.Script_FSO) Then
			Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
		Else
			For Each DirFolder In FsoFile.SubFolders
				FolderName = DirFolder.Name
				FolderSize = GetFileSize(DirFolder.Size)
				FolderTime = DirFolder.DateLastModified
				Response.Write "  <tr onmouseover=""this.style.backgroundColor='#F3F3FA';this.style.color='red'"" onmouseout=""this.style.backgroundColor='';this.style.color=''""> " & vbCrLf
				Response.Write "    <td align=center><input type=""checkbox"" name=""FolderId"" value='" & FolderName & "' title='" & FolderName & "'></td>" & vbCrLf
				Response.Write "    <td>&nbsp;<a href=?action=Open&path=" & FsoDir & FolderName & ">" & FolderName & "</a></td>" & vbCrLf
				Response.Write "    <td align=center><img src='" & ImageFolder & "ClosedFolder.gif' width=16 height=16 alt='文件夹'></td>" & vbCrLf
				Response.Write "    <td align=right>" & FolderSize & "</td>" & vbCrLf
				Response.Write "    <td align=right>" & FolderTime & "</td>" & vbCrLf
				Response.Write "    <td align=center><a href='?action=Open&path=" & FsoDir & "&FolderName=" & FolderName & "'>文件更名</a></td>" & vbCrLf
				Response.Write "  </tr>" & vbCrLf
			Next
			FileCount = 0
			For Each DirFiles In FsoFile.Files
				c = c + 1
				If FileCount >= maxperpage Then
					Exit For
				ElseIf c > maxperpage * (CurrentPage - 1) Then
					filename = DirFiles.Name
					FileType = GetFileIcon(filename)
					FileSize = GetFileSize(DirFiles.Size)
					FileTime = DirFiles.DateLastModified
					Response.Write "  <tr onmouseover=""this.style.backgroundColor='F5F5FB';this.style.color='red'"" onmouseout=""this.style.backgroundColor='';this.style.color=''""> " & vbCrLf
					Response.Write "    <td align=center><input type=""checkbox"" name=""FileID"" value='" & filename & "' title='" & filename & "'></td>" & vbCrLf
					Response.Write "    <td>&nbsp;<a href=" & FsoDir & filename & " target=_blank>" & filename & "</a></td>" & vbCrLf
					Response.Write "    <td align=center><Img src=" & ImageFolder & FileType & " alt='文件'></td>" & vbCrLf
					Response.Write "    <td align=right>" & FileSize & "</td>" & vbCrLf
					Response.Write "    <td align=right>" & FileTime & "</td>" & vbCrLf
					Response.Write "    <td align=center><a href='?action=Open&path=" & FsoDir & "&FileName=" & filename & "'>更 名</a> | <a href=""javascript:openScript('admin_filemanage.asp?action=edit&stype=edit&FileName=" & FsoDir & filename & "',600,450)"">编 辑</a></td>" & vbCrLf
					Response.Write "  </tr>" & vbCrLf
					FileCount = FileCount + 1
				End If
			Next
			Response.Write "<tr><td class=forumRowHighlight colspan=""6""><input name=""chkAll"" type=""checkbox"" id=""chkAll"" onclick=CheckAll(this.form) value=""checkbox"">全选/反选　 " & vbCrLf
			Response.Write "	    <input name=""Action"" type=""hidden"" id=""Action"" value=""del"">" & vbCrLf
			Response.Write "	      <input type=""submit"" name=""Submit"" value=""删除选中的文件"" class=""button"">　 " & vbCrLf
			Response.Write "	      <input type=""hidden"" name=""ThisDir"" value='" & FsoDir & "'>" & vbCrLf
			Response.Write "      　     <input type=""button"" name=""Submit1"" onclick=""javascript:history.go(-1)"" value=""返回上一页"" class=button>　　" & vbCrLf
			Response.Write "</td></tr></form>" & vbCrLf
			Response.Write "  <tr> " & vbCrLf
			Response.Write "    <td colspan=""6"" class=""forumRowHighlight"">" & vbCrLf
			Call showpage2(strFileName, totalPut, maxperpage)
			Response.Write "  </td></tr>" & vbCrLf
		End If
		Response.Write "</td></tr></table>"
		Set FsoFile = Nothing
	Else
		Response.Write "找不到文件夹！可能是配置有误！"
	End If
End Sub

'*******************************************
'过程作用：分页
'*******************************************

Sub showpage2(sfilename, totalnumber, maxperpage)
	Dim n
	Dim strTemp
	If totalnumber Mod maxperpage = 0 Then
		n = totalnumber \ maxperpage
	Else
		n = totalnumber \ maxperpage + 1
	End If
	strTemp = "<table align='center'><form method='Post' action='" & sfilename & "?path=" & Request("path") & "'><tr><td>"
	strTemp = strTemp & "共 <b>" & totalnumber & "</b> 个文件，占用 <b>" & TotleSize & "</b>&nbsp;&nbsp;"
	sfilename = JoinChar(sfilename)
	If CurrentPage < 2 Then
		strTemp = strTemp & "首页 上一页&nbsp;"
	Else
		strTemp = strTemp & "<a href='" & sfilename & "page=1&path=" & Request("path") & "'>首页</a>&nbsp;"
		strTemp = strTemp & "<a href='" & sfilename & "page=" & (CurrentPage - 1) & "&path=" & Request("path") & "'>上一页</a>&nbsp;"
	End If

	If n - CurrentPage < 1 Then
		strTemp = strTemp & "下一页 尾页"
	Else
		strTemp = strTemp & "<a href='" & sfilename & "page=" & (CurrentPage + 1) & "&path=" & Request("path") & "'>下一页</a>&nbsp;"
		strTemp = strTemp & "<a href='" & sfilename & "page=" & n & "&path=" & Request("path") & "'>尾页</a>"
	End If
	strTemp = strTemp & "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
	strTemp = strTemp & "&nbsp;转到：<select name='page' size='1' onchange='javascript:submit()'>"
	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></form></table>"
	Response.Write strTemp
End Sub

'*******************************************
'过程作用：编辑文件
'*******************************************

Sub EditFile()
	Dim filename, FileText, FileHTML
	Dim objFSO, objCountFile
	filename = Request("FileName")
	FileHTML = Request.Form("HTML")
	On Error Resume Next
	Set objFSO = Server.CreateObject(DownsysClass.Script_FSO)
	If Request("stype") = "save" Then
		Set FSO = CreateObject(DownsysClass.Script_FSO)
		Set f = FSO.OpenTextFile(Server.MapPath(filename), 2, True)
		f.Write FileHTML
		f.Close
		Set FSO = Nothing
		Set f = Nothing
		Response.Write "<script>opener.window.location.reload()</script>"
		Response.Write "<meta http-equiv='refresh' content='0;URL=javascript:window.close()'>"
	ElseIf Request("stype") = "edit" Then
		If objFSO.FileExists(Server.MapPath(filename)) Then
			Set FSO = CreateObject(DownsysClass.Script_FSO)
			Set f = FSO.OpenTextFile(Server.MapPath(filename), 1, True)
			FileText = f.ReadAll
			f.Close
			Set FSO = Nothing
			Set f = Nothing
		Else
			ErrMsg = ErrMsg & "发生错误，文件已经被删除或者损坏！"
			Founderr = True
			Exit Sub
		End If
		Response.Write "<table width=""96%"" border=""0"" align=""center"" cellpadding=""2"" cellspacing=""1"" class=""tableBorder"">" & vbCrLf
		Response.Write "<tr><th height=""22"">在线编辑" & filename & " </th></tr>" & vbCrLf
		Response.Write "<form name=""form1"" method=""post"" action=""admin_filemanage.asp?action=edit&stype=save"">" & vbCrLf
		Response.Write "<td width=""80%"" align=""center"" class=""forumRow"">" & vbCrLf
		Response.Write "<textarea id=""FileText"" name=""html"" style=""width:100%;"" rows=""20"">" & Server.HTMLEncode(FileText) & "</textarea>" & vbCrLf
		Response.Write "<input type=""hidden"" name=""FileName"" value=""" & filename & """>" & vbCrLf
		Response.Write "    <br>" & vbCrLf
		Response.Write "    <input type=""button"" name=""Submit1"" value=""关闭窗口"" class=""button"" onClick=""window.close()"">　 " & vbCrLf
		Response.Write "    <input type=""reset"" name=""Submit2"" value=""重 置"" class=""button"">　 " & vbCrLf
		Response.Write "    <input type=""submit"" name=""Submit"" value=""保存文件"" class=""button"" onclick=""{if(confirm('您确定要保存文件么？\n此操作不可恢复！')){this.document.form1.submit();return true;}return false;}"">　 " & vbCrLf
		Response.Write "    <a href=""javascript:admin_Size(-20,'Thtml')""><img src=""images/minus.gif"" unselectable=""on"" border='0'></a> <a href=""javascript:admin_Size(20,'Thtml')""><img src=""images/plus.gif"" unselectable=""on"" border='0'></a>" & vbCrLf
		Response.Write "（<font color=#808080>操作前最好先备份文件!</font>）</td></form>" & vbCrLf
		Response.Write "</tr>" & vbCrLf
		Response.Write "</table>" & vbCrLf
	End If
End Sub

'*******************************************
'函数作用：格式化文件的大小
'*******************************************

Function GetFileSize(Size)
	Dim FileSize
	FileSize = Size / 1024
	FileSize = FormatNumber(FileSize, 2)
	If FileSize < 1024 And FileSize > 1 Then
		GetFileSize = "<font color=red>" & FileSize & "</font>&nbsp;KB"
	ElseIf FileSize > 1024 Then
		GetFileSize = "<font color=red>" & FormatNumber(FileSize / 1024, 2) & "</font>&nbsp;MB"
	Else
		GetFileSize = "<font color=red>" & Size & "</font>&nbsp;Bytes"
	End If
End Function

'*******************************************
'函数作用：取得文件的后缀名
'*******************************************

Function GetExtensionName(Name)
	Dim filename
	filename = Split(Name, ".")
	GetExtensionName = filename(UBound(filename))
End Function

'*******************************************
'函数作用：返回文件类型
'*******************************************

Function GetFileIcon(Name)
	Dim filename, Icon
	filename = LCase(GetExtensionName(Name))
	Select Case filename
		Case "asp"
			Icon = "asp.gif"
		Case "bmp"
			Icon = "bmp.gif"
		Case "doc"
			Icon = "doc.gif"
		Case "exe"
			Icon = "exe.gif"
		Case "gif"
			Icon = "gif.gif"
		Case "jpg"
			Icon = "jpg.gif"
		Case "chm"
			Icon = "chm.gif"
		Case "htm", "html"
			Icon = "htm.gif"
		Case "log"
			Icon = "log.gif"
		Case "mdb"
			Icon = "mdb.gif"
		Case "swf"
			Icon = "swf.gif"
		Case "txt"
			Icon = "txt.gif"
		Case "wav"
			Icon = "wav.gif"
		Case "xls"
			Icon = "xls.gif"
		Case "rar", "zip"
			Icon = "zip.gif"
		Case "css"
			Icon = "css.gif"
		Case Else
			Icon = "none.gif"
	End Select
	GetFileIcon = Icon
End Function

'*******************************************
'过程作用：删除选定的文件或文件夹
'*******************************************

Sub DelAll()
	Dim FolderId, FileId, ThisDir, FileNum, FolderNum, FilePath, FolderPath
	FolderId = Split(Request.Form("FolderId"), ",")
	FileId = Split(Request.Form("FileId"), ",")
	ThisDir = Trim(Request.Form("ThisDir"))
	FileNum = 0
	FolderNum = 0
	If UBound(FolderId) <> -1 Then '删除文件夹
		For i = 0 To UBound(FolderId)
			FolderPath = Server.MapPath(ThisDir & Trim(FolderId(i)))
			If FSO.FolderExists(FolderPath) Then
				FSO.DeleteFolder FolderPath, True
				FolderNum = FolderNum + 1
			End If
		Next
	End If
	If UBound(FileId) <> -1 Then '删除文件
		For j = 0 To UBound(FileId)
			FilePath = Server.MapPath(ThisDir & Trim(FileId(j)))
			If FSO.FileExists(FilePath) Then
				FSO.DeleteFile FilePath, True
				FileNum = FileNum + 1
			End If
		Next
	End If
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

'*******************************************
'过程作用：使选定的文件或文件夹改名
'*******************************************

Sub rename()
	Dim ThisDir, NewName, OldName, NewName1
	Set FSO = Server.CreateObject(DownsysClass.Script_FSO)
	ThisDir = Trim(Request.Form("ThisDir"))
	FolderName = Trim(Request.Form("FolderName"))
	filename = Trim(Request.Form("FileName"))
	If Len(Trim(Request.Form("NewName"))) = 0 Then
		ErrMsg = "<li>请输入文件或文件夹名称！</li>"
		Founderr = True
		Exit Sub
	Else
		NewName = Trim(Request.Form("NewName"))
	End If
	On Error Resume Next
	Set FSO = Server.CreateObject(DownsysClass.Script_FSO)
	If Len(FolderName) <> 0 Then '文件夹改名
		NewName1 = Server.MapPath(ThisDir & NewName)
		OldName = Server.MapPath(ThisDir & FolderName)
		If Not FSO.FolderExists(NewName1) Then
			FSO.MoveFolder OldName, NewName1
			Response.redirect (Request.ServerVariables("HTTP_REFERER"))
		Else
			ErrMsg = ErrMsg & "<li>有同名文件夹，请换个文件夹名</li>"
			Founderr = True
			Exit Sub
		End If
	End If
	If Len(filename) <> 0 Then '文件改名
		NewName1 = Server.MapPath(ThisDir & NewName)
		OldName = Server.MapPath(ThisDir & filename)
		If Not FSO.FileExists(NewName1) Then
			FSO.MoveFile OldName, NewName1
			Response.redirect (Request.ServerVariables("HTTP_REFERER"))
		Else
			ErrMsg = ErrMsg & "<li>有同名文件，请换个文件名</li>"
			Founderr = True
		End If
	End If
	FSO.Close
	Set FSO = Nothing
End Sub

'*******************************************
'过程作用：新建文件
'*******************************************

Sub CreateNewFile()
	Dim NewFile, NewFilePath, FsoFile, NewFileDir
	NewFileDir = Trim(Request.Form("ThisDir"))
	If Len(Trim(Request.Form("CreateName"))) = 0 Then
		ErrMsg = "<li>请输入文件夹名称！</li>"
		Founderr = True
		Exit Sub
	Else
		NewFile = Trim(Request.Form("CreateName"))
	End If
	NewFile = Trim(Request.Form("CreateName"))
	NewFilePath = Server.MapPath(NewFileDir & NewFile)
	Set FSO = Server.CreateObject(DownsysClass.Script_FSO)
	If Not FSO.FileExists(NewFilePath) And Not FSO.FolderExists(NewFilePath) Then
		Set FsoFile = FSO.CreateTextFile(NewFilePath)
		FsoFile.WriteLine
		FsoFile.Close
		Set FsoFile = Nothing
		Set FSO = Nothing
		Response.redirect (Request.ServerVariables("HTTP_REFERER"))
	Else
		ErrMsg = ErrMsg & "<li>有同名文件，请换个文件名</li>"
		Founderr = True
	End If
End Sub

'*******************************************
'过程作用：新建文件夹
'*******************************************

Sub CreateNewFolder()
	Dim NewFolder, NewFolderPath, objFSO
	NewFolderPath = Trim(Request.Form("ThisDir"))
	If Len(Trim(Request.Form("CreateName"))) = 0 Then
		ErrMsg = "<li>请输入文件夹名称！</li>"
		Founderr = True
		Exit Sub
	Else
		NewFolder = Trim(Request.Form("CreateName"))
	End If
	NewFolderPath = Server.MapPath(NewFolderPath & NewFolder)
	On Error Resume Next
	Set objFSO = Server.CreateObject(DownsysClass.Script_FSO)
	If Not objFSO.FolderExists(NewFolderPath) Then
		objFSO.CreateFolder (NewFolderPath)
		Response.redirect (Request.ServerVariables("HTTP_REFERER"))
	Else
		ErrMsg = ErrMsg & "<li>有同名文件夹，请换个文件夹名</li>"
		Founderr = True
	End If
	objFSO.Close
	Set objFSO = Nothing
End Sub

'*******************************************
'函数作用：在文件名后加上字符串连接
'*******************************************

Function JoinChar(strUrl)
	If strUrl = "" Then
		JoinChar = ""
		Exit Function
	End If
	If InStr(strUrl, "?") < Len(strUrl) Then
		If InStr(strUrl, "?") > 1 Then
			If InStr(strUrl, "&") < Len(strUrl) Then
				JoinChar = strUrl & "&"
			Else
				JoinChar = strUrl
			End If
		Else
			JoinChar = strUrl & "?"
		End If
	Else
		JoinChar = strUrl
	End If
End Function
%>
