⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fso_index.asp

📁 网店批发系统,很好很强大,很好很强大很好很强大
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<!--#include file= "conn.asp" -->
<%
'管理员认证
Dim DisplayFlag,suffix,ImgName
DisplayFlag=1                   '是否是文件夹中的多余图片  0为否, 1为是
%>
<%	Response.Buffer=true 
	On Error Resume Next
	Server.ScriptTimeOut = 1000
	Response.Expires=0 
	Dim StartTime,IsReplace,ImageFolder
	IsReplace = true	'是否过滤编辑时文件的<textarea></textarea>标记,如不过滤遇到有<textarea>标记的文件时编辑有显示不完全的现象
           ImageFolder = "Fso_image"     '存放本程序图标的文件夹,如果要更换图标文件夹请更新这里就可以拉
	StatrTime = Timer()
%>
<%
'****************************************
'函数定义部分开始
'****************************************

'*******************************************
'过程作用:判断服务器是否支持FSO
'*******************************************
Sub IsErr()
	If Err = -2147221005 Then
		Response.write "这台服务器不支持FSO,故本程序无法运行"
		Response.end
	End If
End Sub
'*******************************************
'函数作用:取得文件的后缀名
'*******************************************
Function UpDir(ByVal D)
	Dim UDir
	If Len(D) = 0 then Exit Function
	UDir=Left(D,InStrRev(D,"\")-1)
	UpDir=UDir
End Function
'*******************************************
'函数作用:取得当前页的URL,
'		   为文件添加正确的链接
'*******************************************
Function FileUrl(url,D)
	Dim PageUrl,PUrl
	PageUrl="http://"& Request.ServerVariables("SERVER_NAME")
	PUrl=Left(Request.ServerVariables("URL"),InStrRev(Request.ServerVariables("Url"),"/"))
	PageUrl=PageUrl & Purl & Mid(D,2,Len(D)) & "/" & url
	FileUrl=PageUrl
End Function
'*******************************************
'函数作用:格式化文件的大小
'*******************************************
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.write "<script>alert('\n恭喜,删除成功\n\n"& FolderNum &" 个文件夹被删除\n"& FileNum &" 个文件被删除');window.location.href=('"& Replace(Request.ServerVariables("HTTP_REFERER"),"\","\\") &"')</script>"
End Sub
'*******************************************
'过程作用:使选定的文件或文件夹改名
'*******************************************
Sub Rname()
	Dim ThisDir,FolderName,NewName,OldName
	ThisDir = Trim(Request.Form("ThisDir"))
	FolderName = Trim(Request.Form("FolderId"))
	FileName = Trim(Request.Form("FileId"))
	NewName = Trim(Request.QueryString("NewName"))
	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.write "<script>alert('【 "& FolderName &" 】文件夹已经成功改名为【 "& NewName &" 】');window.location.href=('"& Replace(Request.ServerVariables("HTTP_REFERER"),"\","\\") &"')</script>"
		Else
			Response.write "<script>alert('有同名文件夹,请换个文件夹名');window.location.href=('"& Replace(Request.ServerVariables("HTTP_REFERER"),"\","\\") &"')</script>"
		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.write "<script>alert('【 "& FileName &" 】文件已经成功改名【 "& NewName &" 】');window.location.href=('"& Replace(Request.ServerVariables("HTTP_REFERER"),"\","\\") &"')</script>"
		Else
			Response.write "<script>alert('有同名文件,请换个文件名');window.location.href=('"& Replace(Request.ServerVariables("HTTP_REFERER"),"\","\\") &"')</script>"
		End If
	End If	
End Sub
'*******************************************
'过程作用:新建文件
'*******************************************
Sub NewFile()
	Dim NewFile,NewFilePath
	NewFilePath = Trim(Request.Form("ThisDir"))
	NewFile = Trim(Request.Form("NewFileName"))
	NewFilePath = Server.MapPath(".") & NewFilePath & "\" & NewFile
	If not Fso.FileExists(NewFilePath) and not Fso.FolderExists(NewFilePath) then
		Set FsoFile = Fso.CreateTextFile(NewFilePath)
			FsoFile.Writeline
		FsoFile.close
		Set FsoFile = nothing
		Response.write "<script>alert('建立文件成功');window.location.href=('"& Replace(Request.ServerVariables("HTTP_REFERER"),"\","\\") &"')</script>"
	Else
		Response.write "<script>alert('有同名文件,请换个文件名');window.location.href=('"& Replace(Request.ServerVariables("HTTP_REFERER"),"\","\\") &"')</script>"
	End if
End Sub
'*******************************************
'过程作用:新建文件夹
'*******************************************
Sub NewFolder()
	Dim NewFolder,NewFolderPath
	NewFolderPath = Trim(Request.Form("ThisDir"))
	NewFolder = Trim(Request.Form("NewFolderName"))
	NewFolderPath = Server.MapPath(".") & NewFolderPath & "\" & NewFolder
	If not Fso.FolderExists(NewFolderPath) then
		Fso.CreateFolder(NewFolderPath)
		Response.write "<script>alert('建立文件夹成功');window.location.href=('"& Replace(Request.ServerVariables("HTTP_REFERER"),"\","\\") &"')</script>"
	Else
		Response.write "<script>alert('有同名文件夹,请换个文件夹名');window.location.href=('"& Replace(Request.ServerVariables("HTTP_REFERER"),"\","\\") &"')</script>"
	End if
End Sub
'*******************************************
'过程作用:css 样式
'*******************************************
Sub Css()
%>
<style>
.fonts{font-size:9pt;line-height:25px}
.button{padding:2px;
		height:20px;
		background-color:#FF9900;
		color:#ffffff;
		border:1px solid #333333;
		font-size:12px;
		font-family: "宋体";
}
.TextBox {
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: solid;
	border-right-style: solid;
	border-bottom-style: solid;
	border-left-style: solid;
	border-top-color: #666666;
	border-right-color: #CCCCCC;
	border-bottom-color: #CCCCCC;
	border-left-color: #666666;
	padding: 2px;
	height: 300px;
	font-size:12px;
	font-family: "宋体";

}
.InputBox {
         border-top-width:1px;
         border-left-width:1px;
         border-right-width:1px;
         border-bottom-width:1px;
         border-top-color:#000000;
         border-left-color:#000000;
         border-bottom-color:#000000;
         border-right-color:#000000;
         padding:2px;
         height:20px;

}
Input, Select, TextArea {
	font-family: "宋体";
	font-size: 12px;
	text-decoration: none;
}
a:link {  color: #000000; text-decoration: none}
a:visited {  color: #000000; text-decoration: none}
a:hover {  color: #FF0000; text-decoration: underline}
</style>
<%
End Sub
'*******************************************
'过程作用:编辑文件
'*******************************************
Sub Edit()
	Dim FilePath,FileName,action
	Set Fso = Server.CreateObject("Scripting.FileSystemObject")
	IsErr
	action=Trim(Request.QueryString("action"))
	If action = ("Save") then	'保存文件
		Dim FileSave
		FilePath = trim(Request.QueryString("FilePath"))
		FileAll = trim(Request.Form("FileAll"))
		If IsReplace then FileAll = Replace(FileAll,"\\textarea\\","textarea")
		If Fso.FileExists(FilePath) then
			Set FileSave = Fso.OpenTextFile(FilePath,2)
				FileSave.Write(FileAll)
			FileSave.Close
			Response.write "<script>if(confirm('文件已经保存,是否关闭本页')){window.close();}else{history.back();}</script>"
		Else
			Response.write "<script>alert('发生错误,文件已经被删除或者损坏!');window.close()</script>"
		End If
	ElseIf action = ("Edit") then	'读取文件
		Dim FileAll
		FilePath = Trim(Request.Form("ThisDir"))
		FileName = Trim(Request.Form("FileId"))
		FilePath1 = Server.MapPath(".") & FilePath & "\" & FileName
		If Fso.FileExists(FilePath1) then
			Set FileOpen = Fso.OpenTextFile (FilePath1,1)
				FileAll = FileOpen.ReadAll
			FileOpen.close
		If IsReplace then FileAll = Replace(FileAll,"textarea","\\textarea\\")
		Else
			Response.write "<script>alert('发生错误,文件已经被删除或者损坏!');window.close()</script>"
		End If
%>
<%	End If
	Set Fso = nothing
	End Sub
'****************************************
'函数定义部分结束

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -