⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 postmess.asp

📁 电子商务网络购物系统
💻 ASP
字号:
<% Option Explicit %>
<!--#include file="conn.asp" -->
<!--#include file="functions/sendmail.asp" -->
<!--#include file="functions/formatpost.asp"	-->
<!--#include file="includes/emoticons.asp" -->
<%
Response.Buffer	= True

Dim lngNumOfPosts
Dim blnEmailNotify
Dim blnEmailSent
Dim strEmailSubject
Dim strMessage
Dim lngMessageID
Dim strMode
Dim intForumID
Dim lngTopicID
Dim strSubject
Dim strPostDateTime
Dim strUserName
Dim lngEmailUserID
Dim strUserEmail
Dim strEmailMessage
Dim blnSignature
Dim intPriority
Dim strPostMessage
Dim intReturnPageNum
Dim strForumName
Dim intNumOfPostsInFiveMin
Dim strReturnCode
Dim strPollQuestion
Dim blnMultipleVotes
Dim blnPollReply
Dim saryPollChoice()
Dim intPollChoice
Dim strBadWord
Dim strBadWordReplace
Dim lngPollID
Dim blnForumLocked
Dim blnTopicLocked
Dim intNewGroupID
Dim strGuestName

strPostDateTime	= Now()
intNumOfPostsInFiveMin = 0
lngPollID = 0
blnForumLocked = False
blnTopicLocked = False

If lngLoggedInUserID = 0 OR blnActiveMember = False Then
	Set rsConn = Nothing
	adoCon.Close
	Set adoCon = Nothing
	Response.Redirect "index.asp"
End If

If bannedIP() Then
	Set rsConn = Nothing
	adoCon.Close
	Set adoCon = Nothing
	Response.Redirect("nopermission.asp?M=IP")
End If

strMode	= Request.Form("mode")
intForumID = CInt(Request.Form("fid"))
lngTopicID = CLng(Request.Form("tid"))
strSubject = Trim(Mid(Request.Form("subject"), 1, 41))
strMessage = Request.Form("Message")
lngMessageID = CLng(Request.Form("pid"))
blnEmailNotify = CBool(Request.Form("email"))
blnSignature = CBool(Request.Form("signature"))
intPriority = CInt(Request.Form("priority"))
If lngLoggedInUserID = 2 Then strGuestName = Trim(Mid(Request.Form("Gname"), 1, 20))

strSQL = "SELECT timesbbs.* FROM timesbbs WHERE	bbsid = " & intForumID & ";"
rsConn.Open strSQL, adoCon
If NOT rsConn.EOF Then
	If blnAdmin = False Then blnForumLocked = CBool(rsConn("Locked"))
	Call forumPermisisons(intForumID, intGroupID, CInt(rsConn("Read")), CInt(rsConn("Post")), CInt(rsConn("replypost")), CInt(rsConn("editpost")), 0, CInt(rsConn("toppost")), CInt(rsConn("addpoll")), 0,	0, 0)
End If
rsConn.Close

If strMode <> "new" AND blnForumLocked = False AND blnAdmin = False AND blnModerator = False Then
	strSQL = "SELECT timestopic.Locked FROM timestopic WHERE timestopic.topicid = " & lngTopicID & ";"
	rsConn.Open strSQL, adoCon
	If NOT rsConn.EOF Then
		blnTopicLocked = CBool(rsConn("Locked"))
	End If
	rsConn.Close
End If

If blnForumLocked OR blnTopicLocked Then

	Set rsConn = Nothing
	adoCon.Close
	Set adoCon = Nothing
	If blnForumLocked Then
		Response.Redirect("failpost.asp?mode=FLocked")
	Else
		Response.Redirect("failpost.asp?mode=TClosed")
	End If
End If

If Request.Form("tpn") = "" Then
	intReturnPageNum = 1
Else
	intReturnPageNum = CInt(Request.Form("tpn"))
End If
If NOT Request.Form("ThreadPos") = "" Then
	If CInt(Request.Form("ThreadPos")) > (intThreadsPerPage	* intReturnPageNum) Then
		intReturnPageNum = intReturnPageNum + 1
	End If
End If

If strSubject =	"" AND (strMode	= "new"	OR strMode = "editTopic" OR strMode = "poll") Then strReturnCode = "noSubject"
If strMessage =	"" Then	strReturnCode =	"noSubject"
If Request.Form("browser") = "IE" Then
	strMessage = WYsiWYGFormatPost(strMessage)
Else
	strMessage = FormatPost(strMessage)
End If
If Request.Form("forumCodes") Then strMessage = FormatForumCodes(strMessage)
strMessage = checkHTML(strMessage)
strSubject = removeAllTags(strSubject)
strSubject = formatInput(strSubject)
If lngLoggedInUserID = 2 Then 
	strGuestName = formatSQLInput(strGuestName)
	strGuestName = formatInput(strGuestName)
End If
If strMode = "poll" AND	blnPollCreate =	True Then
	strPollQuestion	= Trim(Mid(Request.Form("pollQuestion"), 1, 41))
	blnMultipleVotes = CBool(Request.Form("multiVote"))
	blnPollReply = CBool(Request.Form("pollReply"))
	If strPollQuestion = ""	Then strReturnCode = "noPoll"
	strPollQuestion	= removeAllTags(strPollQuestion)
	strPollQuestion	= formatInput(strPollQuestion)
	For intPollChoice = 1 To intMaxPollChoices
		ReDim Preserve saryPollChoice(intPollChoice)
		saryPollChoice(intPollChoice) =	Trim(Mid(Request.Form("choice" & intPollChoice), 1, 41))
		If intPollChoice < 2 AND saryPollChoice(intPollChoice) = "" Then strReturnCode = "noPoll"
		If saryPollChoice(intPollChoice) = "" Then
			ReDim Preserve saryPollChoice(intPollChoice - 1)
			Exit For
		End If
		saryPollChoice(intPollChoice) =	removeAllTags(saryPollChoice(intPollChoice))
		saryPollChoice(intPollChoice) =	formatInput(saryPollChoice(intPollChoice))
	Next
End If

strSQL = "SELECT timesword.* FROM	timesword"
rsConn.Open strSQL, adoCon
Do While NOT rsConn.EOF
	strBadWord = rsConn("mist")
	strBadWordReplace = rsConn("okworld")
	strSubject = Replace(strSubject, strBadWord, strBadWordReplace,	1, -1, 1)
	strMessage = Replace(strMessage, strBadWord, strBadWordReplace,	1, -1, 1)
	If strMode = "poll" Then
		strPollQuestion	= Replace(strPollQuestion, strBadWord, strBadWordReplace, 1, -1, 1)
		For intPollChoice = 1 To UBound(saryPollChoice)
			saryPollChoice(intPollChoice) =	Replace(saryPollChoice(intPollChoice), strBadWord, strBadWordReplace, 1, -1, 1)
		Next
	End If
	rsConn.MoveNext
Loop
rsConn.Close

strSQL = "SELECT TOP 15	timespost.Message, timespost.userid,	timespost.msgdtm FROM timespost ORDER BY timespost.msgdtm DESC;"
rsConn.Open strSQL, adoCon
If NOT rsConn.EOF Then
	If (rsConn("Message")	= strMessage) AND NOT (strMode = "edit"	OR strMode = "editTopic") Then
		strReturnCode =	"posted"
	End If
	Do While NOT rsConn.EOF AND blnAdmin = False AND lngLoggedInUserID <> 2
		If rsConn("userid") = lngLoggedInUserID AND DateDiff("s", rsConn("msgdtm"), now())	< intSpamTimeLimitSeconds AND intSpamTimeLimitSeconds <> 0 Then
			strReturnCode =	"maxS"
		End If
		If rsConn("userid") = lngLoggedInUserID AND DateDiff("n", rsConn("msgdtm"), now())	< intSpamTimeLimitMinutes AND intSpamTimeLimitMinutes <> 0 Then
			intNumOfPostsInFiveMin = intNumOfPostsInFiveMin	+ 1
			If intNumOfPostsInFiveMin = 5 Then
				strReturnCode =	"maxM"
			End If
		End If
		rsConn.MoveNext
	Loop
End If
rsConn.Close

If strReturnCode <> "" AND  NOT	(strMode = "edit" OR strMode = "editTopic") Then
	Set rsConn = Nothing
	adoCon.Close
	Set adoCon = Nothing
	Response.Redirect "failpost.asp?mode=" & strReturnCode
End If

If strMode = "poll" AND	blnPollCreate =	True Then
	strSQL = "SELECT TOP 1 timespoll.* FROM timespoll ORDER BY timespoll.pollid DESC;"
	With rsConn
		.CursorType = 2
		.LockType = 3
		.Open strSQL, adoCon
		.AddNew
		.Fields("pollques") = strPollQuestion
		.Fields("multi") = blnMultipleVotes
		.Fields("Reply") = blnPollReply
		.Update
		.Requery
		lngPollID = CLng(rsConn("pollid"))
		.Close
	End With

	For intPollChoice = 1 To UBound(saryPollChoice)
		strSQL = "SELECT TOP 1 timeschoice.* FROM timeschoice;"
		With rsConn
			.CursorType = 2
			.LockType = 3
			.Open strSQL, adoCon
			.AddNew
			.Fields("pollid") = lngPollID
			.Fields("Choice") = saryPollChoice(intPollChoice)
			.Update
			.Requery
			.Close
		End With
	Next
	strMode	= "new"
End If

If strMode = "new" AND (blnPost	= True OR (blnAdmin = True OR blnModerator = True)) Then
	strSQL = "SELECT TOP 1 timestopic.* FROM timestopic	"
	strSQL = strSQL	& "WHERE bbsid =" & intForumID & " "
	strSQL = strSQL	& "ORDER By timestopic.startdtm	DESC;"
	With rsConn
		.CursorType = 2
		.LockType = 3
		.Open strSQL, adoCon
		.AddNew
		.Fields("bbsid") = intForumID
		.Fields("pollid") = lngPollID
		.Fields("Subject") = strSubject
		.Fields("Priority") = intPriority
		.Fields("startdtm") =	strPostDateTime
		.Update
		.Requery
		lngTopicID = CLng(rsConn("topicid"))
		intReturnPageNum = 1
		.Close
	End With
End If

If strMode = "editTopic" AND (blnEdit =	True OR	(blnAdmin = True OR blnModerator = True)) Then
	strSQL = "SELECT timestopic.Subject, timestopic.Priority FROM timestopic "
	strSQL = strSQL	& "WHERE topicid =" & lngTopicID & ";"
	With rsConn
		.CursorType = 2
		.LockType = 3
		.Open strSQL, adoCon
		.Fields("Subject") = strSubject
		.Fields("Priority") = intPriority
		.Update
		strMode	= "edit"
		.Close
	End With
End If

If strMode = "edit" AND	(blnEdit = True	OR (blnAdmin = True OR blnModerator = True)) Then
	If blnShowEditUser Then
		strMessage = strMessage & "<edited><editID>" & strLoggedInUsername & "</editID><editDate>" & CDbl(now()) &  "</editDate></edited>"
	End If
	strSQL = "SELECT timespost.postid, timespost.Message, timespost.dissign, timespost.ipaddr "
	strSQL = strSQL	& "FROM	timespost "
	strSQL = strSQL	& "WHERE timespost.postid=" & lngMessageID &	";"
	With rsConn
		.CursorType = 2
		.LockType = 3
		.Open strSQL, adoCon
		.Fields("Message") = strMessage
		.Fields("dissign") = CBool(blnSignature)
		.Fields("ipaddr") = Request.ServerVariables("REMOTE_ADDR")
		.Update
		.Close
	End With

ElseIf ((strMode = "new" AND blnPost = True) OR	(blnReply = True)) OR (blnAdmin	= True OR blnModerator = True) Then
	strSQL = "SELECT TOP 1 timespost.postid, timespost.topicid, timespost.userid,	timespost.Message, timespost.msgdtm, timespost.dissign, timespost.ipaddr "
	strSQL = strSQL	& "FROM	timespost "
	strSQL = strSQL	& "ORDER BY timespost.postid DESC;"
	With rsConn
		.CursorType = 2
		.LockType = 3
		.Open strSQL, adoCon
		.AddNew
		.Fields("topicid") = lngTopicID
		.Fields("userid") = lngLoggedInUserID
		.Fields("Message") = strMessage
		.Fields("msgdtm")	= strPostDateTime
		.Fields("dissign") = blnSignature
		.Fields("ipaddr") = Request.ServerVariables("REMOTE_ADDR")
		.Update
		.Requery
		lngMessageID = CLng(rsConn("postid"))
		.Close
	End With
	strSQL = "UPDATE timestopic SET "
	strSQL = strSQL	& "timestopic.lastdtm = "	& strDatabaseDateFunction & " "
	strSQL = strSQL	& "WHERE (((timestopic.topicid)=	" & lngTopicID & "));"
	adoCon.Execute(strSQL)
	If lngLoggedInUserID = 2 AND strGuestName <> "" Then
		strSQL = "INSERT INTO timesguest ("
		strSQL = strSQL & "[Name], "
		strSQL = strSQL & "[postid] "
		strSQL = strSQL & ") "
		strSQL = strSQL & "VALUES "
		strSQL = strSQL & "('" & strGuestName & "', "
		strSQL = strSQL & "'" & lngMessageID & "' "
		strSQL = strSQL & ")"
		adoCon.Execute(strSQL)
	End If
	strSQL = "SELECT timesuser.postnum, timesgrp.cusrank "
	strSQL = strSQL	& "FROM	timesuser, timesgrp "
	strSQL = strSQL	& "WHERE timesuser.grpid = timesgrp.grpid AND timesuser.userid= " & lngLoggedInUserID & ";"
	rsConn.Open strSQL, adoCon
	If NOT rsConn.EOF Then
		lngNumOfPosts =	CLng(rsConn("postnum"))
		lngNumOfPosts =	lngNumOfPosts +	1
		strSQL = "UPDATE timesuser SET "
		strSQL = strSQL	& "timesuser.postnum = " & lngNumOfPosts
		strSQL = strSQL	& " WHERE timesuser.userid= " & lngLoggedInUserID & ";"
		adoCon.Execute(strSQL)
	End If

	If NOT rsConn.EOF Then
		If CBool(rsConn("cusrank")) = False Then
			rsConn.Close
			intNewGroupID = intGroupID
			strSQL = "SELECT TOP 1 timesgrp.grpid "
			strSQL = strSQL	& "FROM timesgrp "
			strSQL = strSQL	& "WHERE (timesgrp.minipost <= " & lngNumOfPosts & ") And (timesgrp.minipost >= 0) "
			strSQL = strSQL	& "ORDER BY timesgrp.minipost DESC;"
			rsConn.Open strSQL, adoCon
			If NOT rsConn.EOF Then intNewGroupID = CInt(rsConn("grpid"))
			If intGroupID <> intNewGroupID Then
				strSQL = "UPDATE timesuser SET "
				strSQL = strSQL	& "timesuser.grpid = " & intNewGroupID
				strSQL = strSQL	& " WHERE timesuser.userid= " & lngLoggedInUserID & ";"
				adoCon.Execute(strSQL)
			End If
		End If
	End If
	rsConn.Close

	If blnEmail = True Then
		strEmailSubject	= strMainForumName & " " & "论坛发贴提醒"
		If blnSendPost = True Then
			strSQL = "SELECT timesbbs.bbsname, timestopic.Subject "
			strSQL = strSQL	& "FROM	timesbbs INNER JOIN timestopic ON	timesbbs.bbsid = timestopic.bbsid "
			strSQL = strSQL	& "WHERE topicid =" & lngTopicID & ";"
			rsConn.Open strSQL, adoCon
			If NOT rsConn.EOF Then
				strSubject = rsConn("Subject")
				strForumName = rsConn("bbsname")
			End If
			rsConn.Close
			strPostMessage = "<br /><b>论坛名称:</b> " &	strForumName
			strPostMessage = strPostMessage	& "<br /><b>主题名称:</b> " & strSubject
			strPostMessage = strPostMessage	& "<br /><b>发帖人:</b>	" & strLoggedInUsername & "<br /><br />"
			strPostMessage = strPostMessage	& strMessage
			strPostMessage = Replace(strPostMessage, "src=""smileys/smiley", "src=""" & strForumPath & "/smileys/smiley", 1, -1, 1)
		End If
		strSQL = "SELECT DISTINCT timesnotify.userid, timesuser.Username,	timesuser.useremail "
		strSQL = strSQL	& "FROM	timesuser INNER	JOIN timesnotify ON timesuser.userid = timesnotify.userid "
		strSQL = strSQL	& "WHERE (timesnotify.bbsid=" & intForumID & " OR	timesnotify.topicid=" & lngTopicID & ") AND	timesuser.useremail Is Not Null;"
		rsConn.Open strSQL, adoCon
		Do While NOT rsConn.EOF
			strUserName = rsConn("Username")
			lngEmailUserID = CLng(rsConn("userid"))
			strUserEmail = rsConn("useremail")
			If lngEmailUserID <> lngLoggedInUserID Then
				strEmailMessage	= "Hi" & " " & decodeString(strUserName) & ","
				strEmailMessage	= strEmailMessage & "<br /><br /> 在论坛已经发表了一个贴子 " & strMainForumName & ""
				strEmailMessage	= strEmailMessage & "<br /><br />查看发表的贴子请点击以下连接 : "
				strEmailMessage	= strEmailMessage & "<br /><a href=""" & strForumPath &	"/post.asp?tid="	& lngTopicID & "&tpn=" & intReturnPageNum & """>" & strForumPath & "/post.asp?tid=" & lngTopicID	& "&tpn=" & intReturnPageNum & "</a>"
				strEmailMessage	= strEmailMessage & "<br /><br />取消 :"
				strEmailMessage	= strEmailMessage & "<br /><a href=""" & strForumPath &	"/enotify.asp?tid=" & lngTopicID &	"&fid="	& intForumID & "&M=Unsubscribe"">" & strForumPath & "/enotify.asp?tid=" & lngTopicID & "&fid=" & intForumID & "&M=Unsubscribe</a>"
				If blnSendPost = True Then
					strEmailMessage	= strEmailMessage & "<br /><br /><hr />" & strPostMessage
				End If
				blnEmailSent = SendMail(strEmailMessage, decodeString(strUserName), decodeString(strUserEmail),	strMainForumName, decodeString(strForumEmailAddress), strEmailSubject, strMailComponent, true)
			End If
			rsConn.MoveNext
		Loop
		rsConn.Close
	End If
	Call updateTopicPostCount(intForumID)
End If

If (strMode = "new" OR strMode = "edit"	OR strMode="reply") AND	blnEmail = True	Then
		strSQL = "SELECT timesnotify.*  "
		strSQL = strSQL	& "FROM	timesnotify "
		strSQL = strSQL	& "WHERE timesnotify.userid=" & lngLoggedInUserID	& " AND	timesnotify.topicid=" & lngTopicID & ";"
	With rsConn
		.CursorType = 2
		.LockType = 3
		.Open strSQL, adoCon
		If blnEmailNotify = False AND NOT .EOF Then
			.Delete
		ElseIf ((strMode = "new" OR strMode = "reply") OR (strMode = "edit" AND	.EOF)) AND blnEmailNotify = True Then
			.AddNew
			.Fields("userid") = lngLoggedInUserID
			.Fields("topicid") = lngTopicID
			.Update
		End If
		.Close
	End With
End If
Set rsConn = Nothing
adoCon.Close
Set adoCon = Nothing
Response.Redirect "post.asp?tid=" & lngTopicID &	"&pn=1&tpn=" & intReturnPageNum
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -