|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
asp可以使用微软的activeX使得网页功能无比强大,不过安全性也较差,而且是基于的windows服务器,所以性能稳定性也一般模板用php用惯了,用phplib用惯了,没有他以为很不恬逸
上彀查找没有人写,本人写了一个,asp程度不高,但愿
能有妙手指导修正。
<%
====================================
Name:TemplateClass
Purpose:ParseandoutputHTMLpage
Date:10.2002
Author:pig
Email:pigzjq@sina.com
Phone:13910320759
====================================
classTemplate
dimgs_root
dimgs_handle()
dimgs_file()
dimgs_keys()
dimgs_keyVars()
dimgs_vars()
机关函数
PrivateSubTemplate_Initialize()
callof_setRoot(".")
callof_redimVar()
EndSub
functionof_redimVar()
redimgs_handle(0)
redimgs_file(0)
redimgs_keys(0)
redimgs_keyVars(0)
redimgs_vars(0)
endfunction
设置模板寄存路径
functionof_setRoot(byValps_root)
ifps_root""then
gs_root=ps_root
endif
endfunction
设置文件称号函数
functionof_setFile(byValps_fileHandle,byValps_fileName)
ifps_fileName""then
li_maxNum=UBound(gs_handle)
gs_handle(li_maxNum)=ps_fileHandle
gs_file(li_maxNum)=gs_root+"/"+ps_fileName
li_maxNum=li_maxNum+1
redimPreservegs_handle(li_maxNum)
redimPreservegs_file(li_maxNum)
endif
endfunction
设置要交换的参数变量
functionof_setVar(byValps_key,byValps_var)
ifps_key""andps_var""then
li_keyIndex=of_getIndex(gs_keys,ps_key)
ifli_keyIndex="no"then
li_maxNum=UBound(gs_keys)
gs_keys(li_maxNum)=ps_key
gs_keyVars(li_maxNum)="{"&ps_key&"}"
gs_vars(li_maxNum)=ps_var
li_maxNum=li_maxNum+1
redimPreservegs_keys(li_maxNum)
redimPreservegs_keyVars(li_maxNum)
redimPreservegs_vars(li_maxNum)
else
gs_keys(li_keyIndex)=ps_key
gs_keyVars(li_keyIndex)="{"&ps_key&"}"
gs_vars(li_keyIndex)=ps_var
endif
endif
endfunction
界说重载笔墨块儿
functionof_setBlock(byValps_parent,byValps_handle,byValps_name)
if(notof_loadFile(ps_parent))then
ls_error="of_loadFileunabletoload"+ps_parent
response.write(ls_error)
of_setBlock=false
exitfunction
endif
ifps_name=""then
ps_name=ps_handle
endif
ls_string=of_getVar(ps_parent)
ls_pattern="<!--s*BEGIN"&ps_handle&"s*-->(.*)<!--s*END"&ps_handle&"s*-->"
SetregEx=NewRegExp
regEx.Pattern="
"
regEx.IgnoreCase=false
regEx.global=true
ls_string=regEx.Replace(ls_string,"")
regEx.Pattern=ls_pattern
regEx.Multiline=true
regEx.global=false
SetMatches=regEx.Execute(ls_string)
ls_string=regEx.Replace(ls_string,"{"&ps_name&"}")
ForEachMatchinMatches
ls_value=Match.value
Next
regEx.Pattern="<!--s*BEGIN"&ps_handle&"s*-->"
regEx.IgnoreCase=false
regEx.global=true
ls_value=regEx.Replace(ls_value,"")
regEx.Pattern="<!--s*END"&ps_handle&"s*-->"
regEx.IgnoreCase=false
regEx.global=true
ls_value=regEx.Replace(ls_value,"")
callof_setVar(ps_handle,ls_value)
callof_setVar(ps_parent,ls_string)
endfunction
装载变量内容
functionof_loadFile(byValps_handle)
li_keyIndex=of_getIndex(gs_keys,ps_handle)
ifli_keyIndex="no"then
li_fileIndex=of_getIndex(gs_handle,ps_handle)
ifli_fileIndex="no"then
ls_error="loadfile:"+ps_handle+"isnotavalidhandle."
response.write(ls_error)
of_loadFile=false
exitfunction
endif
ls_fileName=gs_file(li_fileIndex)
ls_fileName=server.mappath(ls_fileName)
SetMyFileObject=Server.CreateObject("Scripting.FileSystemObject")
li_exist=MyFileObject.FileExists(ls_fileName)
ifli_existthen
SetMyTextFile=MyFileObject.OpenTextFile(ls_fileName)
ls_file=MyTextFile.readAll()
MyTextFile.Close
callof_setVar(ps_handle,ls_file)
else
ls_error="loadfile:"+ls_fileName+"isnotavalidfileorpath."
response.write(ls_error)
of_loadFile=false
exitfunction
endif
endif
of_loadFile=true
</p>ASP在国内异常流行,因为国内大多使用的是盗版的Windows和盗版的SQLServer,而ASP+COM+SQLServer实际上也是一种不错的搭配,其性能也不输于PHP+MYSQL,特别是Windows系统和SQLServer都有图形界面,比APACHE和MYSQL易于维护,因此对于不重视知识产权的国家来说也是一种不错的选择。 |
|