www.gusucode.com > CC校友录贴吧 CCBar源码程序asp编程 > forum/forum_func.asp

    <%
'===================================================================
'= ASP FILENAME	: /forum/forum_func.asp
'= CREATED TIME : Mar,15,2004
'= LAST MODIFIED: Mar,15,2004
'= VERSION INFO : CCASP Framework Ver 2.0.1 ALL RIGHTS RESERVED BY www.cclinux.com
'= DESCRIPTION  : forum public functions and not by style
'= Change Log:
'===================================================================
%>
<%
'==  查看帖子内容数据校验设置
Dim arrForumContentDataChk(1)
arrForumContentDataChk(0) = Array("DT_ID"	,"TopicsId"	,"该帖子"	,0	,20)
arrForumContentDataChk(1) = Array("DT_ID"	,"ForumId"	,"该帖子所属栏目"	,0	,20)

'===================================================================
'= Function    : GetMaster(intForumId)
'= Time		   : Created At Jun,11,2004
'= Input       : 
'= Table	   : Qurey CLASS_FORUM,CLASS_USER
'= Description : get user master of forum
'===================================================================
Function GetMaster(intForumId)

	Dim strTmp,i

	strTmp =  Trim(GetConfig(Application(GBL_strCookieURL & "FORUM_MASTER"),"Forum" & intForumId))

	If strTmp <> "" Then
		strTmp = Split(strTmp,"|")
		For i = Lbound(strTmp) To Ubound(strTmp)
			If Trim(strTmp(i)) = GBL_strUserAccount Then
				GetMaster = True
				Exit Function
			End If
		Next
	End If

	GetMaster = False

End Function

'===================================================================
'= Function    : ForumMenu(intFlag,strClew)
'= Time		   : Created At Mar,15,2004
'= Input       : intFlag	: now page mode
'= Table	   : Qurey CLASS_FORUM,
'= Description : Show form now menu
'===================================================================
Function ForumMenu(intFlag,strClew)

	Dim strPutMenu
	Dim strHtmlCode
	Dim arrTmp,strTmp,ForumId

	strPutMenu = ""
	strHtmlCode = ""
	strTmp = ""

	ForumId = Trim(Request("ForumId"))
	If Len(ForumId) = 0 Or Not IsNumeric(ForumId) Then
		ForumId = 0
	End If

	GBL_objPubDB.Clear()
	GBL_objPubDB.AllSQL = "SELECT FORUM_NAME FROM CLASS_FORUM WHERE FORUM_ID=" & ForumId
	GBL_objPubDB.SQLRSExecute()
	Call ResultExecute(GBL_objPubDB.intErrNum,"mdy topics forbid","ES_ERR")
	If GBL_objPubDB.intRSNum > 0 Then
		Dim strForumTitle : strForumTitle = GBL_objPubDB.objPubRS("FORUM_NAME")
	End If

	'arrTmp = Trim(GetConfig(Application(GBL_strCookieURL & "FORUM_CATE"),"Forum" & ForumId))
	'If arrTmp <> ""  Then
	'	arrTmp = Split(arrTmp,"|")
	'	If Not IsArray(arrTmp) Then
	'		ForumMenu = ""
	'		Exit Function
	'	End If
	'Else
	'	ForumMenu = ""
	'	Exit Function
	'End If

	strPutMenu = "&nbsp;<img src='" & GBL_strHomeURL & "images/jt.gif' border=0 align=absmiddle>&nbsp;<a href='" & GBL_strHomeURL & "index.asp'>首页</a> &gt;&gt;<a href='" & GBL_strHomeURL & "forum/forum_cate.asp' > 交流贴吧</a> &gt;&gt; "
	strPutMenu = strPutMenu & "<a href='" & GBL_strHomeURL & "forum/forum_list.asp?ForumId=" & ForumId & "'>" & strForumTitle & "</a>"

	If Trim(strClew) <> "" Then
		strPutMenu = strPutMenu & " &gt;&gt; " & strClew
	End If
	
	Select Case intFlag
		Case 1	: 
			strPutMenu = strPutMenu & "<br>" & strHtmlCode
		Case 2	:
			strPutMenu = strPutMenu & ""
		Case 3	:
			strPutMenu= strPutMenu & " &gt;&gt; 修改帖子"
	End Select 

	ForumMenu = strPutMenu

End Function
'===================================================================
'= Sub         : CheckMasterForum(GetRSId)
'= Time		   : Created At Jan,29,2004
'= Table	   : Qurey CLASS_FORUM,
'= Description : 是否是版主才能访问的贴吧栏目
'===================================================================
Function CheckMasterForum(GetRSId)
	Dim strForumAccess,arrForumAccess,k
	If Trim(Request("VIEW_MODE")) = "ADMIN_ONLY"  And Session(GBL_strCookieURL & "SEN_strIsMaster") = "0" And Not AdminCheck() Then
		GetRSId = -1
	End If
	If GetRSId = -1 Then
		Call ResultExecute(E_USER_PUB,"您没有浏览该管理员和版主版面的权限","ES_ERR")
		Exit Function
	Else
		strForumAccess = Trim(Application(GBL_strCookieURL & "FORUM_ACCESS"))
		arrForumAccess = Split(strForumAccess,"|")
		For k = Lbound(arrForumAccess) To Ubound(arrForumAccess)
			intNowForumAccess = Cint(arrForumAccess(k))
			If Cint(GetRSId) = intNowForumAccess  And Session(GBL_strCookieURL & "SEN_strIsMaster") = "0" And Not AdminCheck() Then
				Call ResultExecute(E_USER_PUB,"您没有浏览该管理员和版主版面的权限","ES_ERR")
				Exit Function
			End If
		Next
	End If

End Function
'===================================================================
'= Sub         : FormAddReply()
'= Time		   : Created At Jan,31,2004
'= Input       : None
'= Description : Add new forum reply
'===================================================================
Sub FormAddReply()

	Dim clsForm			'== Class of form
	Dim strHtmlCode
	Dim strActFlag
	Dim intErrId
	Dim strAddInfo
	Dim strTitle		'== the topic title
	Dim GetRSId,GetRSId1
	Dim strContent,strFace

	strContent = ""
	strFace = "14.gif"
	strTitle = ""

	strActFlag = Trim(Request.QueryString("pstActFlag"))
	If strActFlag <> "" And strActFlag <> "FORUM_EDIT_MODE" Then
		Call ResultExecute(E_USER_PUB,"贴子编辑模式不正确","ES_ERR")
		Exit Sub
	End If

	Dim ForumId : ForumId = Trim(Request.QueryString("ForumId"))
	strAddInfo = "贴吧栏目"
	intErrId = DataCheck("DT_ID",ForumId,strAddInfo,"ES_ERR")
	Call ResultExecute(intErrId,strAddInfo,"ES_ERR")

	'== check title
	'strTitle = Trim(Request.QueryString("pstTitle"))
	Call CheckMasterForum(ForumId)

	'== edit mode 
	If strActFlag = "FORUM_EDIT_MODE" Then

		GetRSId1 = Trim(Request.QueryString("ReplyId"))
		strAddInfo = "该要编辑的帖子回复"
		intErrId = DataCheck("DT_ID",GetRSId1,strAddInfo,"")
		Call ResultExecute(intErrId,strAddInfo,"ES_ERR")

		GBL_objPubDB.Clear()
		GBL_objPubDB.TableName = "CLASS_REPLY"
		GBL_objPubDB.SQLType = "SELECT"
		If GBL_strUserAuthen = 1 Or GetMaster(ForumId) Then
			GBL_objPubDB.Where = "REPLY_ID=" & GetRSId1
		Else
			GBL_objPubDB.Where = "REPLY_ID=" & GetRSId1 & " AND REPLY_OWNER_ID=" & GBL_intUserId
		End If
		GBL_objPubDB.AddField "REPLY_CONTENT,REPLY_FACE,REPLY_TITLE",""
		GBL_objPubDB.SQLRSExecute()
		Call ResultExecute(GBL_objPubDB.intErrNum,"get edit reply content","ES_ERR")
		If GBL_objPubDB.intRSNum = 0 Then
			Call ResultExecute(E_USER_PUB,"该要编辑帖子不存在或已删除","ES_ERR")
			Exit Sub
		End If
		strContent = GBL_objPubDB.objPubRS("REPLY_CONTENT")
		strFace = GBL_objPubDB.objPubRS("REPLY_FACE")
		strTitle = GBL_objPubDB.objPubRS("REPLY_TITLE")

	End If

	'== quote reply
	If Trim(Request.QueryString("ACT_MODE")) = "ACT_REPLY_QUOTE" Then
	
		ReplyId = Trim(Request.QueryString("ReplyId"))
		strAddInfo = "引用贴"
		intErrId = DataCheck("DT_ID",ReplyId,strAddInfo,"ES_ERR")
		Call ResultExecute(intErrId,strAddInfo,"ES_ERR")

		GBL_objPubDB.Clear()
		GBL_objPubDB.AllSQL = "SELECT REPLY_CONTENT,USER_REALNAME FROM CLASS_REPLY,CLASS_USER WHERE USER_ID=REPLY_OWNER_ID AND REPLY_ID=" & ReplyId
		GBL_objPubDB.SQLRSExecute()
		Call ResultExecute(GBL_objPubDB.intErrNum,"quote reply","ES_ERR")

		If GBL_objPubDB.intRSNum > 0 Then
			strContent = "[QUOTE]引用" & GBL_objPubDB.objPubRS("USER_REALNAME") & "发表的内容:<br>" & GBL_objPubDB.objPubRS("REPLY_CONTENT") & "[/QUOTE]"
		End If
		
	End If

	'== check id
	GetRSId = Trim(Request.QueryString("TopicsId"))
	strAddInfo = "该需回复帖子"
	intErrId = DataCheck("DT_ID",GetRSId,strAddInfo,"")
	Call ResultExecute(intErrId,strAddInfo,"ES_ERR")

	'== get title
	Dim strInTitle
	If CONST_PAGE_FILE = "forum/forum_show.asp" Then
		strTitle = strInTitle
	Else
		If strActFlag <> "FORUM_EDIT_MODE" Then
			GBL_objPubDB.Clear()
			GBL_objPubDB.AllSQL = "SELECT TOPICS_TITLE  FROM CLASS_TOPICS WHERE TOPICS_ID=" & GetRSId
			GBL_objPubDB.SQLRSExecute()
			Call ResultExecute(GBL_objPubDB.intErrNum,"get add reply title","ES_ERR")
			If GBL_objPubDB.intRSNum = 0 Then
				Call ResultExecute(E_USER_PUB,"该要回复的帖子不存在或已删除","ES_ERR")
				Exit Sub
			End If
			strTitle = GBL_objPubDB.objPubRS("TOPICS_TITLE")
		End If
	End If

	'== check topics status
	If CONST_PAGE_FILE = "forum/forum_show.asp" Then
	Else
		GBL_objPubDB.Clear()
		GBL_objPubDB.AllSQL = "SELECT TOPICS_REPLY_FORBID FROM CLASS_TOPICS WHERE TOPICS_ID=" & GetRSId
		GBL_objPubDB.SQLRSExecute()
		Call ResultExecute(GBL_objPubDB.intErrNum,"get before reply topics ","ES_ERR")
		If GBL_objPubDB.intRSNum <= 0 Then
			Call ResultExecute(E_USER_PUB,"该帖子不存在","ES_ERR")
			Exit Sub
		ElseIf GBL_objPubDB.objPubRS("TOPICS_REPLY_FORBID") = 1 Then
			Call ResultExecute(E_USER_PUB,"该帖子已被设置为禁止回复","ES_ERR")
			Exit Sub 
		End If
	End If

	Set clsForm = New classFormOld
	If strActFlag = "FORUM_EDIT_MODE" Then
		clsForm.Action = "forum_add_save.asp?action=FormSaveAddReply&TopicsId=" & GetRSId & "&pstActFlag=FORUM_EDIT_MODE&ReplyId=" & GetRSId1
	Else
		clsForm.Action = "forum_add_save.asp?action=FormSaveAddReply&TopicsId=" & GetRSId
	End If
	clsForm.Id = "frmAddReply"
	clsForm.Name = "frmAddReply"
	clsForm.OnSubmit = "return CheckFormAddReply(this)"
	clsForm.ColumnScale = "20%"
	clsForm.MakeForm()
	clsForm.MakeTable "0","3","1","center","530","TBone"

	clsForm.AddTr "TBHead"
	If strActFlag = "FORUM_EDIT_MODE" Then
		clsForm.AddTitle "<b>修改回复帖子</b>","TBHead style='text-align:left;'"
	Else
		clsForm.AddTitle "<b>回复帖子</b>","TBHead style='text-align:left;'"
	End If

	GBL_cssFormTr = ""
	GBL_cssFormTdOne = "TBBG1"
	GBL_cssFormTdTwo = "TBBG9"
	clsForm.AddTr GBL_cssFormTr
	clsForm.AddTd "回贴主题",GBL_cssFormTdOne,GBL_cssFormTdTwo
	clsForm.AddText "iptReTitle class=fminpt ","100","75"
	If strActFlag <> "FORUM_EDIT_MODE" Then
		strTitle = "Re:" & strTitle
	End If
	clsForm.AddValue strTitle

	'== get now smile
	Call ForumFace(clsForm,strFace)

	clsForm.AddTr GBL_cssFormTr
	clsForm.AddTd "UBB标签",GBL_cssFormTdOne,GBL_cssFormTdTwo
	clsForm.AddLine GetUbb()

	clsForm.AddTr GBL_cssFormTr
	clsForm.AddTd "*回复内容",GBL_cssFormTdOne,GBL_cssFormTdTwo
	clsForm.AddTextrea "txtContent class=fmtxtra ","75","15"
	clsForm.AddValue FilterHtml(strContent)

	clsForm.AddTr GBL_cssFormTr
	clsForm.AddTd "*插入表情",GBL_cssFormTdOne,GBL_cssFormTdTwo
	clsForm.AddLine ShowSmileOut(14)

	'clsForm.AddTr GBL_cssFormTr
	'clsForm.AddTd "*回复选项",GBL_cssFormTdOne,GBL_cssFormTdTwo
	'clsForm.AddChkBox "chkSign",0,"使用个性签名",0

	clsForm.AddTr GBL_cssFormTr
	clsForm.AddTd "帖子提交",GBL_cssFormTdOne,GBL_cssFormTdTwo
	strHtmlCode = "<input type=hidden name='hidForumId' id='hidForumId' value=" & ForumId & ">"
	clsForm.AddLine "Alt+S或Ctrl+Enter快速提交" & strHtmlCode

	clsForm.AddTr "TBBG9"
	clsForm.AddSubTd " align=center "
	clsForm.AddSub "subAddReply","提 交","submit class='fmbtn' "
	clsForm.AddSub "rstAddReply","重 写","reset class='fmbtn' "
	
	clsForm.OutPutForm()
	Set clsForm = Nothing

End Sub
'====================================================================
'= Function    : ForumIcoShow()
'= Called by   : 
'= Calls       : 
'= Description : 贴吧图例
'====================================================================
Function ForumIcoShow()
%>
	<table width=100% >
		<tr width=100%>
			<td width=100% align=center valign=bottom>贴吧图例:
			<img src="<%=GBL_strHomeURL%>images/Ico/User_info.gif"  align=absmiddle valign='middle'>发贴者信息&nbsp;
			<img src="<%=GBL_strHomeURL%>images/Ico/forum_quote.gif" align=absmiddle valign='middle'>引用留言&nbsp;
			<img src="<%=GBL_strHomeURL%>images/Ico/forum_del.gif" align=absmiddle valign='middle'>删除&nbsp;
			<img src="<%=GBL_strHomeURL%>images/Ico/forum_edit.gif" align=absmiddle valign='middle'>编辑&nbsp;
			<img src="<%=GBL_strHomeURL%>images/Ico/User_sms.gif" align=absmiddle valign='middle'>发站内短信&nbsp;
			</td>
		</tr>
	</table>
<%
End Function

'====================================================================
'= Function    : ShowForumMenu()
'= Called by   : 
'= Calls       : 
'= Description : 导航菜单
'====================================================================
Function ShowForumMenu() 
	Dim GetRSId,strMaster
	GetRSId = Trim(Request("ForumId"))
	If Not IsNumeric(GetRSId) Then 
		Call ResultExecute(E_USER_PUB,"该帖子ID错误="&GetRSId,"ES_ERR")
	End If

	'== master
	strMaster =  Replace(GetConfig(Application(GBL_strCookieURL & "FORUM_MASTER_NAME"),"Forum" & GetRSId),"|",", ")
	If Trim(strMaster) <> "" Then
		strMaster = " 本版版主:" & strMaster
	Else
		strMaster = " 本版版主:暂无"
	End If

%>
 
<table width=500 border=0  cellspacing=5 cellpadding=1 class="forum_nav_table">
		<tr >
			<td width=100% colspan=2 style="text-align:left" >
			<%
			If Trim(Request.QueryString("ACT_MODE")) = "ACT_TOPICS_GOOD" Then
				Response.Write ForumMenu(1,"<font color=red>精华区</font>") 
			ElseIf Trim(Request.QueryString("ACT_MODE")) = "ACT_SEARCH" Then
				Response.Write ForumMenu(1,"<font color=red>搜索</font>")
			ElseIf Trim(Request.QueryString("ACT_MODE")) = "ACT_TOPICS_SUBJECT" Then
				Subject = Trim(Request.QueryString("Subject"))
				If Not IsEmpty(DEF_FormSubject(GetRSId)) Then
					If IsArray(DEF_FormSubject(GetRSId)) Then 
						arrNowSub = DEF_FormSubject(GetRSId)
						If Not IsEmpty(arrNowSub(Subject-1)) Then
							strSub = "<font color=red>本版专题 >> " & arrNowSub(Subject-1) & "</font>"
						Else
							strSub = "帖子列表"
						End If
					Else
						strSub = "帖子列表"
					End If
				Else
					strSub = "帖子列表"
				End If
				Response.Write ForumMenu(1,"<font color=red>" & strSub & "</font>")
			ElseIf Trim(Request.QueryString("ACT_MODE")) = "ACT_SEARCH" Then
				Response.Write ForumMenu(1,"帖子搜索")
			Else
				Response.Write ForumMenu(1,"帖子列表")
			End If
			%>
			</td>
		</tr>
		<tr>
			<td width="*" align=left>
			<%
				Dim strHtmlCode,strTmp
				strHtmlCode = ""
				strTmp = MakeImg(GBL_strImgDir & "ico/forum_add.gif","")
				strHtmlCode = "&nbsp;"&  MakeLink("forum/forum_add_topics.asp?action=FormAddTopics&ForumId=" & GetRSId,strTmp,"") & "&nbsp;<img src='" & GBL_strHomeURL & "images/forum/plus.gif' align=absmiddle> <a href='" & GBL_strHomeURL & "forum/forum_list.asp?action=ShowForumList&ForumId=" & GetRSId & "&ACT_MODE=ACT_TOPICS_GOOD" & "'>精华</a>"
				Response.Write strHtmlCode
				Response.Write "&nbsp;&nbsp;<img src='" & GBL_strHomeURL & "images/forum/plus.gif' align=absmiddle> <a href='" & GBL_strHomeURL & "forum/forum_list.asp?action=ShowForumList&ForumId=" & GetRSId & "&ACT_MODE=ACT_SEARCH" & "'>搜索</a>"

				'== subject
				'If Not IsEmpty(DEF_FormSubject(GetRSId)) Then
				'	If IsArray(DEF_FormSubject(GetRSId)) Then
				'		Response.Write "&nbsp;&nbsp;<img src='" & GBL_strHomeURL & "images/forum/plus.gif' align=absmiddle> 专题:"
				'		arrNowSub = DEF_FormSubject(GetRSId)
				'		For n = Lbound(arrNowSub) To Ubound(arrNowSub)
				'			Response.Write "&nbsp;&nbsp;<img src='" & GBL_strHomeURL & "images/forum/folder.gif' align=absmiddle> <a href='" & GBL_strHomeURL & "forum/forum_list.asp?action=ShowForumList&ForumId=" & GetRSId & "&ACT_MODE=ACT_TOPICS_SUBJECT&Subject=" & n+1 & "'>" & arrNowSub(n) & "</a>"
				'		Next
				'	End If
				'End If
			%>
			</td>
			<td width="*" align=right>
			<%
				Dim strTemp
				Dim arrMasterName : arrMasterName = Split(GBL_strForumMasterName,"|||")
				Dim arrMasterId : arrMasterId = Split(GBL_strForumMasterId,"|||")
				Dim m
				For m = Lbound(arrMasterName) To UBound(arrMasterName)
					strTemp =  strTemp & "<span style='cursor:hand'  title='查看详细信息' onclick=window.open('../address/address_userinfo_pop.asp?intUserId=" & arrMasterId(m) & "','','left=5,top=5,width=450,height=410,scrollbars=yes,status=yes') >" & arrMasterName(m) & "</span>&nbsp;"
				Next
				If strTemp <> "" Then
					strTemp = "贴吧总版主:" & strTemp
				End If
				Response.Write "<font color=red>" & strTemp & "&nbsp;&nbsp;" & strMaster & "</font>&nbsp;&nbsp;&nbsp;"	
			%>
			</td>
		</tr>
	</table>
<%
End Function

'====================================================================
'= Function    : ShowAddTopicsForumMenu(strClew)
'= Called by   : 
'= Calls       : 
'= Description : 导航菜单
'====================================================================
Function ShowAddTopicsForumMenu(strClew)
	Dim GetRSId,strMaster
	GetRSId = Trim(Request("ForumId"))
	If Not IsNumeric(GetRSId) Then 
		Call ResultExecute(E_USER_PUB,"该帖子ID错误="&GetRSId,"ES_ERR")
	End If

	'== master
	strMaster =  Replace(GetConfig(Application(GBL_strCookieURL & "FORUM_MASTER_NAME"),"Forum" & GetRSId),"|",", ")
	If Trim(strMaster) <> "" Then
		strMaster = " 本版版主:" & strMaster
	Else
		strMaster = " 本版版主:暂无"
	End If

%>
<table width=500  cellspacing=1 cellpadding=5 class="forum_nav_table">
		<tr >
			<td width=100% colspan=2 style="text-align:left" >
			<%
			
			Response.Write ForumMenu(2,strClew)
			
			%>
			</td>
		</tr>
		
	</table>
<%
End Function

'====================================================================
'= Function    : ShowAddReplyForumMenu(strClew)
'= Called by   : 
'= Calls       : 
'= Description : 导航菜单
'====================================================================
Function ShowAddReplyForumMenu(strClew)
	Dim GetRSId,strMaster
	GetRSId = Trim(Request("ForumId"))
	If Not IsNumeric(GetRSId) Then 
		Call ResultExecute(E_USER_PUB,"该帖子ID错误="&GetRSId,"ES_ERR")
	End If

	'== master
	strMaster =  Replace(GetConfig(Application(GBL_strCookieURL & "FORUM_MASTER_NAME"),"Forum" & GetRSId),"|",", ")
	If Trim(strMaster) <> "" Then
		strMaster = " 本版版主:" & strMaster
	Else
		strMaster = " 本版版主:暂无"
	End If

%>
<table width=500  cellspacing=1 cellpadding=5 class="forum_nav_table">
		<tr >
			<td width=100% colspan=2 style="text-align:left" >
			<%
			
			Response.Write ForumMenu(2,strClew)
			
			%>
			</td>
		</tr>
		
	</table>
<%
End Function
%>