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

📄 copythread.asp

📁 很好的一个论坛原代码
💻 ASP
字号:
<!--#INCLUDE FILE="inc/db_inc.asp"-->
<!--#INCLUDE FILE="inc/char_inc.asp"-->
<!--#INCLUDE FILE="inc/xbcode_inc.asp"-->
<!--#INCLUDE FILE="header.asp"-->
<%
dim ip, strip, killip
dim StrSql, toptext, rs, rs2, StrHtml, StrHtml2, error, err, userid, threadid, threadtitle, postid, posttitle

StrHtml = loadtemplate("htmltop")
StrHtml = Replace(StrHtml, "{pagetitle}", loadtemplate("hint_selectoperate"))
StrHtml = Replace(StrHtml, "{forumtitle}", boardtitle)
response.write StrHtml
StrHtml = loadtemplate("pagetitle")
if request.cookies("sf")("username") = "" then
	toptext = loadtemplate("toptextguest")&toptext
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

' 检测threadid是否合法
threadid = ChkSql(request("threadid"))
err = false
if not IsNumeric(threadid) then
	err = true
else
	StrSql = "select * from sf_thread where threadid = " & threadid
	Set rs2 = Conn.Execute(StrSql)
	if rs2.bof or rs2.eof then
		err = true
	else
		threadtitle = rs2("title")
		forumid = rs2("forumid")
	end if
end if

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

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

' 如果未注册或未登录...
if request.cookies("sf")("username") = "" or request.cookies("sf")("password") = "" then
	StrHtml = loadtemplate("error")
	StrHtml = Replace(StrHtml, "{error_text}", loadtemplate("err_unregistered"))
	response.write StrHtml
	response.end		
end if

' 检测密码...
error = ""
userinfo = 0
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 = loadtemplate("err_chkpassword")
else
	if request.cookies("sf")("password") <> rs2("password") then
		error = loadtemplate("err_chkpassword")
	else
		' 如果是帖子原作者userinfo=1
		if userid = rs2("userid") then
			userinfo = 1
		else
			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 rs2.bof or rs2.eof then
				error = loadtemplate("err_purview")
			else
				userinfo = 2
				if rs2("isadmin") = 1 then userinfo = 3
			end if
		end if
	end if
end if

' 检测forumid是否合法
err = false
StrSql = "select sf_forum.forumid, sf_forum.title, sf_forum.allowposting, sf_forum.canmove, sf_forum.onlyuser, sf_forum.onlymember, sf_forum.memberlist, sf_forum.cateid, sf_cate.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")
	canmove = rs2("canmove")
	onlymember = rs2("onlymember")
	memberlist = rs2("memberlist")
	' 如果只允许内部成员访问...
	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

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

if (canmove = 0) and (userinfo <> 3) then error = error & "<br><li>" & forumtitle & "-" & loadtemplate("err_purview")

' 检测toforumid是否合法
toforumid = ChkSql(request("toforumid"))
if request("step") <> "" then
	err = false
	if not IsNumeric(toforumid) then
		err = true
	else
		StrSql = "select * from sf_forum where forumid = " & toforumid
		Set rs2 = Conn.Execute(StrSql)
		if rs2.bof or rs2.eof then
			err = true
		else
			forumtitle = rs2("title")
			allowpost = rs2("allowposting")
			onlymember = rs2("onlymember")
			memberlist = rs2("memberlist")
			' 如果只允许内部成员访问...
			if onlymember = 1 then
				if not IsMember(forumid, memberlist) then error = error & "<br><li>" & forumtitle & " - " & 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>" & forumtitle & " - " & loadtemplate("err_forumnotexist")
if (allowpost = 0) and (userinfo <> 3) then error = error & "<br><li>" & forumtitle & " - " & loadtemplate("err_post")
end if


if error <> "" or userinfo < 2 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; " & loadtemplate("hint_selectoperate"))
response.write StrHtml

step = ChkSql(request("step"))
action = ChkSql(request("action"))
select case step
	case "2"
		select case action
			case "copy"
				' 复制
				StrSql = "select * from sf_thread where threadid = " & threadid
				Set rs2 = Conn.Execute(StrSql)
				StrSql = "insert into sf_thread (title, lastpost, forumid, pollid, displayorder, [open], best, replycount, postusername, postuserid, lastposterid, lastposter, dateline, views, iconid, rating) values("
				StrSql = StrSql & "'" & ChkSql(rs2("title")) & "', '" & rs2("lastpost") & "', " & toforumid & ", " & rs2("pollid") & ", 0, " & rs2("open") & ", " & rs2("best") & ", " & rs2("replycount") & ", '" & ChkSql(rs2("postusername")) & "', " & rs2("postuserid") & ", " & rs2("lastposterid") & ", '" & ChkSql(rs2("lastposter")) & "', '" & rs2("dateline") & "', " & rs2("views") & ", " & rs2("iconid") & ", " & rs2("rating") & ")"
				Conn.Execute(StrSql)
				StrSql = "select threadid from sf_thread where title = '" & rs2("title") & "' order by threadid DESC"
				Set rs2 = Conn.Execute(StrSql)
				tothreadid = rs2("threadid")
				StrSql = "select * from sf_post where threadid = " & threadid	
				Set rs2 = Conn.Execute(StrSql)
				i = 0
				if not (rs2.bof or rs2.eof) then
					do until rs2.eof
						i = i + 1
						StrSql = "insert into sf_post (forumid, threadid, parentid, username, userid, title, dateline, pagetext, allowsmilie, allowxbcode, allowautourl, showsignature, ipaddress, iconid, layer, notes, attachmentid) values("
						pagetext =  ChkSql(rs2("pagetext"))
						StrSql = StrSql & toforumid & "," & tothreadid & ", " & rs2("parentid") & ", '" & ChkSql(rs2("username")) & "', " & rs2("userid") & ", '" & ChkSql(rs2("title")) & "', '" & rs2("dateline") & "', '" & pagetext & "', " & rs2("allowsmilie") & ", " & rs2("allowxbcode") & ", " & rs2("allowautourl") & ", " & rs2("showsignature") & ", '" & rs2("ipaddress") & "', " & rs2("iconid") & ", " & rs2("layer") & ", '" & rs2("notes") & "'," & rs2("attachmentid") & ")"
						Conn.execute(StrSql)
						rs2.MoveNext
					loop
				end if

				' 更新统计
				StrSql = "update sf_forum set threadcount = threadcount + 1, postcount = postcount + " & i & " where forumid = " & toforumid
				Conn.Execute(StrSql)
				StrHtml = loadtemplate("hint")
				StrHtml = Replace(StrHtml, "{hint_text}", loadtemplate("hint_threadcopy"))
				StrHtml = Replace(StrHtml, "{pro_name}", "showforum.asp?forumid=" & forumid)
				response.write StrHtml
			case "move"
				' 移动
				Conn.execute("update sf_thread set forumid = " & toforumid & " where threadid = " & threadid)
				Conn.execute("update sf_post set forumid = " & toforumid & " where threadid = " & threadid)
				Set rs2 = Conn.Execute(StrSql)
				i = 0
				if not (rs2.bof or rs2.eof) then
					do until rs2.eof
						i = i + 1
						rs2.MoveNext
					loop
				end if
				' 更新统计
				StrSql = "update sf_forum set threadcount = threadcount - 1, postcount = postcount - " & i & " where forumid = " & forumid
				Conn.Execute(StrSql)
				StrSql = "update sf_forum set threadcount = threadcount + 1, postcount = postcount + " & i & " where forumid = " & toforumid
				Conn.Execute(StrSql)
				StrHtml = loadtemplate("hint")
				StrHtml = Replace(StrHtml, "{hint_text}", loadtemplate("hint_threadmove"))
				StrHtml = Replace(StrHtml, "{pro_name}", "showforum.asp?forumid=" & forumid)
				response.write StrHtml
		end select
	case else
		StrHtml = loadtemplate("copythread")
		StrHtml = Replace(StrHtml, "{title}", threadtitle)
		StrHtml2 = "<select name=""toforumid"">" & chr(10)
		StrSql = "select sf_forum.forumid, sf_forum.cateid, sf_forum.title, sf_cate.catetitle from sf_forum left join sf_cate on (sf_forum.cateid = sf_cate.cateid) where sf_cate.displayorder>0 and sf_forum.displayorder>0 order by sf_cate.displayorder DESC, sf_cate.cateid ASC, sf_forum.displayorder DESC, sf_forum.forumid ASC"
		Set rs2 = Conn.Execute(StrSql)
		nowcateid = -1
		if not (rs2.bof or rs2.eof) then
			do until rs2.eof
				if nowcateid <> rs2("cateid") then
					nowcateid = rs2("cateid")
					StrHtml2 = StrHtml2 & "<option value=""-1""> &raquo; " & rs2("catetitle") & "</option>" & chr(10)
				end if
				StrHtml2 = StrHtml2 & "<option value=""" & rs2("forumid") & """>&nbsp;" & rs2("title") & "</option>" & chr(10)
				rs2.MoveNext
			loop
		end if
		StrHtml2 = StrHtml2 & "</select>" & chr(10)
		StrHtml = Replace(StrHtml, "{forum_select}", StrHtml2)

		if action = "copy" then
			StrHtml = Replace(StrHtml, "{action_text}", loadtemplate("threadcopy"))
			StrHtml = Replace(StrHtml, "{hidden_field}", "<input type=""hidden"" name=""action"" value=""copy""><input type=""hidden"" name=""threadid"" value=""" & threadid &""">")
		else
			StrHtml = Replace(StrHtml, "{action_text}", loadtemplate("threadmove"))
			StrHtml = Replace(StrHtml, "{hidden_field}", "<input type=""hidden"" name=""action"" value=""move""><input type=""hidden"" name=""threadid"" value=""" & threadid &""">")
		end if
		response.write StrHtml
end select

response.write loadtemplate("htmlbottom")
Conn.Close
Set Conn = nothing
Set rs = nothing
Set rs2 = nothing
set ip = nothing
set strip = nothing
set killip = nothing
%>

⌨️ 快捷键说明

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