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

📄 new_post.asp

📁 简单的asp论坛源码系统,很适用于初学者!界面简洁,功能齐全
💻 ASP
📖 第 1 页 / 共 3 页
字号:
<% @ Language=VBScript %>
<% Option Explicit %>
<!--#include file="common.asp" -->
<!--#include file="functions/functions_send_mail.asp" -->
<!--#include file="functions/functions_format_post.asp"	-->
<!--#include file="includes/emoticons_inc.asp" -->
<%
'****************************************************************************************
'**  Copyright Notice    
'**
'**  Web Wiz Forums(TM)
'**  http://www.webwizforums.com
'**                            
'**  Copyright (C)2001-2008 Web Wiz(TM). All Rights Reserved.
'**  
'**  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS UNDER LICENSE FROM 'WEB WIZ'.
'**  
'**  IF YOU DO NOT AGREE TO THE LICENSE AGREEMENT THEN 'WEB WIZ' IS UNWILLING TO LICENSE 
'**  THE SOFTWARE TO YOU, AND YOU SHOULD DESTROY ALL COPIES YOU HOLD OF 'WEB WIZ' SOFTWARE
'**  AND DERIVATIVE WORKS IMMEDIATELY.
'**  
'**  If you have not received a copy of the license with this work then a copy of the latest
'**  license contract can be found at:-
'**
'**  http://www.webwizguide.com/license
'**
'**  For more information about this software and for licensing information please contact
'**  'Web Wiz' at the address and website below:-
'**
'**  Web Wiz, Unit 10E, Dawkins Road Industrial Estate, Poole, Dorset, BH15 4JD, England
'**  http://www.webwizguide.com
'**
'**  Removal or modification of this copyright notice will violate the license contract.
'**
'****************************************************************************************



'*************************** SOFTWARE AND CODE MODIFICATIONS **************************** 
'**
'** MODIFICATION OF THE FREE EDITIONS OF THIS SOFTWARE IS A VIOLATION OF THE LICENSE  
'** AGREEMENT AND IS STRICTLY PROHIBITED
'**
'** If you wish to modify any part of this software a license must be purchased
'**
'****************************************************************************************




'Set the response buffer to true as we maybe redirecting
Response.Buffer	= True


'Dimension variables
Dim lngNumOfPosts		'Holds the number of posts a user has made
Dim blnEmailNotify		'Set to	true if	the users want to be notified by e-mail	of a post
Dim blnEmailSent		'Set to	true if	the e-mail is sent
Dim strEmailSubject		'Holds the subject of the e-mail
Dim strMessage			'Holds the Users Message
Dim lngMessageID		'Holds the message ID number
Dim strMode			'Holds the mode	of the page so we know whether we are editing, updating, or new	topic
Dim lngTopicID			'Holds the topic ID number
Dim strSubject			'Holds the subject
Dim strPostDateTime		'Holds the current date	and time for the post
Dim strUserName			'Holds the username of the person we are going to email
Dim lngEmailUserID		'Holds the users ID of the person we are going to email
Dim strUserEmail		'Holds the users e-mail	address
Dim strEmailMessage		'Holds the body	of the e-mail
Dim blnSignature		'Holds wether a	signature is to	be shown or not
Dim intPriority			'Holds the priority of tipics
Dim strPostMessage		'Holds the post	to send	as mail	notify
Dim intReturnPageNum		'Holds the page	number to return to
Dim strForumName		'Holds the name	of the forum the message is being posted in
Dim intNumOfPostsInFiveMin	'Holds the number of posts the user has	made in	the last 5 minutes
Dim strReturnCode		'Holds the code	if the post is not valid and we	need to	return to forum	without	posting
Dim strPollQuestion		'Holds the poll	question
Dim blnMultipleVotes		'Set to	true if	multiple votes are allowed
Dim blnPollReply		'Set to	true if	users can't reply to a poll
Dim saryPollChoice()		'Array to hold the poll	choices
Dim intPollChoice		'Holds the poll	choices	loop counter
Dim strBadWord			'Holds the bad words
Dim strBadWordReplace		'Holds the rplacment word for the bad word
Dim lngPollID			'Holds the poll	ID number
Dim blnForumLocked		'Set to true if the forum is locked
Dim blnTopicLocked		'Set to true if the topic is locked
Dim intNewGroupID		'Holds the new group ID for the poster
Dim strGuestName		'Holds the name of the guest if it is a guest posting
Dim intReplyCount		'Holds the number of threads in topic
Dim saryFileUploads		'Holds the names of the files uploaded
Dim objFSO			'Holds the file system object
Dim intLoop			'Loop counter
Dim strTopicIcon		'Holds the topic icon for the message
Dim dtmEventDate		'Holds the Calendar event date
Dim dtmEventDateEnd		'Holds the Calendar event date



'Initalise variables
strPostDateTime	= internationalDateTime(Now())
intNumOfPostsInFiveMin = 0
lngPollID = 0
intReplyCount = 1
blnForumLocked = False
blnTopicLocked = False




'If the	user has not logged in then redirect them to the main forum page
If lngLoggedInUserID = 0 OR blnActiveMember = False OR blnBanned Then
	
	'Clean up
	Call closeDatabase()

	'Redirect
	Response.Redirect("default.asp" & strQsSID1)
End If



'******************************************
'***	      Check IP address		***
'******************************************

'If the	user is	user is	using a	banned IP redirect to an error page
If bannedIP() Then
	
	'Clean up
	Call closeDatabase()

	'Redirect
	Response.Redirect("insufficient_permission.asp?M=IP" & strQsSID3)

End If






'******************************************
'***	  Read in form details		***
'******************************************

'Read in user deatils from the post message form
strMode	= Trim(Mid(Request.Form("mode"), 1, 10))
intForumID = CInt(Request.Form("FID"))
lngTopicID = CLng(Request.Form("TID"))
strSubject = Trim(Mid(Request.Form("subject"), 1, 50))
strMessage = Request.Form("Message")
lngMessageID = CLng(Request.Form("PID"))
blnEmailNotify = CBool(Request.Form("email"))
blnSignature = CBool(Request.Form("signature"))
intPriority = CInt(Request.Form("priority"))
strTopicIcon =  Request.Form("icon")
'If the user is in a guest then get the Guest name they have entered
If lngLoggedInUserID = 2 Then strGuestName = Trim(Mid(Request.Form("Gname"), 1, 20))
	
'Read in event start date
If Request.Form("eventDay") <> 0 AND Request.Form("eventMonth") <> 0 AND Request.Form("eventYear") <> 0 Then
	dtmEventDate = internationalDateTime(DateSerial(Request.Form("eventYear"), Request.Form("eventMonth"), Request.Form("eventDay")))
End If

'Read in event end date
If Request.Form("eventDayEnd") <> 0 AND Request.Form("eventMonthEnd") <> 0 AND Request.Form("eventYearEnd") <> 0 Then
	dtmEventDateEnd = internationalDateTime(DateSerial(Request.Form("eventYearEnd"), Request.Form("eventMonthEnd"), Request.Form("eventDayEnd")))
	
	'If the end date is before the start date don't add it to the database
	If dtmEventDate => dtmEventDateEnd OR dtmEventDate = "" Then dtmEventDateEnd = null
End If









'******************************************
'***	  Check CAPTCHA for Guest	***
'******************************************

'If this is a Guest poster and CAPTCHA is enabled check CAPTCHA is enetered correctly
If blnGuestPostingCAPTCHA AND lngLoggedInUserID = 2 Then
	
	'If CAPTCHA security image not enetered corectly kick the user
	If LCase(getSessionItem("SCS")) <> LCase(Trim(Request.Form("securityCode"))) OR getSessionItem("SCS") = "" Then 
		
		'Distroy session variable
		Call saveSessionItem("SCS", "")
		
		'Clean up
		Call closeDatabase()
	
		'Redirect
		If strMode = "new" Then
			Response.Redirect("not_posted.asp?mode=CAPTCHA" & strQsSID3)
		Else
			Response.Redirect("not_posted.asp?mode=CAPTCHA&TID=" & lngTopicID & strQsSID3)
		End If
		
	End If
	
	'Distroy session variable
	Call saveSessionItem("SCS", "")
End If





'******************************************
'***	     Get permissions	      *****
'******************************************


'If this is a new topic then only check the forum permissions
If strMode = "new" OR strMode = "poll" Then
	
	'As this is a new topic get the forum permissions
	strSQL = " " & _
	"SELECT" & strDBTop1 & " " & strDbTable & "Forum.Forum_name, " & strDbTable & "Forum.Password, " & strDbTable & "Forum.Forum_code, " & strDbTable & "Forum.Locked AS ForumLocked, " & strDbTable & "Forum.Password, " & strDbTable & "Permissions.* " & _
	"FROM " & strDbTable & "Forum" & strDBNoLock & ", " & strDbTable & "Permissions" & strDBNoLock & " " & _
	"WHERE " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Permissions.Forum_ID " & _
		"AND " & strDbTable & "Forum.Forum_ID = " & intForumID & " " & _
		"AND (" & strDbTable & "Permissions.Author_ID = " & lngLoggedInUserID & " OR " & strDbTable & "Permissions.Group_ID = " & intGroupID & ") " & _
	"ORDER BY " & strDbTable & "Permissions.Author_ID DESC" & strDBLimit1 & ";"
	
	'Query the database
	rsCommon.Open strSQL, adoCon

'Else if this is a reply in a topic check if the topic is locked also and get the forum ID from the topic that is being posted in
Else


	'As this is a reply in a topic get the forum permissions from the topic being posted in and also check if the topic is locked
	strSQL = " " & _
	"SELECT" & strDBTop1 & " " & strDbTable & "Forum.Forum_name, " & strDbTable & "Forum.Password, " & strDbTable & "Forum.Forum_code, " & strDbTable & "Forum.Locked AS ForumLocked, " & strDbTable & "Forum.Password, " & strDbTable & "Topic.Subject, " & strDbTable & "Topic.Locked AS TopicLocked, " & strDbTable & "Permissions.* " & _
	"FROM " & strDbTable & "Forum" & strDBNoLock & ", " & strDbTable & "Topic" & strDBNoLock & ", " & strDbTable & "Permissions" & strDBNoLock & " " & _
	"WHERE  " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Topic.Forum_ID " & _
		"AND " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Permissions.Forum_ID " & _
		"AND " & strDbTable & "Topic.Topic_ID = " & lngTopicID & " " & _
		"AND (" & strDbTable & "Permissions.Author_ID = " & lngLoggedInUserID & " OR " & strDbTable & "Permissions.Group_ID = " & intGroupID & ") " & _
	"ORDER BY " & strDbTable & "Permissions.Author_ID DESC" & strDBLimit1 & ";"
	
	'Query the database
	rsCommon.Open strSQL, adoCon
	
	'Read in some extra details as this is a reply
	If NOT rsCommon.EOF Then
		intForumID = CInt(rsCommon("Forum_ID"))
		strSubject = rsCommon("Subject")
		If blnAdmin = False Then blnTopicLocked = CBool(rsCommon("TopicLocked"))
	End If
End If


'Check the forum permissions
If NOT rsCommon.EOF Then

	strForumName = rsCommon("Forum_name")
	
	'See if the forum is locked if this is not the admin
	If blnAdmin = False Then blnForumLocked = CBool(rsCommon("ForumLocked"))

	'Read in the forum permissions
	blnRead = CBool(rsCommon("View_Forum"))
	blnPost = CBool(rsCommon("Post"))
	blnReply = CBool(rsCommon("Reply_posts"))
	blnEdit = CBool(rsCommon("Edit_posts"))
	blnPriority = CBool(rsCommon("Priority_posts"))
	blnPollCreate = CBool(rsCommon("Poll_create"))
	blnModerator = CBool(rsCommon("Moderate"))
	blnCheckFirst = CBool(rsCommon("Display_post"))
	blnEvents = CBool(rsCommon("Calendar_event"))
	
	'If the user has no read rights then kick them
	If blnRead = False Then
		
		'Reset Server Objects
		rsCommon.Close
		Call closeDatabase()

		'Kick the user
		Response.Redirect("insufficient_permission.asp" & strQsSID1)
	End If


	'If the forum requires a password and a logged in forum code is not found on the users machine then send them to a login page
	If rsCommon("Password") <> "" AND (getCookie("fID", "Forum" & intForumID) <> rsCommon("Forum_code") AND getSessionItem("Forum" & intForumID) <> rsCommon("Forum_code")) Then

		'Reset Server Objects
		rsCommon.Close
		Call closeDatabase()
		
		'Redirect to a page asking for the user to enter the forum password
		Response.Redirect("forum_password_form.asp?FID=" & intForumID & strQsSID3)
	End If
	
	
	'If this is the admin or moderator then set the post to be displayed
	If blnAdmin OR blnModerator Then blnCheckFirst = false
		
	'If this in not an admin or moderator set the priority to 0
	If (blnAdmin = false OR blnModerator = false) AND blnPriority = false Then intPriority = 0

End If

'Clean up
rsCommon.Close





'*****************************************************
'***   Redirect if the forum or topic is locked   ****
'*****************************************************

'If the forum or topic is locked then don't let the user post a message
If blnForumLocked OR blnTopicLocked Then

	'Clean up
	Call closeDatabase()

	'Redirect to error page
	If blnForumLocked Then
		Response.Redirect("not_posted.asp?mode=FLocked" & strQsSID3)
	Else
		Response.Redirect("not_posted.asp?mode=TClosed" & strQsSID3)
	End If
End If









'******************************************
'***	 Get return page details      *****
'******************************************

'If there is no	number must be a new post
If Request.Form("PN") = "" Then
	intReturnPageNum = 1
Else
	intReturnPageNum = CInt(Request.Form("PN"))
End If

'calcultae which page the tread	is posted on
If Request.Form("ThreadPos") <> "" Then

	'If the	position in the	topic is on next page add 1 to the return page number
	If CInt(Request.Form("ThreadPos")) > (intThreadsPerPage	* intReturnPageNum) Then
		intReturnPageNum = intReturnPageNum + 1
	End If
End If



'********************************************
'***  Clean up and check in form details  ***
'********************************************

'If there is no	subject	or message then	don't post the message as won't	be able	to link	to it
If strSubject =	"" AND (strMode	= "new" OR strMode = "poll") Then strReturnCode = "noSubject"
If Trim(strMessage) = "" OR Trim(strMessage) = "<P>&nbsp;</P>" OR Trim(strMessage) = "<br>" OR Trim(strMessage) = "<br>" & vbCrLf Then strReturnCode = "noSubject"



'Place format posts posted with	the WYSIWYG Editor (RTE)
If Request.Form("browser") = "RTE" Then

	'Call the function to format WYSIWYG posts

⌨️ 快捷键说明

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