<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="inc/conndb.asa"-->
<!--#include file="inc/function.asp"-->
<%
id=Request.QueryString("id")
	If Request("CurPage") = "" or Request("CurPage") = 0 then
		CurPage = 1
			Else
		CurPage = CINT(Request("CurPage"))
	End If
Set rs1 = Server.CreateObject("ADODB.Recordset") 

'管理员和超级管理员可以访问被禁止的帖子 Edit For V1.5
rs1.Open "Select * From "&bbstable&" where id="&id, conn,3,3 
'访问次数.根据session的值判断是否需要累加
if session("refresh_"&id)="" then session("refresh")="0"
if cLng(session("refresh_"&id)) <> cLng(id) then 
	rs1("hits")=rs1("hits")+1 
	rs1.update 
	session("refresh_"&id)=id''--将session更新为当前的id号
end if
nowhits=rs1("hits") 
title=rs1("title")
recount=rs1("recount")
istop=rs1("istop")
isgood=rs1("isgood")
username0=rs1("username")
addtime=rs1("addtime")
image=rs1("picurl")
content=rs1("content")
boardid=CInt(rs1("boardid"))

IsFee = CInt(rs1("IsFee")) 'Add For V1.5
IsRe = CInt(rs1("IsRe")) 'Add For V1.5
IsCheck =Cint(rs1("IsCheck")) 'Add For V1.5
rs1.close
set rs1=Nothing

'广告信息
gap_arr = Split(bbs_about_gaps,"|@|")
if ubound(gap_arr)>=2 then
	bbs_about_gaps1 = gap_arr(0)
	bbs_about_gaps2 = gap_arr(1)
	bbs_about_gaps3 = gap_arr(2)
end if

'吧的相关信息
If boardid<>"" And boardid<>0 Then
		isboardid="boardid="&boardid
		'从缓存中读出吧的相关信息
		if ubound(Arr_Category,1)=0 then Response.Write("没有该贴吧")
		Category_Len=ubound(Arr_Category,2)
		For kkkj=0 To Category_Len
				'开始循环
				If boardid=Arr_Category(1,kkkj) Then
					boardname=Arr_Category(0,kkkj)
					boardadmin0=Arr_Category(3,kkkj)
				Exit For
				End If
		Next
		If boardadmin0<>"" Then 
			boardadmin=" 版主:"&"<select name='boardadmin' class='selBoardManager'><option value=''>"& vbCrlf & Replace(boardadmin0,"|","</option><option value=''>")&"</option></select>"
		Else
			boardadmin=" 版主:<select name='boardadmin' class='selBoardManager'><option value=''>暂无版主</option></select>"
		End if
		'Edit At 2007-11-13 CHANG,ZIDONE
		If Dreamsun_name<>"" And boardadmin0<>"" And CInt(isadmin)<>9 Then 
			tdim0=split(boardadmin0,"|")
			for ti0=0 to ubound(tdim0)
				If Dreamsun_name=tdim0(ti0) Then isadmin=1 '斑竹是1，高官是9
			next
		End If
End If

'判断是否放开的帖子
'Add For V1.5
'如果帖子没有被审核
if IsCheck = 0 then
	' 如果未登录，禁止查看
	if Dreamsun_name ="" Then '禁止浏览
		Response.Write(BackMsg("该帖尚未通过审核",""))
	else'如果不是管理员或者斑竹
		if isadmin<1 Then '禁止浏览
			Response.Write(BackMsg("该帖尚未通过审核",""))
		end if
	end if
elseif IsCheck <0 then
	if isadmin<>9 then 
		'只有最高管理员可以查看回收站中的帖子
		Response.Write(BackMsg("您所访问的帖子不存在,或者已经被删除",""))
	end if
End if

' 判断是否需要扣除浏览者的积分 
'Add For V1.5 CHANG,ZIDONE
Dim content1,needTransToUbb
needTransToUbb = true
content1 = content
if IsFee > 0 Then
	' 如果浏览者不是作者本人
	if username0<>Dreamsun_name then
		' 如果是游客，则跳转到登录界面
		if Dreamsun_name = "" then
			Response.Write(BackMsg("查看该帖子需要积分,请先登录",""))
		End if
		
		'看帖扣积分 Add For V1.5'''''''''''''''''''''''''
		If OptTable("select [accID] from [account] where [accFromUser]='"&Dreamsun_name&"' and [accRemark]='"&id&"'") = "" Then 
			'如果该人没有看过帖子，则不能显示
			if Request.QueryString("lookup")="" then 
				'如果没有点击查看链接，显示需付费查看字样
				content1 = "<center><p>&nbsp<br>阅读该帖需要花费您"&IsFee&"积分，若要继续，请点击<a href='show.asp?id="&id&"&CurPage="&CurPage&"&lookup=yes'>确定</a><p>&nbsp</center>"
				needTransToUbb = false
			else 
				'如果有点击查看链接，则进行扣分，然后显示
				' 取得浏览者的总积分
				myAccount = OptTable("select [umoney] from "&usertable&" where [username]='"&Dreamsun_name&"'")
				
				' 如果积分合法
				If IsNumeric(myAccount) Then
					' 如果有足够的积分查看该帖
					If CInt(myAccount)>= IsFee Then
						OptTable("insert into [account] " & _
						"(accID,accValue,accFromUser,accToUser,accTime,accReason,accRemark)"& _
						" values("&CStr(GetMaxID("account","accid"))&","&IsFee&",'"&Dreamsun_name& _
						"','"&username0&"','"&CStr(Now())&"','读帖','"&id&"')")
						'给看帖者扣分
						OptTable("update ["&usertable&"] set [umoney]=[umoney]-"&IsFee&" where [username]='"&Dreamsun_name&"'")
						 '给发帖者相应积分
						OptTable("update ["&usertable&"] set [umoney]=[umoney]+"&IsFee&" where [username]='"&username0&"'")
						Response.Write(BackMsg("操作成功","show.asp?id="&id))
					Else
						Response.Write(BackMsg("查看该帖需要"&IsFee&"积分,您的积分不足",""))
					End If
				Else
					Response.Write(BackMsg("取得用户积分失败",""))
				End If
			end if
		Else
			'如果已经扣过分了，直接显示帖子内容
			content1 = content
		End if
	End if
Else
	content1 = content
End If
' 格式化帖子的用户名
If ubound(split(username0,"."))<3 And instr(username0,".*")=0 And _
((Dreamsun_Name<>"" And isuserinfo=0) Or isuserinfo=1) Then
	username="<a href=user.asp?Action=infoshow&username="&username0&">"& _
	DropFuckWords(LCase(username0))&"</a>"
Else
	username=DropFuckWords(LCase(username0))
	'Update For V1.5
	if isShowIpName>0  And instr(username0,".*")>0then
		p_ip = Replace(DropFuckWords(LCase(username0)),"*","1")
		username= "<span id='p_ip'  onmouseover=""showShortIpData('user.asp?Action=ipname&ip="&p_ip& _
					"','p_ip');""  onmouseout=""SetValue('p_ip','"&username&"');"">"&username&"</span>"
	end if
End If 

'--Add by zidone 2006/12/30
boardadmin = Replace(boardadmin,"|"," ")
ggg=title&"-"&boardname&"-ID="&id
navdh=" <a href=index.asp?boardid="&boardid&">"&boardname&"</a> &gt;&gt; 浏览主题"
webtitle=title&"-"&bbsname
navright=boardadmin '&"  吧主:"&sysManager
Call showpage()
Sub pagecontent()
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="38%"><a href="#new"><img src="images/fen/nav_post.gif" width="72" height="24" border="0"></a> <a href="index.asp?act=jinghua&<%=isboardid%>"><img src="images/fen/nav_good.gif" width="52" height="24"border="0"></a> <a href="help.asp"><img src="images/fen/nav_help.gif" width="72" height="24" border="0"></a></td>
    <td width="62%"><% Call boardlist()%></td>
  </tr>
</table>
		<table width="900" height="4" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#EC4D00" style="border-bottom-style: none; border-left-style:none; border-right-style:none">
          <tr>
            <td height="6" bgcolor="#FFFFFF" style="border-style:none"></td>
          </tr>
</table>
<table width="900" height="30" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#EC4D00" style="border-style:dashed">
          <tr>
            <td width="900" bgcolor='#fffbfc' style="border-style:none"><div id="content-left">
<!-- 主体模板左侧区域 start-->
<% 
	'判断系统是否关闭
	if Left(sys_close,1)="1" then
	showList = "<center>&nbsp;<p>&nbsp;<p>&nbsp;很抱歉,本帖吧因为下列原因暂时关闭:<br> -  " & _ 
				Right(sys_close,(len(sys_close)-1))&_
				"<p>&nbsp;<p>&nbsp;</center>"
%>
<%=ShowList%>
</div>
<%else%>

<% if CurPage<=1 then  %>
<div class="tiebamain">
	<div class="tiebamain-title">
		<div style="WIDTH: 60%;FLOAT: left; font-family:黑体; font-size:18px;line-height:180%;height:40px"><%=DropFuckWords(title)%> 
        <%if CInt(IsFee)>0 then%>
            <span style="cursor:help;" title="看到正文意味着您已经被扣除积分，不会再重复扣分"><strong>(积分帖: 读帖需减去<font color=red><%=isFee%></font>分)</strong></span>
        <%End if%>
        </div>
		<div style="WIDTH: 30%;	FLOAT: right;text-align:right;">已阅：<%=nowhits%> / 回复：<%=recount%>（楼主）</div>
	</div>
	<hr size="0" />
	<div class="tiebamain-content cont">
	<%
	if needTransToUbb = true then
		Response.Write(DropFuckWords(ubbs(content1)))
	else
		Response.Write(DropFuckWords(content1))
	end if
	%>
    </div>
		<%
		If ubound(split(username0,"."))<3 And instr(username0,".*")=0 Then Call sigline(username0)%>
	<div class="tiebamain-info list">
        <div style="WIDTH: 30%;FLOAT: left;">作者：<%=username%> （<%=addtime%>） 
        </div>
        <div style="WIDTH: 20%;FLOAT: left;height:20px;overflow:hidden;"><%=bbs_about_gaps1%></div>
		<div style="WIDTH: 48%;	FLOAT: right;text-align:right;"><%
		If isadmin=0 And Dreamsun_name=username0 Then 
		response.write "<a href='edit.asp?tn=bbs&id="&id&"'>编辑</a>"
		End If 
		if isadmin<>0 Then
		response.write ("操作：")
		
		'审核 Add Form V1.5
		if IsCheck=0 then
			Response.Write("<a href='tzsave.asp?cz=ischeck&id="&id&"'><font color=red>审核</font></a>")
		elseif IsCheck = 1 then
			Response.Write("<a href='tzsave.asp?cz=ischeck&id="&id&"'>屏蔽</a>")
		end if
		response.write (" | ")
		response.write "<a href='edit.asp?tn=bbs&id="&id&"'>编辑</a>"
		response.write (" | ")
		if istop=0 then
		response.write "<a href='tzsave.asp?cz=istop&id="&id&"'>设置顶</a>"
		ElseIf istop=1 Then 
		response.write "<a href='tzsave.asp?cz=istop&id="&id&"'>取置顶</a>"
		end If
		response.write (" | ")
		if isgood=0 then
		response.write "<a href='tzsave.asp?cz=isgood&id="&id&"'>设精华</a>"
		else
		response.write "<a href='tzsave.asp?cz=isgood&id="&id&"'>取精华</a>"
		end If
		response.write (" | ")
		response.write "<a href='tzsave.asp?cz=del&id="&id&"'>删除</a>"
		end if %>&nbsp; <a href="#re" onClick="ResetReplyTitle('楼主','<%=TitleLeft(title,20)%>');">回复此贴</a></div>
	</div>
</div>
<%
end if
Set rs = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM "&rebbstable&" where IsCheck>=0 and re="&id&" ORDER BY addtime ASC" 
rs.open sql,conn,1,1
If rs.eof and rs.bof Then
else
RS.PageSize=bbsnum'设置每页记录数           
Dim TotalPages              
TotalPages = RS.PageCount              
	If CurPage>RS.Pagecount Then               
	CurPage=RS.Pagecount              
	end if              
RS.AbsolutePage=CurPage
rs.CacheSize = RS.PageSize'设置最大记录数  
Dim Totalcount              
Totalcount =INT(RS.recordcount)              
StartPageNum=1              
do while StartPageNum+10<=CurPage              
	StartPageNum=StartPageNum+10              
	Loop              
EndPageNum=StartPageNum+9              
If EndPageNum>RS.Pagecount then EndPageNum=RS.Pagecount
I=0
p=RS.PageSize*(Curpage-1)
p=p+1
do while (Not RS.Eof) and (I<RS.PageSize)              
reid=rs("id")
retitle=rs("title")
reusername0=rs("username")
recontent=rs("content")
readdtime=rs("addtime")
reimg=rs("picurl")
relou=rs("lou")
If ubound(split(reusername0,"."))<3 And instr(reusername0,".*")=0 And ((Dreamsun_Name<>"" And isuserinfo=0) Or isuserinfo=1) Then
reusername="<a href=user.asp?Action=infoshow&username="&reusername0&">"&DropFuckWords(LCase(reusername0))&"</a>"
Else
reusername=DropFuckWords(LCase(reusername0))
	'Add For V1.5 IP Show
	if isShowIpName>0 And instr(reusername0,".*")>0 then
		r_ip = Replace(DropFuckWords(LCase(reusername0)),"*","1")
		reusername="<span  id='r_ip"&relou&"'  onmouseover=""showShortIpData('user.asp?Action=ipname&ip="&r_ip& _
						"','r_ip"&relou&"');""  onmouseout=""SetValue('r_ip"&relou&"','"&reusername&"');"">"&reusername&"</span>"
	end if
End If 
Dim oddEvenGap
if(i+1) mod 2 = 0 then
	oddEvenGap = bbs_about_gaps3
else
	oddEvenGap = bbs_about_gaps2
end if
%>
<div class="tiebamain">
	<div class="tiebamain-title">
		<div style="WIDTH: 60%;FLOAT: left;"><%=DropFuckWords(retitle)%></div>
		<div style="WIDTH: 30%;	FLOAT: right;text-align:right;">第 <%=relou%> 楼</div>
	</div>
	<div class="tiebamain-content cont"><%=DropFuckWords(UBBs(recontent))%></div>
	<%If ubound(split(reusername0,"."))<3 And instr(reusername0,".*")=0 Then Call sigline(reusername0)%>
	<div class="tiebamain-info list">
		<div style="WIDTH: 30%;FLOAT: left;"><span class=tiebamain-span>作者：<%=reusername%> （<%=readdtime%>）</span></div>
        <div style="WIDTH: 38%;FLOAT: left;height:20px;overflow:hidden;"><%=oddEvenGap%></div>
		<div style="WIDTH: 30%;	FLOAT: right;text-align:right;"><span id=tiebamain-span><%
			If isadmin=0 And Dreamsun_name=reusername0 Then 
			response.write "<a href='edit.asp?tn=rebbs&id="&reid&"'>编辑</a>"
			End If 
			if isadmin<>0 Then
			response.write "<a href='edit.asp?tn=rebbs&id="&reid&"'>编辑</a>"
			response.write (" | ")
			response.write "<a href='tzsave.asp?cz=redel&id="&reid&"'>删除</a>  |  "
			end if %><a href="#re" onClick="ResetReplyTitle('<%=relou%>','<%=TitleLeft(Retitle,40)%>');">回复此贴</a></span></div>
	</div>
</div>
	  <%
		I=I+1              
		RS.MoveNext              
		Loop
		' 吉林信息网 专用页码简化版,取得显示页码
		pagelist=viewpage(Totalcount,bbsnum,5,CurPage,"id="&id,"当前总数:","show.asp")
		 '总记录,显示记录数,显示页数,当前页,传替参数,总数说明,当前页面名称
		end if
		rs.close
		set rs=nothing
		%>
		<DIV class=tiebalist><%=pagelist%></DIV>
        <!-- 主体模板左侧区域 end --></td></tr></table>



		<table width="900" height="4" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#EC4D00" style="border-bottom-style: none; border-left-style:none; border-right-style:none">
          <tr>
            <td height="6" bgcolor="#FFFFFF" style="border-style:none"></td>
          </tr>
</table>
<script language=javascript src=inc/ubb.js></script>
<table width="900" height="30" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#EC4D00" style="border-style:dashed">
          <tr>
            <td width="900" bgcolor='#fffbfc' style="border-style:none">

    <BR>
    <%
	' 在帖子开放的条件下，用户/斑竹登录后可回帖；游客在“允许游客回帖”时可回帖
	' 不管帖子开放或者关闭，超级管理员都可以回帖
	' Edit For V1.5
	If (CInt(IsRe)=1 and ((Dreamsun_name="" And guestrev=1) Or Dreamsun_name<>"" )) or (IsAdmin)=9 Then 
	%>
    <form name="save" method="post" action="tzsave.asp?cz=addsave" onSubmit="return regcheck(this);" class=postform>
    <input name="ycid" type="hidden" id="ycid" value="<%=id%>">
    <DIV class="bo"><LABEL for=title><strong>标 题：</strong></LABEL><input name="title" type="text" id="title" size="50"  maxlength="50" value="<%response.write "回复:"&TitleLeft(title,40)%>">
    <%
        If CInt(IsRe)=0 Then Response.Write("该主题已被关闭")
    %> <A HREF="tietu.htm" target=_blank>转贴圣手</A>
</DIV>

<DIV class="bo" style="padding-left: 80px;">
	<!--#include file="inc/ubb.asp" -->
</DIV>

<div id="clear"></div>

<DIV class="bo">
    <strong><a name="re"></a>回 复：</strong>
    <textarea name="content" cols="60" rows="5" id="contents" title='Ctrl+Enter快速提交' onSelect="javascript: storeCaret(this);" onClick="javascript: storeCaret(this);" onKeyUp="javascript: storeCaret(this);"></textarea>
</DIV>

<DIV class="bo">
    <strong>作 者：</strong>
    <%
        if Dreamsun_name= "" then
        response.write"您目前是匿名发表 <A href='user.asp'>登录</A> | <A href='user.asp?Action=reg'>注册</A>"
        else
        response.write Dreamsun_name&" | <A href='user.asp?Action=exit'>退出</A>"
        end if
    %> 
</DIV>

<%if Dreamsun_name="" then%>
<DIV class="bo">
    <strong>验证码：</strong>
    <input name="zd_code" type="text" id="zd_code" size="4" maxlength="4" onKeyPress="if ((event.keyCode<48 || event.keyCode>57)) event.returnValue=false"> 
    <img src="inc/GetCode.asp?a=back" alt= "验证码,看不清楚?请点击刷新验证码" style="cursor : pointer;" onClick="this.src='inc/GetCode.asp?a=back'">
</DIV>
<%end if%>

<DIV class="bo">
    <input type="submit" name="Submit" value="发表帖子"> 
    <input type="reset" name="Submit" value="重新填写"> 
    [Ctrl] + [Enter]直接提交帖子
</DIV>
</form> 
<%
Elseif CInt(IsRe)=0 Then
	'如果不是超级管理员，且帖子已经被关闭，则禁止回帖
	'Edit For V1.5
	response.write "<p><CENTER>该主题已经被关闭.</CENTER><p>"
Else 
	'
	response.write "<p><CENTER>目前不允许游客回复,请 <A href='user.asp'>登录</A> <A href='user.asp?Action=reg'>注册</A> 发贴.</CENTER><p>"
End If 
%>

<script language="JavaScript"> 
<!-- 
document.onkeydown=function up(){ 
if(event.ctrlKey&&event.keyCode==13) 
document.save.submit(); 
} 
//--> 
function delete_confirm(e) {
 if (event.srcElement.outerText=="删除")
  event.returnValue=confirm("您确认执行该操作么？不可恢复!");
 }
 document.onclick=delete_confirm;

function regcheck(formct){
	if (formct.title.value=='' ){
		alert('标题不能为空,请填写');
		return false; 
	}
		if (formct.content.value=='' ){
		alert('内容不能为空,请填写');
		return false; 
	}
<%if Dreamsun_name="" then%>
		if (formct.zd_code.value=='' ){
		alert('验证码不能为空,请填写');
		return false; 
	}
<% end if%>
	formct.Submit.disabled=true;
}
function ResetReplyTitle(no, title) {
        if(no == null||no == ""){
          if(title == null || title == '')
            title_src = '<%=TitleLeft(title,40)%>';
          else
            title_src = title;
        }
        else{
          title_src = title;
          var s = title_src.indexOf("：");
          title_src = title_src.substring(s+1,title.length);
        }
        document.forms('save').title.value='回复 ' + no + '：' + title_src;
        return true;
}
</script> 

<%end if%></td></tr></table>
<table width="900" height="4" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#EC4D00" style="border-bottom-style: none; border-left-style:none; border-right-style:none">
          <tr>
            <td height="6" bgcolor="#FFFFFF" style="border-style:none"></td>
          </tr>
</table>
<%
End Sub %>
<script language="vbscript" src="images/vbs2js.vbs"></script>
<script type="text/javascript"  language="javascript" src="images/ClientAjaxWithVBS.js"></script>
		
</body>
</html>


