<!--#INCLUDE FILE="setup.asp" -->
<!--#include file="checkuser.asp" -->
<!--#INCLUDE FILE="theme.asp" -->
<!--#include file="include/char.asp" -->
<!--#include file="include/ubbcode.asp" -->
<%

locat="校友留言"
act="浏览帖子"
Call top(2,1)

Dim topic
Dim TopicID
Dim hits
Dim currentpage,totalpages
Dim pagesize
Dim rs
Dim abgcolor
Dim LinkID

pagesize=Cint(IntVar(8))

call main()


sub main()

TopicID=trim(Request("TopicID"))
if TopicID="" then
	ErrMsg=ErrMsg+"<br><li>请指定您要查看的主题！"
	Call Error("Exclamation",ErrMsg)
	exit sub
end if

TopicID=Clng(TopicID)
sql="Select title,hits,linkid,locked from topic where postid="&TopicID
Set rs=conn.execute(sql)
if rs.eof and rs.bof Then
	ErrMsg=ErrMsg+"<br><li>您要查看的主题不存在或已被删除！"
	Call Error("Exclamation",ErrMsg)
	Exit Sub
End if

topic=rs(0)
hits=rs(1)
linkid=rs(2)
locked=rs(3)

Set rs=Nothing

Call topictop()
Call showreplys()

if membername<>"" Then

	if not locked then
		Response.Write "<form action=NewReply.asp method=POST onsubmit=submitonce(this) name=frmgbk>"&_
	"<input type=hidden name=Action value=Reply>"&_
	"<input type=hidden name=TopicID value="&topicID&">"&_
		"<table width=""100%"" cellspacing=1 cellpadding=2 Class=TableBorder><tr>"&_
		"<th height=23>≡≡ 快速回复主题 ≡≡"&_
		"<tr Class=LightTableBody><td>"&_
		"<table border=0 width=""100%""><tr><td width=""27%""><br><li>HTML标签：<font color=brown>OFF</font><BR><li>UBB标签："
		if BoolVar(4)=True Then 
			Response.Write "<font color=#003399>ON" 
		Else 
			Response.Write "<font color=brown>OFF"
		End if
	Response.Write "</font><BR><li>最大长度：<font color=brown>"&IntVar(1)&"KB</font></td><td><textarea onkeydown=ctlent() name=content rows=8 cols=68 title=Ctrl+Enter直接提交回复帖子></textarea></td></tr></table></td></tr>"&_
		"<tr Class=DarkTableBody><td align=center><input type=Submit value="" 发 表 "" name=Sbmt class=button>&nbsp;&nbsp;&nbsp;&nbsp;<input type=reset name=reset value="" 清 除 "" class=button></td></tr></table></form>"
	end if
	if sysadmin Then	
	Response.Write "<BR><table width=""100%"" cellpadding=0 celspacing=0 border=0>"&_
		"<tr><td align=right valign=top><b>主题管理选项</b>：<a href=ManagePost.asp?Action=Lock&TopicID="&TopicID&">锁定/解锁</a>"&_
		"&nbsp;|&nbsp;<a href=ManagePost.asp?Action=Top&TopicID="&TopicID&">固顶/解固</a>"&_
		"&nbsp;|&nbsp;<a href=ManagePost.asp?Action=DeleteTopic&TopicID="&TopicID&" onclick=""javascript:return confirm('确定要删除这个主题及其所有回复吗?')"">删除主题</a></td></tr></table>"

	end if
End if

conn.execute("update topic Set hits=hits+1 where postid="&TopicID)

end sub


Sub topicTop()

	Dim nrs

	Set nrs=conn.execute("Select min(postid) from topic where postid>"&TopicID)
	if not (nrs.eof and nrs.bof) Then
	pretopic=nrs(0)
	End if
	Set nrs=conn.execute("Select max(postid) from topic where postid<"&TopicID)
	if not (nrs.eof and nrs.bof) Then
	nxttopic=nrs(0)
	End if

	Response.Write "<BR><BR><table cellpadding=0 cellspacing=0 border=0 width=""100%"" align=center>"&_
				"<tr><td align=left width=""30%"" valign=middle><a href=NewTopic.asp>"&_ 
				"<img src=images/newthread.gif alt=发表一个新主题 border=0></a>&nbsp; <a href=NewReply.asp?TopicID="&TopicID&">"&_ 
				"<img src=images/newreply.gif alt=回复主题 border=0></a></td>"&_
				"<td align=right width=""70%"" valign=middle>您是本帖的第 <B>"&hits&"</B> 个阅读者"

	if pretopic<>"" Then 
	Response.Write "<a href=""ViewThread.asp?TopicID="&pretopic&"""><img src=images/pretopic.gif border=0 alt=浏览上一篇主题 width=52 height=12></a>"
	End if
	if nxttopic<>"" Then 
	Response.Write "&nbsp;<a href=""ViewThread.asp?TopicID="&nxttopic&""">"&_
					"<img src=images/nxttopic.gif border=0 alt=浏览下一篇主题 width=52 height=12></a>"
	End if
	Response.Write "</font></td></tr></table>"&_
					"<table cellpadding=0 cellspacing=0 border=0 width=100% Class=TableBorder align=center><tr><td height=1> </td></tr></table>"

	Response.Write "<table cellpadding=0 cellspacing=0 border=0 width=100% align=center><tr> "&_
				"<td Class=TableBorder valign=middle width=1 height=24> </td>"&_
				"<td align=left valign=middle width=*>"&_ 
				"<table cellpadding=0 cellspacing=0 border=0 width=""100%"" height=""100%"">"&_
				"<tr><th align=left valign=middle width=""65%"">"&_
				"&nbsp;<b>* 贴子主题</B>："&htmlencode(cutstr(topic,30))				
	Response.Write "</font> </th><th width=""35%"" align=right>"
	Response.Write "<a href=# onclick=""javascript:WebBrowser.ExecWB(4,1)"">"&_
		"<img src=images/saveas.gif border=0 width=16 height=16 alt=保存该页为文件 align=absmiddle></a>&nbsp;"&_
		"<object id=""WebBrowser"" width=0 height=0 classid=""CLSID:8856F961-340A-11D0-A96B-00C04FD705A2""></object>"
	Response.Write 	"<a href=# onclick=""javascript:document.all.WebBrowser.ExecWB(6,1)""><img src=images/print.gif alt=打印此页 border=0></a>&nbsp;"
	Response.Write 	"&nbsp;</th></tr>"&_
				"</table></td><td Class=TableBorder valign=middle width=1 height=24> </td>"&_
				"</tr></table>"

End Sub



Sub showreplys()
%>

<!--#INCLUDE FILE="script/popup.inc" -->
<SCRIPT LANGUAGE="JavaScript">
<!--
function copyText(obj) {var rng = document.body.createTextRange();rng.moveToElementText(obj);rng.select();rng.execCommand('Copy');}

//-->
</SCRIPT>

<table cellpadding=0 cellspacing=1 border=0 width="100%" align=center Class=TableBorder>
<%

Set rs = Server.CreateObject("ADODB.Recordset")


sql="Select B.*,S.sex,S.regdate,S.point,S.maxim,S.imageid,S.birthday,"&_
	"S.email,S.oicq,S.homepage,S.locked from Reply B inner join student S on "&_
	"B.userid=S.userid where B.topicid="&TopicID&" order by B.postid"

rs.open sql,conn,1,1
if rs.eof and rs.bof then exit sub
totalrecords=rs.recordcount
rs.pagesize=PageSize
totalpages=rs.pagecount

currentPage=Request("page")
if currentpage="" or not isnumeric(currentpage) Then
	currentpage=1
ElseIf Cint(currentpage)>totalpages Then
	currentpage=totalpages
End if

currentpage=Cint(currentpage)
rs.absolutepage=CurrentPage




for i=1 to PageSize
name=rs("userid")

if BoolVar(9)=false and rs("locked")>1 then
	namestyle="color:white;filter:glow(color=#FF33ff,strength=2)"
elseif rs("sex")=True Then
	namestyle="color:white;filter:glow(color=#FF3333,strength=2)"
else
	namestyle="color:white;filter:glow(color=#3333ff,strength=2)"
End if



if (i mod 2)=0 Then 
	bgcolor=LightTBColor
	abgcolor=DarkTBColor
Else
	bgcolor=DarkTBColor
	abgcolor=LightTBColor
End if

Response.Write "<a name=""PID"&rs("postid")&"""></a>"&_
	"<table cellpadding=0 cellspacing=1 border=0 width=""100%"" align=center Class=TableBorder>"&_
	"<tr bgcolor="&bgColor&">"
	'<!--left start-->
response.write "<td width=27% valign=top background=images/LeftBG.gif>"&_
	"<table cellspacing=8 border=0 align=center width=""90%""  style=""word-break:break-all"">"&_
	"<tr><td>"&_
	"<table cellspacing=0 cellpadding=0 width=100% border=0>"&_
		"<tr><td><table style="&namestyle&" border=0 height=30 valign=middle cellspacing=0 cellpadding=0><tr><td><B>"&htmlencode(name)&"</B></td></tr></table></td>"&_
		"<td align=right>"

if rs("sex")=True Then 
	Response.Write "<img src=images/fem.gif width=20 hspace=2 alt=哇,美女耶!>"
Else
	Response.Write "<img src=images/mal.gif width=20 hspace=2 alt=哦,帅哥哟!>"
End if
response.write constellation(rs("birthday"),false)&"</td></tr>"&_
	"</table>"

if rs("imageid")<>0 Then
	Response.Write "<a href=""Profile.asp?Action=showdetail&Name="&name&""" target=_blank  title=""查看"&name&"的个人信息""><img src=""face/image"&rs("imageid")&".gif"" border=0></a>"
Else
	Response.Write "<br><br>"
End if

Response.Write "<BR><br>积分："&rs("point")&"<br>注册："&rs("regdate")
if BoolVar(5)=True Then Response.Write "<br>鉴定："&ipsource(rs("ip"))

response.write "</td></tr></table>"&_
	"</td>"
'<!--left end-->
'<!--right start-->
response.write "<td height=""100%"">"&_
	"<table width=100% height=100% border=0 cellspacing=1 cellpadding=0 align=center>"&_
	"<tr><td valign=top>"
	'<!--top start-->
response.write "<table width=100% cellspacing=1 cellpadding=0 border=0>"&_
	"<tr><td align=right valign=top nowrap>"&_
	"<a href=""UserSMS.asp?Action=new&touser="&name&""" target=_blank title=""给"&name&"发短消息"">"&_
	"<img border=0 src=""images/message.gif"" align=absmiddle hspace=2>短信</a>&nbsp;&nbsp;"&_
	"<a href=""Friendlist.asp?Action=addF&myFriend="&name&""" target=_blank title=""把"&name&"加入好友列表"">"&_
	"<img border=0 src=""images/friend.gif"" align=absmiddle hspace=2>好友</a>&nbsp;&nbsp;"&_
	"<a href=""Profile.asp?Action=showdetail&Name="&name&""" target=_blank  title=""查看"&name&"的个人信息"">"&_
	"<img border=0 src=""images/profile1.gif"" align=absmiddle hspace=1>信息</a>&nbsp;&nbsp;"
if rs("email")<>"" Then
	response.write "<a href=""mailto:"&rs("email")&""" title=""给"&name&"发电子邮件"">"&_
	"<img src=""images/email.gif"" border=0  hspace=2>邮件</a>&nbsp;&nbsp;"
End if
if rs("oicq")<>"" Then
	response.write "<a href=""http://search.tencent.com/cgi-bin/friend/user_show_info?ln="&rs("oicq")&""" title=""查看"&name&"的QQ["&rs("oicq")&"]资料""><img src=""images/oicq.gif"" border=0 width=15 height=15 hspace=2>QQ</a>&nbsp;&nbsp;"
End if
if rs("homepage")<>"" Then
	response.write "<a href="""&rs("homepage")&""" title=""访问"&name&"的主页"">"&_
	"<img src=""images/homepage.gif"" border=0 align=absmiddle>主页</a>&nbsp;&nbsp;"
End if
response.write "</td></tr></table>"&_
"<hr width=98% size=1 color=#777777>"&_
"</td></tr>"
'<!--top end-->
'<!--body start-->
response.write "<tr><td width=100% height=""100%"">"&_
	"<table height=100% width=95% border=0 style=""word-break:break-all"" align=center>"&_
	"<tr><td valign=top>"
if rs("mood")<>0 Then
	Response.Write "<img src=""mood/face"&rs("mood")&".gif"" border=0 alt=发贴心情>&nbsp;"
end if
Response.Write ""&htmlencode(rs("title"))&"<br>"
if BoolVar(4)=True Then 
	Response.Write "<span id=yu"&rs("postid")&">"&ubbcode(rs("body"))&"</span>"
Else 
	Response.Write "<span id=yu"&rs("postid")&">"&htmlencode(rs("body"))&"</span>"
End if
response.write "</td></tr></table>"&_
	"</td></tr>"
'<!--body end-->
'<!--maxim start-->
response.write "<tr><td height=100% valign=bottom>"
if membername<>"" and rs("maxim")<>"" then
	Response.Write "<table align=center valign=bottom border=0 cellspacing=8 cellpadding=0  width=""95%"">"&_
	"<tr><td align=right vlign=bottom><p>--------------------------------<br>"& UBBCode(rs("maxim"))&"</td></tr></table>"
End if
response.write "</td></tr>"
'<!--maxim end-->
response.write "</table>"
'<!--right end-->
response.write "</td></tr>"&_
	"<tr bgcolor="&bgcolor&" height=30>"
'<!--bottom start-->
Response.Write "<td background=images/LeftBG.gif>&nbsp;"&OnlineStatus(name)
if membername<>"" then
	if cdate(Request.cookies("fytxl")("logintime"))<rs("posttime") Then
		Response.Write "<img src=images/postnew.gif hspace=2 alt=新贴>"
	Else
		Response.Write "<img src=images/postold.gif hspace=2 alt=旧贴>"
	End if
end if
response.write rs("posttime")&"</td>"&_
	"<td><table width=""100%"">"&_
	"<tr><td><img src=""images/ip.gif"" hspace=2 alt=发贴IP>"
if sysadmin Then
	Response.Write rs("ip")
Else
	Response.Write getip(rs("ip"))
End if
response.write "</td><td align=right>&nbsp;"

if name=membername or sysadmin Then
	Response.Write "<a href=ManagePost.asp?Action=Edit&TopicID="&TopicID&"&PostID="&_
	rs("postid")&"&Page="&CurrentPage&"><img src=images/edit1.gif border=0>编辑</a>&nbsp;&nbsp;"
	if linkid<>rs("postid") then
		response.write "<a onclick=""javascript:return confirm('您确认要删除这个回复帖子吗?')"" href=""ManagePost.asp?Action=DeleteReply&TopicID="&TopicID&"&PostID="&rs("postid")&"&Page="&CurrentPage&""">"&_
		"<img src=""images/recycle1.gif"" border=0>删除</a>&nbsp;&nbsp;"
	end if
End if
response.write "<a href=""javascript:copyText(document.all.yu"&rs("postid")&")"">"&_
	"<img border=0 src=""images/copy.gif"" align=absmiddle hspace=1>复制</a>&nbsp;&nbsp;"&_
	"<a href=""NewReply.asp?TopicID="&TopicID&"&QuotePost="&rs("PostID")&""" title=""引用"&name&"的留言"">"&_
	"<img border=0 src=""images/replynow.gif"" align=absmiddle hspace=1>引用</a>&nbsp;&nbsp;"&_
	"</td></table>"&_
	"</td></tr></table>"
'<!--bottom end-->
response.flush

rs.movenext
if currentpage=totalpages then
	if rs.eof then exit for
end if

next


'start page(s) link
Dim p,ii

Response.Write "<table border=0 cellpadding=0 cellspacing=3 width=100% align=center >"&_
	"<tr><td valign=middle nowrap><a href=#top><img src=images/gotop.gif border=0>顶端</a>"
	
if totalpages<>1 then
	response.write "&nbsp;&nbsp;页次：<strong>"& currentPage &"</strong>/<strong>"& totalpages &"</strong></td>"&_
	"<td valign=middle align=right nowrap><p>分页："

if currentpage=4 then
	response.write "<a href=""?TopicID="&TopicID&"&Page=1""><b>1</b></a> "
elseif currentpage>3 then
	response.write "<a href=""?TopicID="&TopicID&"&Page=1""><B>1</B></a> …"
end if
if totalpages>currentpage+2 then
	endpage=currentpage+2
else
	endpage=totalpages
end if
for i=currentpage-2 to endpage
	if not i<1 then
		if i = currentpage then
        response.write " <font color=brown><B>"&i&"</B></font>"
		else
        response.write " <a href=""?TopicID="&TopicID&"&Page="&i&"""><B>"&i&"</B></a>"
		end if
	end if
next
if currentpage+3 = totalpages then
	response.write " <a href=""?TopicID="&TopicID&"&Page="&totalpages&"""><B>"&totalpages&"</B></a>"
elseif currentpage+2 < totalpages then 
	response.write " … <a href=""?TopicID="&TopicID&"&Page="&totalpages&"""><B>"&totalpages&"</B></a>"
end if

else

response.write "</td><td align=right>本主题仅一页"


end if

response.write "</td></tr></table>"

'end page(s) link



End Sub



Function OnlineStatus(UserName)
	Dim ors
	Set ors=Conn.Execute("Select userid from online where userid='"&username&"'")
	if ors.eof and ors.bof Then
		OnlineStatus="<img src=images/isoff.gif alt=离线! height=17 hspace=4>"
	Else
		OnlineStatus="<img src=images/ison.gif alt=在线！快来找我吧! height=17 hspace=4>"
	End if
	ors.close
	Set ors=Nothing
End Function


%>
<!--#INCLUDE FILE="include/constellation.asp" -->
<!--#INCLUDE FILE="include/checkupip.asp" -->
<%Call footer()%>