仓酷云

标题: ASP网页编程之ASP一个天生html的新办法 [打印本页]

作者: 莫相离    时间: 2015-1-16 23:47
标题: ASP网页编程之ASP一个天生html的新办法
asp可以使用微软的activeX使得网页功能无比强大,不过安全性也较差,而且是基于的windows服务器,所以性能稳定性也一般天生html|天生html今朝已有良多天生html的旧事体系,可是都是用的模板,本函数完成把asp页面发生的html代码保留成为一个html文件,如许就没有需要修改本来的页面就能够轻松完成一个天生html的旧事体系了。^_^

因为代码对照短,这里就不举行正文了

<%
当方针页面的包括文件即#include的页面里边存在response.End()的时分本程序有成绩
注重:本文件必定要放在filename指向的文件的统一目次下
dimhughchiu_rtcode
Functionget_exe_code(filename)
dimexecode
dimtmp_str
Dimre,re1,content,fso,f,aspStart,aspEnd
dimms,m
execode=""
setfso=CreateObject("Scripting.FileSystemObject")
setf=fso.OpenTextFile(server.mappath(filename))
content=f.ReadAll
f.close
setf=nothing
setfso=nothing

setre=newregexp
re.ignorecase=true
re.global=true
re.pattern="<\%@[^\%]+\%>"
content=re.replace(content,"")

re.global=false
re.pattern="<!--s*#includes*files*=s*""([^""]+)""s*-->"
do
setms=re.execute(content)
ifms.count0then
setm=ms(0)
tmp_str=get_exe_code(m.submatches(0))
content=re.replace(content,tmp_str)
else
exitdo
endif
loop
setm=nothing
setms=nothing

re.pattern="^s*="
aspEnd=1
aspStart=inStr(aspEnd,content,"<%")+2

setre1=newRegExp
re1.ignorecase=true
re1.global=false
re1.pattern="response.Write(.+)"

dowhileaspStart>aspEnd+1
execode=execode&vbcrlf&"hughchiu_rtcode=hughchiu_rtcode&"""&replace(replace(Mid(content,aspEnd,aspStart-aspEnd-2),"""",""""""),vbcrlf,"""&vbcrlf&""")&""""&vbcrlf
aspEnd=inStr(aspStart,content,"%>")+2
tmp_str=Mid(content,aspStart,aspEnd-aspStart-2)

do
setms=re1.execute(tmp_str)
ifms.count0then
setm=ms(0)
tmp_str=re1.replace(tmp_str,"hughchiu_rtcode=hughchiu_rtcode&"&m.submatches(0))
else
exitdo
endif
loop

setm=nothing
setms=nothing

execode=execode&re.replace(tmp_str,"hughchiu_rtcode=hughchiu_rtcode&")
aspStart=inStr(aspEnd,content,"<%")+2
loop

setre1=nothing
setre=nothing

execode=execode&vbcrlf&"hughchiu_rtcode=hughchiu_rtcode&"""&replace(replace(Mid(content,aspEnd),"""",""""""),vbcrlf,"""&vbcrlf&""")&""""&vbcrlf
get_exe_code="<%"&execode&"%>"
EndFunction
functionasp2html(filename)
dimcode
code=replace(replace(replace(get_exe_code(filename),"hughchiu_rtcode=hughchiu_rtcode&"""""&vbcrlf,""),"<%",""),"%>","")
response.Write(code)
execute(code)
response.Write(hughchiu_rtcode)
asp2html=hughchiu_rtcode
endfunction
%>

利用典范:
setfso=CreateObject("Scripting.FileSystemObject")
setf=fso.CreateTextFile(server.mappath("youpage.htm"),true)
f.WriteLine(asp2html("youpage.asp"))
f.close
setf=nothing
setfso=nothing
但愿这个函数对人人有点用,因为程度无限,有错的中央请人人指出,并但愿能加以改善。
</p>源代码保护方面其实现在考虑得没那么多了..NET也可以反编译.ASP写得复杂的话别人能看得懂的话.他也有能力自己写了.这方面担心的倒不太多.纵观现在网上可以下载的那些所谓BBS还有什么网站等等的源代码
作者: 蒙在股里    时间: 2015-1-20 11:51
下载一个源代码,然后再下载一个VBScript帮助,在源代码中遇到不认识的函数或是其他什么程序,都可以查帮助进行解决,这样学习效率很高。
作者: 简单生活    时间: 2015-1-29 07:04
作为IE上广为流传的动态网页开发技术,ASP以它简单易学博得了广大WEB程序爱好这的青睐,而且它对运行环境和开发品台的不挑剔,以及有大量有效的参考手册,极大的推广了它的发展。
作者: 只想知道    时间: 2015-2-2 21:29
你可以通过继承已有的对象最大限度保护你以前的投资。并且C#和C++、Java一样提供了完善的调试/纠错体系。
作者: 变相怪杰    时间: 2015-2-8 06:10
掌握asp的特性而且一定要知道为什么。
作者: 山那边是海    时间: 2015-2-24 10:42
还有如何才能在最短的时间内学完?我每天可以有效学习2小时,双休日4小时。
作者: 再见西城    时间: 2015-3-7 12:00
ASP.Net和ASP的最大区别在于编程思维的转换,而不仅仅在于功能的增强。ASP使用VBS/JS这样的脚本语言混合html来编程,而那些脚本语言属于弱类型、面向结构的编程语言,而非面向对象,这就明显产生以下几个问题:
作者: 爱飞    时间: 2015-3-15 03:44
用户端的浏览器不需要提供任何别的支持,这样大提高了用户与服务器之间的交互的速度。




欢迎光临 仓酷云 (http://ckuyun.com/) Powered by Discuz! X3.2