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

📄 showthread.asp

📁 很好的一个论坛原代码
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<!--#INCLUDE FILE="inc/db_inc.asp"-->
<!--#INCLUDE FILE="inc/char_inc.asp"-->
<!--#INCLUDE FILE="inc/xbcode_inc.asp"-->
<!--#INCLUDE FILE="header.asp"-->
<!--#INCLUDE FILE="user.asp"-->
<%
dim ip, strip, killip
dim StrSql, rs2, toptext, StrHtml, StrHtml2, StrHtml3, err, pagecount
dim threadtitle, threadid, forumid, forumtitle, userid

error = ""
threadtitle = ""

if request("postid") = "" and request("threadid") = "" then
	err = true
	error = error & "<br><li>" & loadtemplate("err_url")
else
	if request("threadid") <> "" then
	
		' 检测threadid是否合法
		err = false
		threadid = ChkSql(request("threadid"))
		if not IsNumeric(threadid) then
			err = true
		else
			postid = -1
		end if
		if err then error = error & "<br><li>" & loadtemplate("err_threadnotexist")
	else
		' 检测postid是否合法
		err = false
		postid = ChkSql(request("postid"))
		if not IsNumeric(postid) then
			err = true
		else
			StrSql = "select * from sf_post where postid = " & postid
			Set rs2 = Conn.Execute(StrSql)
			if rs2.bof or rs2.eof then
				err = true
			else
				posttitle = rs2("title")
				threadid = rs2("threadid")
			end if
		end if
		if err then error = error & "<br><li>" & loadtemplate("err_postnotexist")
	end if
end if

if not err then
	StrSql = "select top 1 * from sf_thread where threadid = " & threadid
	Set rs2 = Conn.Execute(StrSql)
	if rs2.bof or rs2.eof then
		err = true
	else
		forumid = rs2("forumid")
		if request("goto") <> "" then
			if request("goto") = "prev" then
				StrSql = "select top 1 * from sf_thread where forumid = " & forumid & " and threadid < " & threadid & " order by threadid DESC"
			else
				StrSql = "select top 1 * from sf_thread where forumid = " & forumid & " and threadid > " & threadid & " order by threadid ASC"
			end if
			Set rs2 = Conn.Execute(StrSql)
			
		end if
		if not (rs2.bof or rs2.eof) then
			threadid = rs2("threadid")
			forumid = rs2("forumid")
			threadrating = rs2("rating")
			threadtitle = rs2("title")
			if threadrating > 0 then
			threadtitle = threadtitle & "(" & Replace(loadtemplate("hint_threadrating"), "{rating}", threadrating) & ")"
			end if
			pollid = rs2("pollid")
			open = rs2("open")
			' StrHtml3为帖子列表顶部
			StrHtml3 = loadtemplate("threadtop")
			StrHtml3 = Replace(StrHtml3, "{newmsg_info}", newmsginfo)
			StrHtml3 = Replace(StrHtml3, "{post_num}", rs2("replycount"))
			StrHtml3 = Replace(StrHtml3, "{hits_num}", rs2("views") + 1)
			StrHtml3 = Replace(StrHtml3, "{thread_title}", threadtitle)
			if open =1 then
				StrHtml3 = Replace(StrHtml3, "{btn_text}", "<a href=""newthread.asp?forumid=" & forumid & """><img src=""image/default/newthread.gif""  border=""0"" alt=""" & loadtemplate("newthreadtitle") & """></a>" & "&nbsp; " & "<a href=""newvote.asp?forumid=" & forumid & """><img src=""image/default/newvote.gif""  border=0 alt=""" & loadtemplate("newvotetitle") & """></a>&nbsp; <a href=""newreply.asp?threadid=" & threadid & """><img src=""image/default/newreply.gif""  border=0 alt=""" & loadtemplate("newreplytitle") & """></a>")
			else
				StrHtml3 = Replace(StrHtml3, "{btn_text}", "<a href=""newthread.asp?forumid=" & forumid & """><img src=""image/default/newthread.gif""  border=""0"" alt=""" & loadtemplate("newthreadtitle") & """></a>" & "&nbsp; " & "<a href=""newvote.asp?forumid=" & forumid & """><img src=""image/default/newvote.gif""  border=0 alt=""" & loadtemplate("newvotetitle") & """></a>")
			end if
			StrHtml3 = Replace(StrHtml3, "{view_text}", "<a href=""showthread.asp?threadid=" & threadid & "&goto=prev"" style=""color:#FFFFFF"">" & loadtemplate("threadprevtitle") & "</a>&nbsp;|&nbsp;<a href=""showthread.asp?threadid=" & threadid & "&goto=next"" style=""color:#FFFFFF"">" & loadtemplate("threadnexttitle") & "</a>")
			StrSql = "update sf_thread set views = views + 1 where threadid = " & threadid
			Set rs2 = Conn.Execute(StrSql)
		else
			err = true
		end if
	end if
	if err then error = error & "<br><li>" & loadtemplate("err_threadnotexist")
end if
if not err then
' 检测forumid是否合法
	err = false
	if not IsNumeric(forumid) then
		err = true
	else
		StrSql = "select sf_forum.forumid, sf_forum.title, sf_forum.allowposting, sf_forum.allowimages, sf_forum.allowbbcode, sf_forum.onlyuser, sf_forum.onlymember, sf_forum.memberlist, sf_forum.cateid, sf_cate.catetitle from sf_forum left join sf_cate on sf_forum.cateid = sf_cate.cateid where forumid = " & forumid
		Set rs2 = Conn.Execute(StrSql)
		if rs2.bof or rs2.eof then
			err = true
		else
			forumtitle = rs2("title")
			cateid = rs2("cateid")
			catetitle = rs2("catetitle")
			allowpost = rs2("allowposting")
			if rs2("allowbbcode") = 1 then
				allowbbcode = true
			else
				allowbbcode = false
			end if
			if rs2("allowimages") = 1 then
				allowimages = true
			else
				allowimages = false
			end if
			onlyuser = rs2("onlyuser")
			onlymember = rs2("onlymember")
			memberlist = rs2("memberlist")
			if request.cookies("sf")("username") = "" or request.cookies("sf")("password") = "" then
				if onlyuser = 1 then error = error & "<br><li>" & loadtemplate("err_unregistered")
			else
				' 检测密码...
				StrSql = "select password, userid, rating from sf_user where username = '" & ChkSql(request.cookies("sf")("username")) & "'"
				Set rs2 = Conn.Execute(StrSql)
				err = false
				if rs2.bof or rs2.eof then
					err = true
				else
					if request.cookies("sf")("password") <> rs2("password") then
						err = true
					else
						userrating = rs2("rating")
						userid = rs2("userid")
						StrSql = "update sf_user set lastactivity = '" & now() & "' where userid = " & userid
						Conn.Execute(StrSql)
						StrSql = "select * from sf_moderator where userid = " & rs2("userid") & "and (forumid = " & forumid & " or super = 1 or isadmin = 1)"
						Set rs2 = Conn.Execute(StrSql)
						'如果是斑竹userinfo=2
						if not(rs2.bof or rs2.eof) then
							userinfo = 2
						end if
					end if
				end if
				if err then error = error & "<br><li>" & loadtemplate("err_chkpassword")
			end if
			if onlymember = 1 then
				if not IsMember(forumid, memberlist) then error = error & "<br><li>" & loadtemplate("err_member")
				StrSql = "select password, userid from sf_user where username = '" & ChkSql(request.cookies("sf")("username")) & "'"
				Set rs2 = Conn.Execute(StrSql)
				if rs2.bof or rs2.eof then
					error = error & "<br><li>" & loadtemplate("err_chkpassword")
				else
					if request.cookies("sf")("password") <> rs2("password") then error = error & loadtemplate("err_chkpassword")
				end if
			end if

		end if
	end if
	if err then error = error & "<br><li>" & loadtemplate("err_forumnotexist")
end if

StrHtml = loadtemplate("htmltop")

StrHtml = Replace(StrHtml, "{pagetitle}", left(threadtitle, 20))
StrHtml = Replace(StrHtml, "{forumtitle}", boardtitle)
response.write StrHtml
' 短消息提示
response.write newmsg
StrHtml = loadtemplate("pagetitle")
if request.cookies("sf")("username") = "" then
	toptext = loadtemplate("toptextguest")
else
	toptext = loadtemplate("toptextuser")
end if
toptext = toptext & loadtemplate("toptext")
StrHtml = Replace(StrHtml, "{top_text}", toptext)
StrHtml = Replace(StrHtml, "{username}", request.cookies("sf")("username"))
response.write StrHtml

' 论坛关闭
StrSql = "select * from sf_setup"
Set rs2 = Conn.Execute(StrSql)
if rs2("forumclose") = 1 then
StrHtml = loadtemplate("error")
StrHtml = Replace(StrHtml, "{error_text}", rs2("forumclosehint"))
response.write StrHtml
response.end
end if	

' 禁止IP访问
if rs2("killip") = 1 then
	userip = cstr(request.ServerVariables("REMOTE_ADDR"))
	killiplist = rs2("killiplist")
	if killiplist <> "" and userip <> "" then
		killip = split(killiplist, "|")
		struserip = split(userip, ".")
		i = 0
		do until i > ubound(killip)
			strkillip = split(killip(i), ".")
			bolkill = true
			if (struserip(0) <> strkillip(0)) and (strkillip(0) <> "*") then bolkill = false
			if (struserip(1) <> strkillip(1)) and (strkillip(1) <> "*") then bolkill = false
			if (struserip(2) <> strkillip(2)) and (strkillip(2) <> "*") then bolkill = false
			if (struserip(3) <> strkillip(3)) and (strkillip(3) <> "*") then bolkill = false
			if bolkill then
				StrHtml = loadtemplate("error")
				StrHtml = Replace(StrHtml, "{error_text}", rs2("killiphint"))
				response.write StrHtml
				Response.End
			end if
			i = i + 1
		loop
	end if
end if

if threadrating > 0 and userinfo < 2 then
	if userrating < threadrating then error = error & "<br><li>" & Replace(loadtemplate("err_threadrating"), "{rating}", threadrating)
end if

' 如果有错误则提示
if error <> "" then
	StrHtml = loadtemplate("error")
	StrHtml = Replace(StrHtml, "{error_text}", error)
	response.write StrHtml
	response.end
end if

' 显示当前页面路径
StrHtml = loadtemplate("pagepath")
StrHtml = Replace(StrHtml, "{path_text}", "<a href=""index.asp"">" & boardtitle & "</a> &raquo; <a href=""showcate.asp?cateid=" & cateid & """>" & catetitle & "</a> &raquo; <a href=""showforum.asp?forumid=" & forumid & """>" & forumtitle & "</a> &raquo; "& threadtitle)
response.write StrHtml

' 短消息提示
if newmsgnum > 0 then
StrHtml = loadtemplate("newmsg")
StrHtml2 = StrHtml
StrHtml2 = Replace(StrHtml2, "{newmsg_num}", newmsgnum)
i = cint(request.cookies("sf")("userid"))
Set rs = Conn.Execute("select top 1 sf_privatemessage.*, sf_user.username from (sf_privatemessage left join sf_user on sf_privatemessage.fromuserid = sf_user.userid) where sf_privatemessage.folderid = 0 and sf_privatemessage.messageread = 0 and sf_privatemessage.userid = " & i)
if not (rs.bof or rs.eof) then
		StrHtml2 = Replace(StrHtml2, "{subject}", "<a href=""showmessage.asp?action=showinbox&msgid=" & rs("privatemessageid") & """ title=""" & rs("message") & """>" & rs("title") & "</a>")
		StrHtml2 = Replace(StrHtml2, "{username}", "<a href=""showuser.asp?userid=" & rs("fromuserid") & """>" & rs("username") & "</a>")
		StrHtml2 = Replace(StrHtml2, "{time}", rs("dateline"))
end if
rs.close
response.write StrHtml2
end if

' 论坛跳转
response.write "<script language=JavaScript>" & chr(10)
response.write "function goforum(strgoforum) {" & chr(10)
response.write "location.replace(strgoforum)" & chr(10)
response.write "}"
response.write "</script>"

' 显示帖子列表头
response.write StrHtml3

page = request("page")

' 获得当前页数
if page = "" then
	page = 1
else
	if not IsNumeric(page) then
		page = 1
	else
		page = clng(page)
	end if
end if

' 帖子列表
rs2.Close
pagecount = 1
StrHtml = loadtemplate("thread")
Strattachment = loadtemplate("hint_attachment")
StrSql = "select sf_post.*, sf_user.* from sf_post left join sf_user on (sf_post.userid = sf_user.userid) where"
if postid <> -1 then
	StrSql = StrSql & " sf_post.postid = " & postid
else
	StrSql = StrSql & " sf_post.threadid = " & threadid
end if
Strsql = StrSql & " order by sf_post.postid ASC"
Set rs2 = server.CreateObject("ADODB.RecordSet")
rs2.Open StrSql, Conn, 1, 1
if rs2.bof or rs2.eof then
	StrHtml = loadtemplate("error")
	StrHtml = Replace(StrHtml, "{error_text}", loadtemplate("err_url"))
	response.write StrHtml
	response.end
else
	'如果是投票
	if pollid <> -1 then
		StrSql = "select * from sf_poll where pollid = " & pollid
		Set rs3 = Conn.Execute(StrSql)
		if rs3.bof or rs3.eof then

⌨️ 快捷键说明

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