function createnewsfile(id)
dim rs,sql,pclass
set rs = server.createobject("adodb.recordset")
sql = "select id,classid,title,content,author,source,keywords,bimg,simg,filename,pagetype,addtime from NCMS_news where id=" & id
rs.open sql,conn,1,1
dim databox:databox = rs.getrows()
rs.close
rs.open "select * from ncms_class where id=" & databox(1,0),conn,1,1
pclass=rs("cname")
rs.close
set rs = nothing
dim Temp:Temp = ""
if databox(10,0) = 0 then
Temp = processcustomtag(loadtempletfile("../templet/" & getclassall(databox(1,0),2) & ""))
else
Temp = processcustomtag(loadtempletfile("../templet/" & site_stemp & ""))
end if
dim charclass
set charclass = new stringclass
dim PatrnStr,AdvCont
PatrnStr = ".*?"
Temp = charclass.replacestr(PatrnStr,Temp,"" & charclass.getstr(databox(2,0)) & " - " & site_name & "")
PatrnStr = "\{\$pclass\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,pclass)
PatrnStr = "{news:[^<>]+?\/}"
Temp = charclass.newscustomtag(PatrnStr,Temp,databox(1,0),databox(0,0),databox(6,0))
PatrnStr = "\{\$id\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,databox(0,0))
PatrnStr = "\{\$classid\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,databox(1,0))
PatrnStr = "\{\$title\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,databox(2,0))
PatrnStr = "\{\$author\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,databox(4,0))
PatrnStr = "\{\$source\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,databox(5,0))
PatrnStr = "\{\$keywords\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,databox(6,0))
PatrnStr = "\{\$click\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,click(databox(0,0)))
PatrnStr = "\{\$addtime\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,databox(11,0))
PatrnStr = "\{\$guide\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,guide(databox(1,0)))
PatrnStr = "\{\$search\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,search())
PatrnStr = "\{\$toolbar\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,toolbar(databox(0,0)))
PatrnStr = "\{\$description\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,site_description)
PatrnStr = "\{\$copyright\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,site_copyright)
PatrnStr = "\{\$root\$\}"
Temp = charclass.replacestr(PatrnStr,Temp,site_root)
PatrnStr = "\{\$advarea\$\}"
AdvCont = databox(3,0)
AdvCont = charclass.replacestr(PatrnStr,AdvCont,advshow(site_advcode))
dim tempArr,n,sPATH,ePATH,cPATH:cPATH = "" & site_root & "/" & site_html & "/" & getclasspath(databox(1,0)) & "/"
if instr(databox(9,0),"/") = 0 then
createdir(server.mappath(cPATH))
else
tempArr = split(databox(9,0),"/")
for n = 0 to ubound(tempArr)
ePATH = replace(databox(9,0),tempArr(n),"")
next
createdir(server.mappath(cPATH & ePATH))
end if
dim TTemp:TTemp = Temp
dim arrcont:arrcont = split(AdvCont,"{$split$}",-1,1)
dim PageHTM:PageHTM = ""
dim i,j,k:k = ubound(arrcont)
for i = 0 to k
if i = 0 then
sPATH = "" & cPATH & databox(9,0) & site_extname & ""
else
sPATH = "" & cPATH & databox(9,0) & site_extname & ""
sPATH = left(sPATH,(len(sPATH)-len(site_extname))) & "_" & i + 1 & site_extname
end if
if sPATH = "" then
createnewsfile = false
exit function
end if
if k >= 1 then
PageHTM = "【本新闻共" & k + 1 & "页】-"
if i = 0 then
PageHTM = PageHTM & "【首页】-"
PageHTM = PageHTM & "【上页】-"
end if
if i > 1 then
PageHTM = PageHTM & "【首页】-"
PageHTM = PageHTM & "【上页】-"
end if
if i = 1 Then
PageHTM = PageHTM & "【首页】-"
PageHTM = PageHTM & "【上页】-"
end if
if i < k then
PageHTM = PageHTM & "【下页】-"
PageHTM = PageHTM & "【尾页】-"
end if
if i = k then
PageHTM = PageHTM & "【下页】-"
PageHTM = PageHTM & "【尾页】-"
end if
PageHTM = PageHTM & "【当前在第" & i + 1 & "页】
"
else
PageHTM = ""
end if
PatrnStr = "\{\$content\$\}"
Temp = charclass.replacestr(PatrnStr,TTemp,"" & chr(10) & "" & chr(10) & arrcont(i) & PageHTM & chr(10) & "
" & chr(10))
dim objstream
set objstream = server.createobject("adodb.stream")
with objstream
.open
.charset = "" & chrset & ""
.position = objstream.size
.writetext = Temp
.savetofile server.mappath(sPATH),2
.close
end with
set objstream = nothing
next
if err.number <> 0 then
err.clear
createnewsfile = false
else
conn.execute("update NCMS_news set created=1 where id=" & databox(0,0))
createnewsfile = true
databox = ""
end if
end function