Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Response.Charset="GB2312"
Server.ScriptTimeOut=999999999
Dim TagArray(2),ContentArray(2)
TagArray(0) = "{pxkt_网站标题}"
ContentArray(0) = "中国地产联盟"
TagArray(1) = "{pxkt_网站内容}"
ContentArray(1) = "中国地产联盟内容"
allcontent=AutoCreateContent("template/index.html",TagArray,ContentArray)
Call AutoCreatePage("index.html",allcontent)
'【功能】自定义模板标签
Function ProcessCustomTags(ByVal sContent,ByVal TagArray,ByVal ContentArray)
Dim objRegEx, Match, Matches '建立正则表达式
Set objRegEx = New RegExp '查找内容
objRegEx.Pattern = TagArray '忽略大小写
objRegEx.IgnoreCase = True '全局查找
objRegEx.Global = True 'Run the search against the content string we've been passed
Set Matches = objRegEx.Execute(sContent)
For Each Match in Matches
sContent = Replace(sContent,Match.Value,ContentArray)
Next
set Matches = Nothing
set objRegEx = Nothing
ProcessCustomTags = sContent
End Function
'【功能】读取模板并替换
Function AutoCreateContent(template,TagArray,ContentArray)
Dim Fso,OpenTextFile,insert
Set Fso = CreateObject("Scripting.FileSystemObject")
Set OpenTextFile = Fso.opentextfile(server.mappath(template),1,True)
insert = OpenTextFile.ReadAll
Set OpenTextFile = Nothing
Set Fso = Nothing
For i=0 To ubound(TagArray)
insert = ProcessCustomTags(insert,TagArray(i),ContentArray(i))
Next
AutoCreateContent = insert
End Function
'【功能】写入内容生成首页
Function AutoCreatePage(Page,AllContent)
Dim Fso,CreateTextFile
Set Fso = CreateObject("Scripting.FileSystemObject")
Set CreateTextFile = fso.CreateTextFile(server.mappath(Page))
CreateTextFile.WriteLine AllContent
CreateTextFile.close
Set CreateTextFile = nothing
Set Fso = Nothing
End Function