仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 446|回复: 8
打印 上一主题 下一主题

[学习教程] ASP编程:不必WinRar将收集空间上的文件打包下载...

[复制链接]
透明 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:11:18 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

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)方式来编写的。
9#
发表于 2015-3-22 01:45:28 | 只看该作者
ASP.Net和ASP的最大区别在于编程思维的转换,而不仅仅在于功能的增强。ASP使用VBS/JS这样的脚本语言混合html来编程,而那些脚本语言属于弱类型、面向结构的编程语言,而非面向对象,这就明显产生以下几个问题:
乐观 该用户已被删除
8#
发表于 2015-3-15 14:02:26 | 只看该作者
作为IE上广为流传的动态网页开发技术,ASP以它简单易学博得了广大WEB程序爱好这的青睐,而且它对运行环境和开发品台的不挑剔,以及有大量有效的参考手册,极大的推广了它的发展。
兰色精灵 该用户已被删除
7#
发表于 2015-3-7 20:27:12 | 只看该作者
Response:从字面上讲是“响应”,因此这个是服务端向客户端发送东西的,例如Response.Write
第二个灵魂 该用户已被删除
6#
发表于 2015-2-25 10:56:25 | 只看该作者
运用ASP可将VBscript、javascript等脚本语言嵌入到HTML中,便可快速完成网站的应用程序,无需编译,可在服务器端直接执行。容易编写,使用普通的文本编辑器编写,如记事本就可以完成。由脚本在服务器上而不是客户端运行,ASP所使用的脚本语言都在服务端上运行。
爱飞 该用户已被删除
5#
发表于 2015-2-8 11:24:16 | 只看该作者
先学习用frontpage熟悉html编辑然后学习asp和vbscript建议买书进行系统学习
冷月葬花魂 该用户已被删除
地板
发表于 2015-2-2 22:04:12 | 只看该作者
代码的可重用性差:由于是面向结构的编程方式,并且混合html,所以可能页面原型修改一点,整个程序都需要修改,更别提代码重用了。
admin 该用户已被删除
板凳
发表于 2015-1-25 12:12:05 | 只看该作者
在平时的学习过程中要注意现学现用,注重运用,在掌握了一定的基础知识后,我们可以尝试做一些网页,也许在开始的时候我们可能会遇到很多问题,比如说如何很好的构建基本框架。
活着的死人 该用户已被删除
沙发
发表于 2015-1-18 22:01:12 | 只看该作者
掌握asp的特性而且一定要知道为什么。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-12-25 14:42

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表