SoFunction
Updated on 2025-04-07

A small and practical asp cms --- NCMS

function createnewsfile(id)
 dim rs,sql,pclass
 set rs = ("")
 sql = "select id,classid,title,content,author,source,keywords,bimg,simg,filename,pagetype,addtime from NCMS_news where select * from ncms_class where cname")
 
 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 = "<title>.*?</title>"
  Temp = (PatrnStr,Temp,"<title>" & (databox(2,0)) & " - " & site_name & "</title>")
  PatrnStr = "\{\$pclass\$\}"
  Temp = (PatrnStr,Temp,pclass)
  PatrnStr = "{news:[^<>]+?\/}"
  Temp = (PatrnStr,Temp,databox(1,0),databox(0,0),databox(6,0))
  PatrnStr = "\{\$id\$\}"
  Temp = (PatrnStr,Temp,databox(0,0))
  PatrnStr = "\{\$classid\$\}"
  Temp = (PatrnStr,Temp,databox(1,0))
  PatrnStr = "\{\$title\$\}"
  Temp = (PatrnStr,Temp,databox(2,0))
  PatrnStr = "\{\$author\$\}"
  Temp = (PatrnStr,Temp,databox(4,0))
  PatrnStr = "\{\$source\$\}"
  Temp = (PatrnStr,Temp,databox(5,0))
  PatrnStr = "\{\$keywords\$\}"
  Temp = (PatrnStr,Temp,databox(6,0))
  PatrnStr = "\{\$click\$\}"
  Temp = (PatrnStr,Temp,click(databox(0,0)))
  PatrnStr = "\{\$addtime\$\}"
  Temp = (PatrnStr,Temp,databox(11,0))
  PatrnStr = "\{\$guide\$\}"
  Temp = (PatrnStr,Temp,guide(databox(1,0)))
  PatrnStr = "\{\$search\$\}"
  Temp = (PatrnStr,Temp,search())
  PatrnStr = "\{\$toolbar\$\}"
  Temp = (PatrnStr,Temp,toolbar(databox(0,0)))
  PatrnStr = "\{\$description\$\}"
  Temp = (PatrnStr,Temp,site_description)
  PatrnStr = "\{\$copyright\$\}"
  Temp = (PatrnStr,Temp,site_copyright)
  PatrnStr = "\{\$root\$\}"
  Temp = (PatrnStr,Temp,site_root)
  PatrnStr = "\{\$advarea\$\}"
  AdvCont = databox(3,0)
  AdvCont = (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((cPATH))
 else
  tempArr = split(databox(9,0),"/")
  for n = 0 to ubound(tempArr)
   ePATH = replace(databox(9,0),tempArr(n),"")
  next
  createdir((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 = "<p align=""center"">[This news is a total of <font color=""red""" & k + 1 & "</font> pages]-"
   if i = 0 then
PageHTM = PageHTM & "【Homepage】-"
PageHTM = PageHTM & "【Previous Page】-"
   end if
   if i > 1 then
PageHTM = PageHTM & "【<a href=""" & cPATH & databox(9,0) & site_extname & """>Home</a>]-"
PageHTM = PageHTM & "【<a href=""" & cPATH & databox(9,0) & "_" & i & site_extname & """>Previous Page</a>]-"
   end if
   if i = 1 Then
PageHTM = PageHTM & "【<a href=""" & cPATH & databox(9,0) & site_extname & """>Home</a>]-"
PageHTM = PageHTM & "【<a href=""" & cPATH & databox(9,0) & site_extname & """>Previous Page</a>]-"
   end if
   if i < k then
PageHTM = PageHTM & "【<a href=""" & cPATH & databox(9,0) & "_" & i + 2 & site_extname & """>Next Page</a>]-"
PageHTM = PageHTM & "【<a href=""" & cPATH & databox(9,0) & "_" & k + 1 & site_extname & """>Last Page</a>]-"
   end if
   if i = k then
PageHTM = PageHTM & "【Next Page】-"
PageHTM = PageHTM & "【Last Page】-"
   end if
PageHTM = PageHTM & "【Currently on <font color=""red""" & i + 1 & "</font>page]</p>"
  else
   PageHTM = ""
  end if
  PatrnStr = "\{\$content\$\}"
  Temp = (PatrnStr,TTemp,"" & chr(10) & "<div id=""content"">" & chr(10) & arrcont(i) & PageHTM & chr(10) & "</div>" & chr(10))
  dim objstream
  set objstream = ("")
  with objstream
   .open
   .charset = "" & chrset & ""
   .position =
   .writetext = Temp
   .savetofile (sPATH),2
   .close
  end with
  set objstream = nothing
 next
 if <> 0 then
  
  createnewsfile = false
 else
  ("update NCMS_news set created=1 where "
 end if
end function