<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/template.inc"-->
<!--#include file="inc/ubbcode.asp"-->
<%
Dim XMLDom,dataNode,i
Dim m_strTitle,m_strContent,m_strDateTime
Dim HtmlContent,AnnounceID

Call Main()
Call TPL_Flush()
NewAsp.PageEnd()

Sub Main()
	Set TPL_XmlDom=NewAsp.CreateXmlDoc("msxml2.FreeThreadedDOMDocument" & MsxmlVersion)
	If Not TPL_XmlDom.load(NewAsp.TemplatePath&"config.xml") Then
		Response.Write "载入模板配置文件出错!"&NewAsp.TemplatePath&"config.xml"
		Response.End
	End If
	
	AnnounceID=NewAsp.ChkNumeric(Request("AnnounceID"))
	Call LoadAnnounceData()

	HtmlContent = NewAsp.LoadTemplate("announce")
	HtmlContent = Replace(HtmlContent, "{$pagetitle}",  TPL_Config(19)&"："&m_strTitle)
	HtmlContent = Replace(HtmlContent, "{$title}",  TPL_Config(19))
	HtmlContent = Replace(HtmlContent, "{$announceid}", AnnounceID)
	HtmlContent = Replace(HtmlContent, "{$classid}", 0)
	TPL_Scan HtmlContent
	Set XMLDom = Nothing : Set dataNode = Nothing
End Sub

Sub LoadAnnounceData()
	Dim Rs,SQL
	NewAsp.Execute ("UPDATE NC_Announce SET hits=hits+1 WHERE AnnounceID="&AnnounceID)
	Set Rs=Newasp.Execute("SELECT AnnounceID,title,[content],PostTime,writer,hits FROM NC_Announce WHERE AnnounceID="&AnnounceID)
	If Rs.BOF And Rs.EOF Then
		'Set Rs = Nothing
		'Response.Write "<p align=""center"" style=""font-size: 16px;color: red;"">对不起，该页面发生了错误，无法访问! </p>"
		'Response.End
		Exit Sub
	End If
	Set XMLDom = NewAsp.RecordsetToxml(Rs,"row","xml")
	Rs.Close:Set Rs = Nothing
	Set dataNode = XMLDom.documentElement.selectSingleNode("row")
	If Not dataNode Is Nothing Then
		AnnounceID=CLng(dataNode.selectSingleNode("@announceid").text)
		m_strTitle=NewAsp.RemoveHtml(dataNode.selectSingleNode("@title").text)
		m_strContent=ubb.UbbCode(dataNode.selectSingleNode("@content").text)
		dataNode.selectSingleNode("@content").text=m_strContent
		'dataNode.selectSingleNode("@title").text=m_strTitle
		m_strDateTime=NewAsp.FormatToDate(dataNode.selectSingleNode("@posttime").text,TPL_Config(20))
	End If
End Sub

Sub TPL_ParseNode(sTokenType, sTokenName, sVariant)
	Select Case sTokenType
		Case "newasp"
			ParseDataNode		sTokenName,sVariant
	Case Else
	End Select
End Sub

Sub ParseDataNode(sToken,sVariant)
	On Error Resume Next
	Dim Node
	Select Case sToken
		Case "datetime"	:	TPL_Echo m_strDateTime
		Case "topic"	:	TPL_Echo m_strTitle
		Case Else
			If Not IsObject(dataNode) Then Exit Sub
			Set Node = dataNode.selectSingleNode("@"&sToken&"")
			If Not (Node Is Nothing) Then
				TPL_Echo Node.text
			End If
	End Select
	Set Node = Nothing
	If Err Then Err.Clear
End Sub
%>