www.gusucode.com > 全球营销软件站整站源码4月最新数据 4.0源码程序 > 801wyxqf\ask\share.asp

    <!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/ubbcode.asp"-->
<%
Dim HtmlContent,XMLDom,TopicUseTable
Dim topicid,classid,classname,child,HeadTitle,topicmode,HeadCategory,isnowuser
Dim maxperpage,CurrentPage,Pcount,totalrec,totalnumber
Dim icons,PostNum,allowAnswers,allowDeletes
allowAnswers = NewAsp.ChkNumeric(NewAsp.Posts_Setting(4))
allowDeletes = NewAsp.ChkNumeric(NewAsp.Posts_Setting(5))
maxperpage = 10
CurrentPage = NewAsp.ChkNumeric(Request("page"))
If CurrentPage = 0 Then CurrentPage = 1
topicid = NewAsp.ChkNumeric(Request("topicid"))

mainshare()
NewAsp.CloseConn()

Sub mainshare()
	If topicid = 0 Then Exit Sub
	HtmlContent = NewAsp.LoadTemplate("share")
	shareTopic()
	CategoryInfo()
	LoadShareList()
	HtmlContent = Replace(HtmlContent, "{$HeadTitle}", HeadTitle)
	HtmlContent = Replace(HtmlContent, "{$ClassID}", 0)
	Response.Write NewAsp.ArchiveHtml(HtmlContent)
End Sub

Sub shareTopic()
	If topicid = 0 Then Exit Sub
	Dim SQL,Rs,Node
	Newasp.Execute ("UPDATE NC_Ask_Topic SET Hits=Hits+1 WHERE topicid="&topicid)
	SQL="SELECT TopicID,classid,userid,classname,title,PostUsername,Expired,Closed,PostTable,DateAndTime,LastPostTime,ExpiredTime,LockTopic,Reward,Hits,PostNum,CommentNum,TopicMode,Broadcast,Anonymous,supplement FROM NC_Ask_Topic WHERE topicid="&topicid&" And topicmode=3"
	Set Rs = NewAsp.Execute(SQL)
	If Rs.BOF And Rs.EOF Then
		Set Rs = Nothing
		NewAsp.FoundErr = True
		Exit Sub
	End If
	Set XMLDom = NewAsp.RecordsetToxml(Rs,"topic","xml")
	Set Rs = Nothing
	Set Node = XMLDom.documentElement.selectSingleNode("topic")
	topicid = CLng(Node.selectSingleNode("@topicid").text)
	classid = CLng(Node.selectSingleNode("@classid").text)
	topicmode = CLng(Node.selectSingleNode("@topicmode").text)
	PostNum = CLng(Node.selectSingleNode("@postnum").text)
	HeadTitle = Trim(Node.selectSingleNode("@title").text)
	TopicUseTable = Trim(Node.selectSingleNode("@posttable").text)
	icons = topicmode

	If CLng(Node.selectSingleNode("@userid").text) <> NewAsp.UserID Then
		isnowuser = 0
	Else
		isnowuser = 1
	End If
	XMLDom.documentElement.setAttribute "postuserid",Node.selectSingleNode("@userid").text
	Set Node = Nothing
	HtmlContent = Replace(HtmlContent, "{$TopicID}", topicid)
	HtmlContent = Replace(HtmlContent, "{$ClassID}", classid)
End Sub

Sub LoadShareList()
	If NewAsp.FoundErr Then Exit Sub
	XMLDom.documentElement.setAttribute "classname",classname
	XMLDom.documentElement.setAttribute "userid",NewAsp.UserID
	XMLDom.documentElement.setAttribute "topicmode",topicmode
	XMLDom.documentElement.setAttribute "isnowuser",isnowuser
	XMLDom.documentElement.setAttribute "icons",icons
	XMLDom.documentElement.setAttribute "allowanswers",allowAnswers
	XMLDom.documentElement.setAttribute "allowdeletes",allowDeletes

	Dim SQL,Rs,Postlist,Node,NowPostNum
	Dim satisanswer,otheranswer,i
	i=0
	SQL="SELECT postsid,classid,TopicID,userid,UserName,topic,content,addText,PostTime,DoneTime,star,satis,LockTopic,PostsMode,VoteNum,Plus,Minus,PostIP,Report FROM ["&TopicUseTable&"] WHERE topicid="&topicid&" and LockTopic=0 ORDER BY postsid ASC"
	Set Rs = NewAsp.Execute(SQL)
	If Not Rs.EOF Then
		SQL=Rs.GetRows(-1)
		Set Postlist=NewAsp.ArrayToxml(SQL,Rs,"row","postlist")
	Else
		Set Postlist=Nothing
	End If
	Set Rs=Nothing
	SQL=Empty
	If Not Postlist Is Nothing Then
		NowPostNum = Postlist.documentElement.SelectNodes("row[@postsmode=1]").Length
		XMLDom.documentElement.setAttribute "nowpostnum",NowPostNum
		For Each Node in Postlist.documentElement.SelectNodes("row")
			Node.selectSingleNode("@topic").text=NewAsp.Checkstr(Node.selectSingleNode("@topic").text)
			Node.selectSingleNode("@posttime").text=NewAsp.FormatDate(Node.selectSingleNode("@posttime").text,1)
			Node.selectSingleNode("@content").text=UBBCode(Node.selectSingleNode("@content").text)
			Node.attributes.setNamedItem(Postlist.createNode(2,"i","")).text = i
			i = i + 1
		Next
		XMLDom.documentElement.appendChild(Postlist.documentElement)
		Set Postlist=Nothing
	Else
		NowPostNum = 0
		XMLDom.documentElement.setAttribute "nowpostnum",NowPostNum
	End If
	'--如果回答数不正确,更新回答总数
	If PostNum <> NowPostNum Then
		NewAsp.Execute ("UPDATE NC_Ask_Topic SET PostNum=" & NowPostNum & " WHERE topicid="&topicid)
	End If
	transform_sharelist()
End Sub

Sub transform_sharelist()
	Dim proc,XMLStyle,node,cnode,XSLTemplate
	Set XSLTemplate=NewAsp.CreateAXObject("Msxml2.XSLTemplate" & MsxmlVersion )
	Set XMLStyle=NewAsp.CreateXmlDoc("msxml2.FreeThreadedDOMDocument"& MsxmlVersion )
	XMLStyle.load Server.MapPath(NewAsp.TemplatePath & "xslt/share.xslt")
	Set Node=XMLStyle.createNode(1,"xsl:variable","http://www.w3.org/1999/XSL/Transform")
	Set CNode=XMLStyle.createNode(2,"name","")
	CNode.text="installdir"
	Node.attributes.setNamedItem(CNode)
	Node.text=NewAsp.InstallDir
	XMLStyle.documentElement.appendChild(node)
	Set Node=XMLStyle.createNode(1,"xsl:variable","http://www.w3.org/1999/XSL/Transform")
	Set CNode=XMLStyle.createNode(2,"name","")
	CNode.text="skinurl"
	Node.attributes.setNamedItem(CNode)
	node.text=NewAsp.AskedSkinUrl
	XMLStyle.documentElement.appendChild(node)
	XSLTemplate.stylesheet=XMLStyle
	Set proc = XSLTemplate.createProcessor()
	proc.input = XMLDom
	proc.transform()
	Dim procstr
	procstr = proc.output
	HtmlContent = Replace(HtmlContent, "{$TopicList}", procstr)
	Set XMLDom=Nothing
	Set proc=Nothing
	Set XMLStyle=Nothing
	Set XSLTemplate=Nothing
End Sub

Sub CategoryInfo()
	If NewAsp.FoundErr Then Exit Sub
	Dim iAskCount,cid,cNameText
	Dim Catelist,Childlist,Node,parentid,Parentstr
	cid = classid
	child = 0
	Set Catelist = Application(NewAsp.CacheName&"_classlist")
	If Not Catelist Is Nothing Then
		For Each Node in Catelist.documentElement.SelectNodes("row[@classid="&classid&"]")
			classname=Node.selectSingleNode("@classname").text
			child=CLng(Node.selectSingleNode("@child").text)
			parentid=CLng(Node.selectSingleNode("@parentid").text)
			Parentstr=Node.selectSingleNode("@parentstr").text
			If child>0 Then
				cid=classid
			Else
				cid=CLng(Node.selectSingleNode("@parentid").text)
			End If
		Next
		cNameText = ""
		If parentid>0 Then
			Dim classType,cateid
			Dim ArrayParent,i,n,DocNodes
			ArrayParent = Split(Parentstr, ",")
			n=0
			For i=0 To UBound(ArrayParent)
				If NewAsp.ChkNumeric(ArrayParent(i))>0 Then
					If n=0 Then
						DocNodes="row[@classid="&ArrayParent(i)&""
					Else
						DocNodes=DocNodes&" or @classid="&ArrayParent(i)&""
					End If
					n=n+1
				End If
			Next
			If DocNodes<>"" Then
				DocNodes=DocNodes&"]"
				For Each Node in Catelist.documentElement.SelectNodes(DocNodes)
					classType=Node.selectSingleNode("@classname").text
					cateid=Node.selectSingleNode("@classid").text
					cNameText=cNameText&"<a href="""&NewAsp.InstallDir&"showlist.asp?classid="&cateid&"&topicmode=3&page=1"">"&classType&"</a> &gt; "
					HeadCategory=HeadCategory&classType&"-"
				Next
			End If
		End If
		cNameText=cNameText&"<a href="""&NewAsp.InstallDir&"showlist.asp?classid="&classid&"&topicmode=3&page=1"">"&classname&"</a>"
		HeadCategory=HeadCategory&classname
		Set Catelist = Nothing
	End If
	HtmlContent = Replace(HtmlContent, "{$Current}", cNameText)
	HtmlContent = Replace(HtmlContent, "{$ClassName}", classname)
End Sub
%>