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

📄 posting.asp

📁 简介:一个程序小巧而功能强大
💻 ASP
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--#include file="Includes/site-dataconn.asp" -->
<!--#include file="Includes/func-common.asp" -->
<!--#include file="Includes/site-config.asp" -->
<!--#include file="Includes/inc-common.asp" -->
<!--#include file="Includes/func-aspcode.asp" -->
<%
Response.Expires = 60
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
%>
<html>

<head>
<title>// <%=Site_Name%> //</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK REL=stylesheet TYPE="text/css" HREF="Includes/site-style.css">
</head>

<body>
<%
'Check user is logged in
if isnull(session("UserID")) = true or session("UserID") = "" then
	strMessage = "You must be logged in to " & Site_Name & " to post a Message. Click <a href='displayforum.asp?F="& clng(request.form("ForumID")) &"'>here</a> if you are not redirected within 5 seconds."
	strRedirectURL = "displayforum.asp?F="& clng(request.form("ForumID"))
end if

'Check that the user as come from the newreply/newtopic page
if instr(1, request.servervariables("HTTP_REFERER"), "?", 1) > 0 then
	strReferedBy = left(request.servervariables("HTTP_REFERER"), (instr(1, request.servervariables("HTTP_REFERER"), "?", 1)-1))
else
	strReferedBy = request.servervariables("HTTP_REFERER")
end if
strCurrentURL_Reply = Site_Forum_URL &"/newreply.asp"
strCurrentURL_Topic = Site_Forum_URL &"/newtopic.asp"

if lcase(strReferedBy) <> lcase(strCurrentURL_Reply) and lcase(strReferedBy) <> lcase(strCurrentURL_Topic) then
	strMessage = "You have reached this page in error. Click <a href='default.asp'>here</a> if you are not redirected within five seconds."
	strRedirectURL = "Default.asp"
end if

if request.form("method") = "topic" then
	'Check user has filled in both fields
	if (len(request.form("Title")) < 1 or len(request.form("Text")) < 1) and strMessage = "" then
		strMessage = "You must complete both fields before you can post a topic. Click <a href='displayforum.asp?F="& clng(request.form("ForumID")) &"'>here</a> if you are not redirected within 5 seconds."
		strRedirectURL = "displayforum.asp?F="& clng(request.form("ForumID"))
	end if
end if

if request.form("method") = "reply" then
	'Check user has filled reply fields
	if (len(request.form("Text")) < 1) and strMessage = "" then
		strMessage = "You must fill in the reply field before you can reply to a topic. Click <a href='displayforum.asp?F="& clng(request.form("ForumID")) &"'>here</a> if you are not redirected within 5 seconds."
		strRedirectURL = "displayforum.asp?F="& clng(request.form("ForumID"))
	end if
end if 

if request.form("method") = "topic" then
	'Check valid forum has been specified
	set rsForumCheck = server.createobject("adodb.recordset")
	sqlForumCheck = "SELECT Forum_Name FROM Forum_Forums WHERE Forum_ID = "& clng(request.form("ForumID")) &";"
	rsForumCheck.open sqlForumCheck, adoConn, CMDText
	if (rsForumCheck.eof or rsForumCheck.bof) and strMessage = "" then
		strMessage = "An invalid forum has been specified, if you have followed a valid link please contact the board administrator. Click <a href='"& clng(request.form("ForumID")) &"'>here</a>if you are not redirected within 5 seconds."
		strRedirectURL = "displayforum.asp?F="& clng(request.form("ForumID"))
	end if
	rsForumCheck.close
	set rsForumCheck = nothing
end if

if request.form("method") = "reply" then
	'Check valid topic has been specified and topic is not closed
	set rsTopicCheck = server.createobject("adodb.recordset")
	sqlTopicCheck = "SELECT Topic_Type, Topic_Status FROM Forum_Topics WHERE Topic_ID = "& clng(request.form("TopicID")) &";"
	rsTopicCheck.open sqlTopicCheck, adoConn, CMDText
	if (rsTopicCheck.eof or rsTopicCheck.bof) and strMessage = "" then
		strMessage = "An invalid topic has been specified, if you have followed a valid link please contact the board administrator. Click <a href='displayforum.asp?F="& clng(request.form("ForumID")) &"'>here</a> if you are not redirected within 5 seconds."
		strRedirectURL = "displayforum.asp?F="& clng(request.form("ForumID"))
	end if
	if rsTopicCheck("Topic_Status") = 0 and strMessage = "" then
		strMessage = "The topic that you have selected has been closed by the forum moderators. Click <a href='displayforum.asp?F="& clng(request.form("ForumID")) &"'>here</a> if you are not redirected within 5 seconds."
		strRedirectURL = "displayforum.asp?F="& clng(request.form("ForumID"))
	end if
	if session("admin") <> true then
		if rsTopicCheck("Topic_Type") = 3 and strMessage = "" then
			strMessage = "The topic that you have selected is an announcement and no replies can be added to it. Click <a href=""displayforum.asp?F="& clng(request.form("ForumID")) &""">here</a> if you are not redirected within 5 seconds."
			strRedirectURL = "displayforum.asp?F="& clng(request.form("ForumID"))
		end if
	end if
	rsTopicCheck.close
	set rsTopicCheck = nothing
end if

'Check when user last posted.
set rsUserCheck = server.createobject("adodb.recordset")
sqlUserCheck = "SELECT User_Last_Post FROM Forum_Users WHERE User_ID = "& session("UserID") &";"
rsUserCheck.open sqlUserCheck, adoConn, CMDText
if (rsUserCheck.eof or rsUserCheck.bof) and strMessage = "" then
	strMessage = "You must be logged in to " & Site_Name & " to post a Message. Click <a href='displayforum.asp?F="& clng(request.form("ForumID")) &"'>here</a> if you are not redirected within 5 seconds."
	rsUserCheck.close
	set rsUserCheck = nothing
else
	if isnull(rsUserCheck("User_Last_Post")) = false then
		if ((db_time() - rsUserCheck("User_Last_Post")) < 15) and strMessage = "" then
			strMessage = "You must wait 15 seconds between posting Messages. Click <a href='displayforum.asp?F="& clng(request.form("ForumID")) &"'>here</a> if you are not redirected within 5 seconds."
			strRedirectURL = "javascript:history.go(-1)"
		end if
	end if
	rsUserCheck.close
	set rsUserCheck = nothing
end if

'Display Error strMessage or continue
if strMessage <> "" then
%>
	<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
		<td align="center">
		<table border="0" cellpadding="3" cellspacing="1" align="center" class="main">
			<tr valign="middle" class="title">
			<td align="center"><%=Site_Name%> // Error</td>
			</tr>
			<tr valign="top" class="body">
			<td align="center">
			<%=strMessage%>
			</td>
			</tr>
		</table>
		</td>
		</tr>
	</table>
	<META HTTP-EQUIV="Refresh" CONTENT="5; URL=<%=strRedirectURL%>">
<%
else
	'Check Forum Rules and Category
	set rsCheck = server.createobject("adodb.recordset")
	sqlCheck = "SELECT Forum_Allow_Images, Forum_Category_ID FROM Forum_Forums WHERE Forum_ID = "& clng(request.form("ForumID")) &";"
	rsCheck.open sqlCheck, adoConn, CMDText
	if not (rsCheck.eof or rsCheck.bof) then
		Allow_Images = rsCheck("Forum_Allow_Images")
		strCategoryID = rscheck("Forum_Category_ID")
	end if
	rsCheck.close
	set rsCheck = nothing
	
	'Assign variables
	strForumID = clng(request.form("ForumID"))
	if request.form("method") = "reply" then
		strTopicID = clng(request.form("TopicID"))
	end if
	strUserID = session("UserID")
	strUserName = session("UserName")
	strTitle = clean_text(request.form("Title"), 0)
	strText = clean_text(request.form("Text"), Site_Allow_HTML)
	if request.form("bbcode") = 1 and Site_Allow_BB = 1 then
		strText = bbcode(strText, Allow_Images)
	end if
	if request.form("smilies") = 1 then
		strText = replace_smilies(strText)
	end if
	if request.servervariables("HTTP_X_FORWARDED_FOR") = "" then
		strIPAddress = request.servervariables("REMOTE_ADDR")
	else
		strIPAddress = request.servervariables("HTTP_X_FORWARDED_FOR")
	end If
	if request.form("signature") = 1 and Site_Allow_Signature = 1 then
		strSignature = 1
	else
		strSignature = 0
	end if
	if request.form("Post_Type") <> "" then
		strTopicType = request.form("Post_Type")
	else
		strTopicType = 1
	end if
	
	if request.form("method") = "topic" then
		'Insert the new topic
		set rsTopic = server.createobject("adodb.recordset")
		sqlTopic = "SELECT * FROM Forum_Topics;"
		rsTopic.cursortype = 2
		rsTopic.locktype = 3
		rsTopic.open sqlTopic, adoConn, CMDText
		rsTopic.addnew
		rsTopic("Topic_Forum_ID") = strForumID
		rsTopic("Topic_Category_ID") = strCategoryID
		rsTopic("Topic_User_ID") = strUserID
		rsTopic("Topic_Last_User_ID") = strUserID
		rsTopic("Topic_Title") = strTitle
		rsTopic("Topic_Time") = Site_Time
		rsTopic("Topic_Views") = 1
		rsTopic("Topic_Replies") = 0
		rsTopic("Topic_Type") = strTopicType
		rsTopic("Topic_Status") = 1
		rsTopic.update
		strTopicID = rsTopic("Topic_ID")
		rsTopic.close
		set rsTopic = nothing
		
		'Insert post
		set rsPost = server.createobject("adodb.recordset")
		sqlPost = "SELECT * FROM Forum_Posts;"
		rsPost.cursortype = 2
		rsPost.locktype = 2
		rsPost.open sqlPost, adoConn, CMDText
		rsPost.addnew
		rsPost("Post_Topic_ID") = strTopicID
		rsPost("Post_Forum_ID") = strForumID
		rsPost("Post_Category_ID") = strCategoryID
		rsPost("Post_User_ID") = strUserID
		rsPost("Post_Time") = Site_Time
		rsPost("Post_IP") = IPAddress
		rsPost("Post_Signature") = strSignature
		rsPost("Post_Title") = strTitle
		rsPost("Post_Text") = strText
		rsPost("Post_Index") = 1
		rsPost.update
		rsPost.close
		set rsPost = nothing
		
		'Update users details
		set rsUser = server.createobject("adodb.recordset")
		sqlUser = "SELECT User_Posts, User_Last_Post FROM Forum_Users WHERE User_ID = "& strUserID &""
		rsUser.cursortype = 2
		rsUser.locktype = 3
		rsUser.open sqlUser, adoConn, CMDText
		rsUser("User_Posts") = rsUser("User_Posts") + 1
		rsUser("User_Last_Post") = Site_Time
		rsUser.update
		rsUser.close
		set rsUser = nothing
		
		'Update forum table
		set rsForum = server.createobject("adodb.recordset")
		sqlForum = "SELECT Forum_Topics, Forum_Posts, Forum_Topic_ID, Forum_Post_Date, Forum_User_ID, Forum_User_Name FROM Forum_Forums WHERE Forum_ID = "& strForumID &";"
		rsForum.cursortype = 2
		rsForum.locktype = 3
		rsForum.open sqlForum, adoConn, CMDText
		rsForum("Forum_Topics") = rsForum("Forum_Topics") + 1
		rsForum("Forum_Posts") = rsForum("Forum_Posts") + 1
		rsForum("Forum_Topic_ID") = strTopicID
		rsForum("Forum_Post_Date") = Site_Time
		rsForum("Forum_User_ID") = strUserID
		rsForum("Forum_User_Name") = strUserName
		rsForum.update
		rsForum.close
		set rsForum = nothing
		
		'Update Stats
		set rsStats = server.createobject("adodb.recordset")
		sqlStats = "SELECT Stats_Topics, Stats_Posts FROM Forum_Stats;"
		rsStats.cursortype = 2
		rsStats.locktype = 3
		rsStats.open sqlStats, adoConn, CMDText
		rsStats("Stats_Topics") = rsStats("Stats_Topics") + 1
		rsStats("Stats_Posts") = rsStats("Stats_Posts") + 1
		rsStats.update
		rsStats.close
		set rsStats = nothing
		
		'Update user lastondate session
		session("laston") = site_time
		response.cookies(site_name)("read") = "r"
		
		'Set redirect URL to new  new topic.
		strRedirectURL = "displaytopic.asp?T=" & strTopicID & "#last"

	end if
	
	if request.form("method") = "reply" then		
		'Insert post
		set rsPost = server.createobject("adodb.recordset")
		sqlPost = "SELECT * FROM Forum_Posts;"
		rsPost.cursortype = 2
		rsPost.locktype = 3
		rsPost.open sqlPost, adoConn, CMDText
		rsPost.addnew
		rsPost("Post_Topic_ID") = strTopicID
		rsPost("Post_Forum_ID") = strForumID
		rsPost("Post_Category_ID") = strCategoryID
		rsPost("Post_User_ID") = strUserID
		rsPost("Post_Time") = Site_Time
		rsPost("Post_IP") = strIPAddress
		rsPost("Post_Signature") = strSignature
		rsPost("Post_Title") = strTitle
		rsPost("Post_Text") = strText
		rsPost("Post_Index") = 0
		rsPost.update
		rsPost.close
		set rsPost = nothing
		
		'Update topic details
		set rsTopic = server.createobject("adodb.recordset")
		sqlTopic = "SELECT Topic_Last_User_ID, Topic_Replies, Topic_Time FROM Forum_Topics WHERE Topic_ID = "& strTopicID &";"
		rsTopic.cursortype = 2
		rsTopic.locktype = 3
		rsTopic.open sqlTopic, adoConn, CMDText
		rsTopic("Topic_Last_User_ID") = strUserID
		Replies = rsTopic("Topic_Replies") + 1
		rsTopic("Topic_Replies") = rsTopic("Topic_Replies") + 1
		rsTopic("Topic_Time") = Site_Time
		rsTopic.update
		rsTopic.close
		set rsTopic = nothing
		
		Pages = Replies/Site_View_Posts
		if (Replies) mod Site_View_Posts > 0 then
			Pages = Pages + 1
		end if
		Pages = int(Pages)
				
		'Update users details
		set rsUser = server.createobject("adodb.recordset")
		sqlUser = "SELECT User_Posts, User_Last_Post FROM Forum_Users WHERE User_ID = "& strUserID &""
		rsUser.cursortype = 2
		rsUser.locktype = 3
		rsUser.open sqlUser, adoConn, CMDText
		rsUser("User_Posts") = rsUser("User_Posts") + 1
		rsUser("User_Last_Post") = Site_Time
		rsUser.update
		rsUser.close
		set rsUser = nothing
		
		'Update forum table
		set rsForum = server.createobject("adodb.recordset")
		sqlForum = "SELECT Forum_Posts, Forum_Topic_ID, Forum_Post_Date, Forum_User_ID, Forum_User_Name FROM Forum_Forums WHERE Forum_ID = "& strForumID &";"
		rsForum.cursortype = 2
		rsForum.locktype = 3
		rsForum.open sqlForum, adoConn, CMDText
		rsForum("Forum_Posts") = rsForum("Forum_Posts") + 1
		rsForum("Forum_Topic_ID") = strTopicID
		rsForum("Forum_Post_Date") = Site_Time
		rsForum("Forum_User_ID") = strUserID
		rsForum("Forum_User_Name") = strUserName
		rsForum.update
		rsForum.close
		set rsForum = nothing
		
		'Update Stats
		set rsStats = server.createobject("adodb.recordset")
		sqlStats = "SELECT Stats_Topics, Stats_Posts FROM Forum_Stats;"
		rsStats.cursortype = 2
		rsStats.locktype = 3
		rsStats.open sqlStats, adoConn, CMDText
		rsStats("Stats_Posts") = rsStats("Stats_Posts") + 1
		rsStats.update
		rsStats.close
		set rsStats = nothing
		
		'Update user lastondate session
		session("laston") = site_time
		response.cookies(site_name)("read") = "r"
		
		'Set redirect UTL.
		strRedirectURL = "displaytopic.asp?T=" & strTopicID & "&P=" & Pages & "#last"

	end if
	
	if Pages = "" then Pages = 1
	'Display Confirmation strMessage
	%>
	<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
		<td align="center">
		<table border="0" cellpadding="3" cellspacing="1" align="center" class="main">
			<tr valign="middle" class="title">
			<td align="center"><%=Site_Name%> // Message Posted</td>
			</tr>
			<tr valign="top" class="body">
			<td align="center">
			Your message has been successfully posted. Please click <a href="displaytopic.asp?T=<%=strTopicID%>&P=<%=Pages%>#last">here</a> if you are not redirected within 5 seconds.
			</td>
			</tr>
		</table>
		</td>
		</tr>
	</table>
	<META HTTP-EQUIV="Refresh" CONTENT="5; URL=<%=strRedirectURL%>">
	<%
end if
%>

</body>
</html>

⌨️ 快捷键说明

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