|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
ASP由于使用了COM组件所以它会变的十分强大,但是这样的强大由于WindowsNT系统最初的设计问题而会引发大量的安全问题。只要在这样的组件或是操作中一不注意,哪么外部攻击就可以取得相当高的权限而导致网站瘫痪或者数据丢失;ClassTemplate
Privatem_FileName,m_Root,m_Unknowns,m_LastError,m_HaltOnErr
Privatem_ValueList,m_BlockList
Privatem_RegExp
PrivateSubClass_Initialize
Setm_ValueList=CreateObject("Scripting.Dictionary")
Setm_BlockList=CreateObject("Scripting.Dictionary")
setm_RegExp=NewRegExp
m_RegExp.IgnoreCase=True
m_RegExp.Global=True
m_FileName=""
m_Root="."
m_Unknowns="remove"
m_LastError=""
m_HaltOnErr=true
EndSub
PrivateSubClass_Terminate
Setm_RegExp=Nothing
Setm_BlockMatches=Nothing
Setm_ValueMatches=nothing
EndSub
PublicPropertyGetClassName()
ClassName="Template"
EndProperty
PublicPropertyGetVersion()
Version="1.0"
EndProperty
PrivateFunctionLoadFile(ByValchartype)
DimFilename,fso,hndFile
Filename=m_Root
IfRight(Filename,1)"/"AndRight(Filename,1)""ThenFilename=Filename&"/"
Filename=Server.MapPath(Filename&m_FileName)
SetStreamObject=Server.CreateObject("Adodb.Stream")
StreamObject.Type=1
StreamObject.Mode=3
StreamObject.Open
StreamObject.Position=0
StreamObject.LoadFromFileFilename
StreamObject.Position=0
StreamObject.Type=2
StreamObject.CharSet=chartype
LoadFile=StreamObject.readtext()
IfLoadFile=""ThenShowError("0x11<br>CouldNotLoadTheFile"&m_FileName&"!")
EndFunction
PrivateSubShowError(ByValmsg)
m_LastError=msg
Response.Write"<spanstyle=""font-size:12px;color:red"">ErrorID:"&msg&"</span>"
Ifm_HaltOnErrThenResponse.End
EndSub
PublicSubset_root(ByValValue)
m_Root=Value
EndSub
PublicFunctionget_root()
get_root=m_Root
EndFunction
PublicPropertyLetRoot(ByValValue)
set_root(Value)
EndProperty
PublicPropertyGetRoot()
Root=m_Root
EndProperty
PublicSubset_file(ByValhandle,ByValfilename,ByValchartype)
m_FileName=filename
m_BlockList.AddHandle,LoadFile(chartype)
EndSub
PublicFunctionget_file()
get_file=m_FileName
EndFunction
PublicSubset_unknowns(ByValunknowns)
m_Unknowns=unknowns
EndSub
PublicFunctionget_unknowns()
get_unknowns=m_Unknowns
EndFunction
PublicPropertyLetUnknowns(ByValunknown)
m_Unknowns=unknown
EndProperty
PublicPropertyGetUnknowns()
Unknowns=m_Unknowns
EndProperty
PublicSubset_block(ByValParent,ByValBlockTag,ByValName)
DimMatches
m_RegExp.Pattern="<!--s+BEGIN"&BlockTag&"s+-->([sS.]*)<!--s+END"&BlockTag&"s+-->"
IfNotm_BlockList.Exists(Parent)ThenShowError("0x12<br>UndefinedBlockTag"&Parent&"!")
setMatches=m_RegExp.Execute(m_BlockList.Item(Parent))
ForEachMatchInMatches
m_BlockList.AddBlockTag,Match.SubMatches(0)
m_BlockList.Item(Parent)=Replace(m_BlockList.Item(Parent),Match.Value,"{"&Name&"}")
Next
setMatches=nothing
EndSub
PublicSubset_var(ByValName,ByValValue,ByValAppEnd)
DimVal
IfIsNull(Value)ThenVal=""ElseVal=Value
Ifm_ValueList.Exists(Name)Then
IfAppEndThenm_ValueList.Item(Name)=m_ValueList.Item(Name)&Val_
Elsem_ValueList.Item(Name)=Val
Else
m_ValueList.AddName,Value
EndIf
EndSub
PublicSubunset_var(ByValName)
Ifm_ValueList.Exists(Name)Thenm_ValueList.Remove(Name)
EndSub
PrivateFunctionInstanceValue(ByValBlockTag)
Dimkeys,i
InstanceValue=m_BlockList.Item(BlockTag)
keys=m_ValueList.Keys
Fori=0Tom_ValueList.Count-1
InstanceValue=Replace(InstanceValue,"{"&keys(i)&"}",m_ValueList.Item(keys(i)))
Next
EndFunction
PublicSubparse(ByValName,ByValBlockTag,ByValAppEnd)
IfNotm_BlockList.Exists(BlockTag)ThenShowError("0x12<br>UndefinedBlockTag"&Parent&"!")
Ifm_ValueList.Exists(Name)Then
IfAppEndThenm_ValueList.Item(Name)=m_ValueList.Item(Name)&InstanceValue(BlockTag)_
Elsem_ValueList.Item(Name)=InstanceValue(BlockTag)
Else
m_ValueList.AddName,InstanceValue(BlockTag)
EndIf
EndSub
PrivateFunctionfinish(ByValcontent)
SelectCasem_Unknowns
Case"keep"finish=content
Case"remove"
m_RegExp.Pattern="{[^
}]+}"
finish=m_RegExp.Replace(content,"")
Case"comment"
m_RegExp.Pattern="{([^
}]+)}"
finish=m_RegExp.Replace(content,"<!--TemplateVariable$1Undefined-->")
CaseElsefinish=content
EndSelect
EndFunction
PublicSuboutput(ByValName)
IfNotm_ValueList.Exists(Name)ThenShowError("0x13<br>CouldNotFindTag"&Name&"!")
Response.Write(finish(m_ValueList.Item(Name)))
EndSub
EndClass在实现ERP等高端的ASP应用时,用户需要提供核心的经营资料,需要ASP商有很高的信用度。楼上说交互性不好,太牵强了吧。在微软提供的一套框架中,利用asp做网站,开发效率高,使用人数少,减少不必要的开销。交互性是互动方式,是有开发人员决定的。 |
|