|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
ActiveServerPage技术为应用开发商提供了基于脚本的直观、快速、高效的应用开发手段,极大地提高了开发的效果。在讨论ASP的安全性问题之前,让我们来看看ASP是怎么工作的。winrar|打包|收集|下载此办法,不倡议紧缩,年夜文件,
一样平常的小文件压几个还很好用的
<%@Language=VBScript%>
<%OptionExplicit%>
<!--#includefile="asptar.asp"-->
<%
Response.Buffer=True
Response.Clear
DimCo,Temp,T,x,i,fsoBrowse,theFolder,TheSubFolders,FilePath,s,PH,objTar
Co=0
PH="./UpFile"文件路径紧缩Upfile下的一切文件
SetobjTar=NewTarball
objTar.TarFilename="LvBBS_UpdateFile.rar"打包的称号
objTar.Path=PH
setfsoBrowse=CreateObject("Scripting.FileSystemObject")
SettheFolder=fsoBrowse.GetFolder(Server.Mappath(PH))
SettheSubFolders=theFolder.SubFolders
ForEachTintheFolder.Files
Temp=Temp&T.Name&"|"
Co=Co+1
Next
ForEachxIntheSubFolders
ForEachiInX.Files
Temp=Temp&X.Name&"/"&i.Name&"|"
Co=Co+1
Next
Next
IfCo<1Then
Response.Write"临时没有可更新的文件下载"
objTar.AddMemoryFile"Sorry.txt","NotFile!"
Else
Temp=Left(Temp,Len(Temp)-1)
FilePath=Split(Temp,"|")
Fors=0ToUbound(FilePath)
objTar.AddFileServer.Mappath(PH&"/"&FilePath(s))
Next
IfResponse.IsClientConnectedThen
objTar.WriteTar
Response.Flush
EndIf
EndIf
SetObjTar=Nothing
SetfsoBrowse=Nothing
SettheFolder=Nothing
SettheSubFolders=Nothing
%>
asptar.asp
<%
UNIXTarballcreator
====================
Author:ChrisRead
Version:1.0.1
====================
Homepage:http://users.bigpond.net.au/mrjolly/
Thisclassprovidestheabilitytoarchivemultiplefilestogetherintoasingle
distributablefilecalledatarball(TheTARactuallystandsforTapeARchive).
ThesearecommonUNIXfileswhichcontainuncompresseddata.
Sowhatisthisusefulfor?Well,itallowsyoutoeffectivelycombinemultiple
filesintoasinglefilefordownloading.TheTARfilesarereadableandextractable
byawidevarietyoftools,includingtheverywidelydistributedWinZip.
Thisscriptcanincludetwotypesofdataineacharchive,filedatareadfromadisk,
andalsothingsdirectfrommemory,likefromastring.Thearchivessupportfilesin
abinarystructure,soyoucanstoreexecutablefilesifyouneedto,orjuststore
text.
Thisclasswasdevelopedtoassistmewithafewprojectsandhasgrownwithevery
implementation.CurrentlyIusethisclasstotarballXMLdataforarchivalpurposes
whichallowsmetograb100sofdynamicallycreatedXMLfilesinasingledownload.
Thereareasmallnumberofpropertiesandmethods,whichareoutlinedinthe
accompanyingdocumentation.
ClassTarball
PublicTarFilenameResultanttarballfilename
PublicUserIDUNIXuserID
PublicUserNameUNIXusername
PublicGroupIDUNIXgroupID
PublicGroupNameUNIXgroupname
PublicPermissionsUNIXpermissions
PublicBlockSizeBlockbytesizeforthetarball(default=512)
PublicIgnorePathsIgnoreanysuppliedpathsforthetarballoutput
PublicBasePathInsertabasepathwitheachfile
PublicPath
Storageforfileinformation
PrivateobjFiles,TmpFileName
PrivateobjMemoryFiles
Filelistmanagementsubs,verybasicstuff
PublicSubAddFile(sFilename)
objFiles.AddsFilename,sFilename
EndSub
PublicSubRemoveFile(sFilename)
objFiles.RemovesFilename
EndSub
PublicSubAddMemoryFile(sFilename,sContents)
objMemoryFiles.AddsFilename,sContents
EndSub
PublicSubRemoveMemoryFile(sFilename)
objMemoryFiles.RemovesFilename
EndSub
Sendthetarballtothebrowser
PublicSubWriteTar()
DimobjStream,objInStream,lTemp,aFiles
SetobjStream=Server.CreateObject("ADODB.Stream")Themainstream
SetobjInStream=Server.CreateObject("ADODB.Stream")Theinputstreamfordata
objStream.Type=2
objStream.Charset="x-ansi"GoodoldextendedASCII
objStream.Open
objInStream.Type=2
objInStream.Charset="x-ansi"
Gothroughallfilesstoredondiskfirst
aFiles=objFiles.Items
ForlTemp=0toUBound(aFiles)
objInStream.Open
objInStream.LoadFromFileaFiles(lTemp)
objInStream.Position=0
ExportFileaFiles(lTemp),objStream,objInStream
TmpFileName=replace(aFiles(lTemp),Server.Mappath(Path)&"","")
ExportFileTmpFileName,objStream,objInStream
objInStream.Close
Next
Nowaddstufffrommemory
aFiles=objMemoryFiles.Keys
ForlTemp=0toUBound(aFiles)
objInStream.Open
objInStream.WriteTextobjMemoryFiles.Item(aFiles(lTemp))
objInStream.Position=0
ExportFileaFiles(lTemp),objStream,objInStream
objInStream.Close
Next
objStream.WriteTextString(BlockSize,Chr(0))
Rewindthestream
Remembertochangethetypebacktobinary,otherwisethewritewilltruncate
pastthefirstzerobytecharacter.
objStream.Position=0
objStream.Type=1
Setallthebrowserstuff
Response.AddHeader"Content-Disposition","filename="&TarFilename
Response.ContentType="application/x-tar"
Response.BinaryWriteobjStream.Read
Closeitandgohome
objStream.Close
SetobjStream=Nothing
SetobjInStream=Nothing
EndSub
Buildaheaderforeachfileandsendthefilecontents
PrivateSubExportFile(sFilename,objOutStream,objInStream)
DimlStart,lSum,lTemp
lStart=objOutStream.PositionRecordwhereweareupto
IfIgnorePathsThen
Weignoreanypathsprefixedtoourfilenames
lTemp=InStrRev(sFilename,"")
iflTemp0then
sFilename=Right(sFilename,Len(sFilename)-lTemp)
endif
sFilename=BasePath&sFilename
EndIf
Buildtheheader,everythingisASCIIinoctalexceptforthedata
objOutStream.WriteTextLeft(sFilename&String(100,Chr(0)),100)
objOutStream.WriteText"100"&Right("000"&Oct(Permissions),3)&""&Chr(0)Filemode
objOutStream.WriteTextRight(String(6,"")&CStr(UserID),6)&""&Chr(0)uid
objOutStream.WriteTextRight(String(6,"")&CStr(GroupID),6)&""&Chr(0)gid
objOutStream.WriteTextRight(String(11,"0")&Oct(objInStream.Size),11)&Chr(0)size
objOutStream.WriteTextRight(String(11,"0")&Oct(dateDiff("s","1/1/197010:00",now())),11)&Chr(0)mtime(Numberofsecondssince10amonthe1stJanuary1970(10amcorrect?)
objOutStream.WriteText"0"&String(100,Chr(0))chksum,typeflagandlinkname,writeoutallblankssothattheactualchecksumwillgetcalculatedcorrectly
objOutStream.WriteText"ustar"&Chr(0)magicandversion
objOutStream.WriteTextLeft(UserName&String(32,Chr(0)),32)uname
objOutStream.WriteTextLeft(GroupName&String(32,Chr(0)),32)gname
objOutStream.WriteText"40"&String(4,Chr(0))devmajor,devminor
objOutStream.WriteTextString(167,Chr(0))prefixandleader
objInStream.CopyToobjOutStreamSendthedatatothestream
if(objInStream.SizeModBlockSize)>0then
objOutStream.WriteTextString(BlockSize-(objInStream.SizeModBlockSize),Chr(0))Paddingtothenearestblockbyteboundary
endif
Calculatethechecksumfortheheader
lSum=0
objOutStream.Position=lStart
ForlTemp=1ToBlockSize
lSum=lSum+(Asc(objOutStream.ReadText(1))And&HFF&)
Next
Insertit
objOutStream.Position=lStart+148
objOutStream.WriteTextRight(String(7,"0")&Oct(lSum),7)&Chr(0)
Movetotheendofthestream
objOutStream.Position=objOutStream.Size
EndSub
Starteverythingoff
PrivateSubClass_Initialize()
SetobjFiles=Server.CreateObject("Scripting.Dictionary")
SetobjMemoryFiles=Server.CreateObject("Scripting.Dictionary")
BlockSize=512
Permissions=438UNIX666
UserID=0
UserName="root"
GroupID=0
GroupName="root"
IgnorePaths=False
BasePath=""
TarFilename="new.tar"
EndSub
PrivateSubClass_Terminate()
SetobjMemoryFiles=Nothing
SetobjFiles=Nothing
EndSub
EndClass
%>
ASP脚本是采用明文(plaintext)方式来编写的。 |
|