<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/check.asp"-->
<%
Dim HtmlContent,XMLDom,HeadTitle,NowUserID,NowUserName,topicmode
Dim AskedPageList,strLink
Dim maxperpage,CurrentPage,Pcount,totalrec,totalnumber
NowUserID = NewAsp.UserID
NowUserName = NewAsp.UserName
topicmode = 3
maxperpage = Newasp.ChkNumeric(NewAsp.Posts_Setting(30))
If maxperpage = 0 Then maxperpage = 20
CurrentPage = NewAsp.ChkNumeric(Request("page"))
If CurrentPage = 0 Then CurrentPage = 1
HeadTitle = "我的分享"
HtmlContent = NewAsp.LoadTemplate("userpostlist")
HtmlContent = Replace(HtmlContent, "{$HeadTitle}", HeadTitle)
LoadTopiclist()
Response.Write NewAsp.ArchiveHtml(HtmlContent)
NewAsp.CloseConn()

Sub LoadTopiclist()
	Dim SQL,Rs,topidlist,Node
	Set XMLDom = NewAsp.CreateXMLDoc("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
	XMLDom.appendChild(XMLDom.createElement("xml"))
	XMLDom.documentElement.setAttribute "action",3
	XMLDom.documentElement.setAttribute "nowuserid",NowUserID
	XMLDom.documentElement.setAttribute "nowusername",NowUserName
	XMLDom.documentElement.setAttribute "topicmode",topicmode
	XMLDom.documentElement.setAttribute "headtitle",HeadTitle
	totalnumber = NewAsp.Execute("SELECT COUNT(*) FROM NC_Ask_Topic WHERE userid="&NowUserID&" And topicmode=3 And LockTopic=0")(0)
	totalrec = totalnumber
	Pcount = CLng(totalrec / maxperpage)  '得到总页数
	If Pcount < totalrec / maxperpage Then Pcount = Pcount + 1
	If Pcount < 1 Then Pcount = 1
	If CurrentPage < 1 Then CurrentPage = 1
	If CurrentPage > Pcount Then CurrentPage = Pcount
	
	XMLDom.documentElement.setAttribute "pagesize",maxperpage
	XMLDom.documentElement.setAttribute "page",CurrentPage
	XMLDom.documentElement.setAttribute "totalnumber",totalnumber
	XMLDom.documentElement.setAttribute "totalrec",totalrec
	XMLDom.documentElement.setAttribute "pagecount",Pcount
	If Not IsObject(Conn) Then ConnectionDatabase
	Set Rs = NewAsp.CreateAXObject("ADODB.Recordset")
	SQL="SELECT TopicID,classid,userid,classname,title,PostUsername,Expired,Closed,PostTable,DateAndTime,LastPostTime,LockTopic,Reward,Hits,PostNum,CommentNum,TopicMode,Highlight,Broadcast,Anonymous,IsTop FROM NC_Ask_Topic WHERE userid="&NowUserID&" And topicmode=3 And LockTopic=0 ORDER BY LastPostTime DESC"
	Rs.Open SQL,Conn,1,1
	If Not (Rs.BOF And Rs.EOF) Then
		If CurrentPage >1 Then
			Rs.Move (CurrentPage-1) * maxperpage
		End If
	End If
	If Not Rs.EOF Then
		SQL=Rs.GetRows(maxperpage)
		Set topidlist=NewAsp.ArrayToxml(SQL,Rs,"row","topic")
	Else
		Set topidlist=Nothing
	End If
	Set Rs=Nothing
	SQL=Empty
	If Not topidlist Is Nothing Then 
		For Each Node in topidlist.documentElement.SelectNodes("row")
			Node.selectSingleNode("@title").text=NewAsp.Checkstr(Node.selectSingleNode("@title").text)
			Node.selectSingleNode("@dateandtime").text=NewAsp.FormatDate(Node.selectSingleNode("@dateandtime").text,5)
			If topicmode=0 Then
				If CLng(Node.selectSingleNode("@closed").text) = 1 Then
					Node.selectSingleNode("@topicmode").text=5
				End If
			End If
		Next
		XMLDom.documentElement.appendChild(topidlist.documentElement)
		Set topidlist=Nothing
	End If
	strLink = NewAsp.InstallDir & "usershare.asp?"
	AskedPageList = showlistpage(CurrentPage,Pcount,strLink)
	transform_topicList()
	HtmlContent = Replace(HtmlContent, "{$AskedPageList}", AskedPageList)
End Sub
Sub transform_topicList()
	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/userpostlist.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="AskedPageList"
	Node.attributes.setNamedItem(CNode)
	Node.text=AskedPageList
	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

%>