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

📄 forum-forums.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" -->
<%
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>
	
<%
'Admin Check
if session("admin") <> true then
	response.redirect(Site_Forum_URL & "/default.asp")
end if
%>
<table width="100%" height="10" border="0" cellspacing="0" cellpadding="1">
  	<tr valign="top">
    <td width="150">
	<!--#include file="inc-navigation.asp" -->
	</td>
    <td>
	<%
	Action = request.querystring("Action")
	Method = request.querystring("Method")
	Category = int(request.querystring("Category"))
	Deleted = request.form("Delete")
	Forum = int(request.form("ID"))
	New_Category = int(request.form("New_Category"))
	
	if Action = "Submit" then
		'check that the form was submitted from here
		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 = Site_Forum_URL &"/Admin/forum-forums.asp"
		
		if lcase(strReferedBy) <> lcase(strCurrentURL) then
			response.redirect(Site_Forum_URL & "/default.asp")
		end if
		
		if request.form("Title") = "" then strError = "Forum Title"
		
		if strError = "" then
			if Method = "Update" then
				if Deleted = "1" then
				
					'Delete the selected forum
					set rsDelete = server.createobject("adodb.recordset")
					sqlDelete = "SELECT * FROM Forum_Forums WHERE Forum_ID = "& Forum &""
					rsDelete.cursortype = 2
					rsDelete.locktype = 3
					rsDelete.open sqldelete, adoConn, CMDText
					if not (rsDelete.eof or rsDelete.bof) then
						Posts = rsDelete("Forum_Posts")
						Topics = rsDelete("Forum_Topics")
						Order = rsDelete("Forum_Order")
						rsDelete.delete
					end if
					rsDelete.close
					set rsDelete = nothing
					
					'Delete topics that were contained within the specified forum
					set rsDelete = server.createobject("adodb.recordset")
					sqlDelete = "DELETE * FROM Forum_Topics WHERE Topic_Forum_ID = "& Forum &";"
					rsDelete.cursortype = 2
					rsDelete.locktype = 3
					rsDelete.open sqlDelete, adoConn
					set rsDelete = nothing
					
					'Delete posts that were contained within the specified forum
					set rsDelete = server.createobject("adodb.recordset")
					sqlDelete = "DELETE * FROM Forum_Posts WHERE Post_Forum_ID = "& Forum &";"
					rsDelete.cursortype = 2
					rsDelete.locktype = 3
					rsDelete.open sqlDelete, adoConn, CMDText
					set rsDelete = nothing
					
					'Decrement the forum stats
					set rsStats = server.createobject("adodb.recordset")
					sqlStats = "SELECT * FROM Forum_Stats"
					rsStats.cursortype = 2
					rsStats.locktype = 3
					rsStats.open sqlstats, adoConn, CMDText
					rsStats("Stats_Posts") = rsStats("Stats_Posts") - Posts
					rsStats("Stats_Topics") = rsStats("Stats_Topics") - Topics
					rsStats.update
					rsStats.close
					set rsStats = nothing
					
					'Update forum orders
					set rsOrder = server.createobject("adodb.recordset")
					sqlOrder = "UPDATE Forum_Forums SET Forum_Order = (Forum_Order - 1) WHERE Forum_Order > "& Order &" AND Forum_Category_ID = "& request.form("Cat") &";"
					rsOrder.open sqlOrder, adoConn
					set rsOrder = nothing
					
					strHeader = "Success"
					strMessage = "The selected forum has been successfully deleted. If you have deleted a large forum you may wish to re-calculate the forum stats. Please click <a href='"& Site_Forum_URL & "/Admin'>here</a> to return to the Admin homepage"				
				else				
					'Update the selected forum
					set rsUpdate = server.createobject("adodb.recordset")
					sqlUpdate = "SELECT * FROM Forum_Forums WHERE Forum_ID = "& Forum &""
					rsUpdate.cursortype  = 2
					rsUpdate.locktype = 3
					rsUpdate.open sqlUpdate, adoConn, CMDText
					rsUpdate("Forum_Name") = request.form("Title")
					rsUpdate("Forum_Description") = request.form("Desc")
					strOldOrder = rsUpdate("Forum_Order")
					rsUpdate("Forum_Order") = request.form("Order")
					rsUpdate("Forum_Allow_Images") = request.form("Images")
					rsUpdate.update
					rsUpdate.close
					set rsUpdate = nothing
					
					'Update other forums with their new order positions
					set rsOrder = server.createobject("adodb.recordset")
					if int(strOldOrder) < int(request.form("Order")) then
						sqlOrder = "UPDATE Forum_Forums SET Forum_Order = (Forum_Order - 1) WHERE Forum_Order >= "& strOldOrder &" AND Forum_Order <= "& request.form("Order") &" AND Forum_ID <> "& request.form("ID") &" AND Forum_Category_ID = "& request.form("Cat") &";"
					else
						sqlOrder = "UPDATE Forum_Forums SET Forum_Order = (Forum_Order + 1) WHERE Forum_Order >= "& request.form("Order") &" AND Forum_Order <= "& strOldOrder &" AND Forum_ID <> "& request.form("ID") &" AND Forum_Category_ID = "& request.form("Cat") &";"
					end if
					rsOrder.open sqlOrder, adoConn
					set rsOrder = nothing
					
					strHeader = "Success"
					strMessage = "The selected forum has been successfully updated. Please click <a href='"& Site_Forum_URL & "/Admin'>here</a> to return to the Admin homepage."
					
				end if
				
			end if
			
			if Method = "New" then
			
				'Count the number of forums in the selected category
				set rsCount = server.createobject("adodb.recordset")
				sqlCount = "SELECT COUNT(*) AS Cat_Count FROM Forum_Forums WHERE Forum_Category_ID = "& New_Category &";"
				rsCount.open sqlCount, adoConn
				Cat_Count = rsCount("Cat_Count")
				rsCount.close
				set rsCount = nothing
				
				'Add the new forum
				set rsNew = server.createobject("adodb.recordset")
				sqlNew = "SELECT * FROM Forum_Forums"
				rsNew.cursortype = 2
				rsNew.locktype = 3
				rsNew.open sqlNew, adoConn, CMDText
				rsNew.addnew
				rsNew("Forum_Category_ID") = New_Category
				rsNew("Forum_Name") = request.form("Title")
				rsNew("Forum_Description") = request.form("Desc")
				rsNew("Forum_Order") = Cat_Count
				rsNew("Forum_Allow_Images") = request.form("Images")
				rsNew.update
				rsNew.close
				set rsDelete = nothing
				strHeader = "Success"
				strMessage = "The new forum has been successfully added to the database. Please click <a href='"& Site_Forum_URL & "/Admin'>here</a> to return to the Admin homepage."
			end if
		else
			strHeader = "Error"
			strMessage = "Unfortunately there was an error updating the forum settings and you did not input a valid entry for the <b>"& strError &"</b>. Please click <a href='"& Site_Forum_URL & "/Admin/forum-forums.asp'>here</a> to re-configure the forum settings."
		end if
		%>
		<table border="0" align="center" cellpadding="2" cellspacing="1" class="main">
			<tr valign="top" class="title">
			<td align="center"><%=Site_Name%> // Complete</td>
			</tr>
			<tr valign="top" class="body">
			<td align="center"><%=strMessage%></td>
			</tr>
		</table>
		<%
	else
		'Display a list of the categories
		%>
		<table border="0" cellspacing="1" cellpadding="2" class="main" align="center" width="783">
			<tr valign="middle" class="title">
			<td align="center" colspan="6" width="762"><%=Site_Name%> // 论 坛 管 理</td>
			</tr>
			<tr valign="top" class="body">
			<td align="left" colspan="6" width="762">To edit a forums details please expand the category that it's contained by clicking on it's name:</td>
			</tr>
			<%
			'Grab all categories
			set rsCategory = server.createobject("adodb.recordset")
			sqlCategory = "SELECT category_ID, Category_Title FROM Forum_Categories ORDER BY Category_Order"
			rsCategory.open sqlCategory, adoConn, CMDText
			if not (rsCategory.eof or rsCategory.bof) then
				CatCnt = rsCategory.recordcount
				CatData = rsCategory.getrows()
				rsCategory.close
				set rsCategory = nothing
					
				tempCatCnt = 0
				
				'Loop through and display categories
				do until tempCatCnt = CatCnt
					%>
					<tr valign="middle" class="sub-title">
					<td align="left" colspan="6" width="762"><a href="forum-forums.asp?Category=<%=CatData(0, tempCatCnt)%>"><%=CatData(1, tempCatCnt)%></a></td>
					</tr>
					<%
					'If the category has been selectedexpand it
					if CatData(0, tempCatCnt) = Category then
					%>
						<tr valign="top" class="body">
						<td width="92">论坛名称</td>
						<td width="460">论坛描述</td>
						<td width="47">Images</td>
						<td width="50">
                        <p align="center">序号</td>
						<td align="center" width="39">删除</td>
						<td width="63"> </td>
						</tr>
						<%
						'Grab all of the forum data for the current category
						set rsForums = server.createobject("adodb.recordset")
						sqlForums = "SELECT Forum_ID, Forum_Name, Forum_Description, Forum_Order, Forum_Topics, Forum_Posts, Forum_Post_Date, Forum_Allow_Images FROM Forum_Forums WHERE Forum_Category_ID = "& Category &" ORDER BY Forum_Order ASC"
						rsForums.open sqlForums, adoConn, CMDText
						if not(rsForums.eof or rsForums.bof) then
							ForumCnt = rsForums.recordcount
							ForumData = rsForums.getrows()
							rsForums.close
							set rsForums = nothing
							
							tempFormCnt = 0
							
							'loop through the forum data
							do until tempFormCnt = ForumCnt
								%>
								<form action="forum-forums.asp?Action=Submit&Method=Update" method="post" onSubmit="this.button.disabled = true;">
								<tr valign="middle" class="body">
								<td width="92">
                                <input name="Title" type="text" id="Title" value="<%=ForumData(1, tempFormCnt)%>" maxlength="60" style="width: 100%; border: 1px solid black;" size="20"></td>
								<td width="460"><input name="Desc" type="text" id="Desc" style="border: 1px solid black;" value="<%=ForumData(2, tempFormCnt)%>" size="60"></td>
								<td width="47">
								<select name="Images">
									<option value="1" <%if ForumData(7, tempFormCnt) = 1 then response.write("selected")%>>Yes</option>
                					<option value="0" <%if ForumData(7, tempFormCnt) = 0 then response.write("selected")%>>No</option>		
								</select>
								</td>
								<td width="50">
								<select name="Order" style="width: 50px;">
									<%
									OptionCnt = 0
									do until OptionCnt = ForumCnt
										%>
										<option value="<%=OptionCnt%>" <%if OptionCnt = ForumData(3, tempFormCnt) then response.write("selected")%>><%=OptionCnt%></option>
										<%
										OptionCnt = OptionCnt + 1
									loop
									%>		
								</select>
								</td>
								<td align="center" width="39"><input name="Delete" type="checkbox" id="Delete" value="1"></td>
								<td align="center" width="63"><input name="Cat" type="hidden" value="<%=request.querystring("Category")%>"><input name="ID" type="hidden" value="<%=ForumData(0, tempFormCnt)%>"><input name="button" type="submit" value="Update"></td>
								</tr>
								<tr class="body">
								<td colspan="6" width="762">Stats: Topics: <%=ForumData(4, tempFormCnt)%> // Posts: <%=ForumData(5, tempFormCnt)%> // Last Post: <%if ForumData(6, tempFormCnt) <> "" then response.write(web_time(ForumData(6, tempFormCnt), Site_Time_Format, "Long"))%></td>
								</tr>
								</form>
								<%
								tempFormCnt = tempFormCnt + 1
							loop
						else
							rsForums.close
							set rsForums = nothing
							%>
							<tr valign="top" class="body">
							<td align="left" colspan="6" width="762">There are no forums configured for this category.</td>
							</tr>
						<%
						end if
					end if
					tempCatCnt = tempCatCnt + 1
				loop
			else
				rsCategory.close
				set rsCategory = nothing
				
				NoCat = 1
				%>
				<tr valign="top" class="body">
				<td align="left" colspan="6" width="762">There are categories configured on this board. You must first add a category to the board before you can add a forum or edit an existing forum. Click <a href="forum-categories.asp">here</a> to add a new category.</td>
				</tr>
				<%
			end if
			%>
		</table>
		<%
		if NoCat <> 1 then
			%>		
			<table border="0" cellspacing="1" cellpadding="0" align="center" class="main">
				<form action="forum-forums.asp?Action=Submit&Method=New" method="post" onSubmit="this.button.disabled = true;">
				<tr class="title"> 
				<td align="center"><%=Site_Name%> // 论 坛 添 加</td>
				</tr>
				<tr class="body"> 
				<td>Add a new forum to the board by filling in the form below. New forums will automatically be a assigned the lowest possible ordering value.</td>
				</tr>
				<tr class="body"> 
				<td>
				论坛名称:<br>
				<input name="Title" type="text" id="Title" style="border: 1px solid black;" size="60">
				</td>
				</tr>
				<tr class="body"> 
				<td>
				论坛描述:<br>
				<input name="Desc" type="text" id="Desc" style="border: 1px solid black;" size="60">
				</td>
				</tr>
				<tr class="body"> 
				<td>
				Allow Images:<br>
				<select name="Images" style="width: 50%;">
                	<option value="1">Yes</option>
                	<option value="0">No</option>
              	</select>
				</td>
				</tr>
				<tr class="body"> 
				<td>
				Category:<br>
				<%
				'Grab all available categories
				set rsNew = server.createobject("adodb.recordset")
				sqlNew = "SELECT Category_ID, Category_Title FROM Forum_Categories ORDER BY Category_Order;"
				rsNew.open sqlNew, adoConn, CMDText
				if not (rsNew.eof or rsNew.bof) then
					NewCnt = rsNew.recordcount
					NewData = rsNew.getrows()
				end if
				rsNew.close
				set reNew = nothing
				
				tempCnt = 0
				
				response.write("<select name='New_Category' style='width: 50%; border: 1px solid black;'>")
				do until tempCnt = NewCnt
					%>
					<option value="<%=NewData(0, tempCnt)%>"><%=NewData(1, tempCnt)%></option>
					<%
					tempCnt = tempCnt + 1
				loop
				response.write("</select>")
				%>
				</td>
				</tr>
				<tr class="body"> 
				<td align="right"><input type="Submit" name="button" value="Submit"></td>
				</tr>
				</form>
			</table>
			<%
		end if
	end if
	%>
	</td>
  	</tr>
</table>

</body>
</html>

⌨️ 快捷键说明

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