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

📄 forum-categories.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 align="center">
	<%
	Action = request.querystring("Action")
	Method = request.querystring("Method")
	
	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-categories.asp"
		
		if lcase(strReferedBy) <> lcase(strCurrentURL) then
			response.redirect(Site_Forum_URL & "/default.asp")
		end if
		
		if request.form("Title") = "" then strError = "Category Title"
		
		if strError = "" then
			if Method = "Update" then
				'Update category settings in database
				
				if request.form("Delete") = "1" then
					'Check whether the category has any forums, if it does then do not go ahead with the deleteion
					set rsForumCheck = server.createobject("adodb.recordset")
					sqlForumCheck = "SELECT * FROM Forum_Forums WHERE Forum_Category_ID = "& request.form("ID") &""
					rsForumCheck.open sqlForumCheck, adoConn
					if rsForumCheck.eof or rsForumCheck.bof then
						'No Forums in this category delete it
						set rsUpdate = server.createobject("adodb.recordset")
						sqlUpdate = "SELECT * FROM Forum_Categories WHERE Category_ID = "& request.form("ID") &";"
						rsUpdate.cursortype = 2
						rsUpdate.locktype = 3
						rsUpdate.open sqlUpdate, adoConn, CMDText
						if not (rsUpdate.eof or rsUpdate.bof) then
							rsUpdate.delete
						end if
						rsUpdate.close
						set rsUpdate = nothing
						strHeader = "Success"
						strMessage = "The forum settings have been updated, click <a href='"& Site_Forum_URL & "/Admin'>here</a> to return to the Admin homepage."
					else
						'Category still has forums associated with it, don't delete
						strHeader = "Error"
						strMessage = "This category is not empty, please delete all of the forums that it contains and try again."	
					end if
				else
					'Update selected category settings
					set rsUpdate = server.createobject("adodb.recordset")
					sqlUpdate = "SELECT * FROM Forum_Categories WHERE Category_ID = "& request.form("ID") &";"
					rsUpdate.cursortype = 2
					rsUpdate.locktype = 3
					rsUpdate.open sqlUpdate, adoConn, CMDText
					strOldOrder = rsUpdate("Category_Order")
					rsUpdate("Category_Title") = request.form("Title")
					rsUpdate("Category_Order") = request.form("Order")
					rsUpdate.update
					rsUpdate.close
					set rsUpdate = nothing
					
					'Update other categories with their new
					set rsCategories = server.createobject("adodb.recordset")
					if int(strOldOrder) < int(request.form("Order")) then
						sqlCategories = "UPDATE Forum_Categories SET Category_Order = (Category_Order - 1) WHERE Category_Order >= "& strOldOrder &" AND Category_Order <= "& request.form("Order") &" AND Category_ID <> "& request.form("ID") &""
					else
						sqlCategories = "UPDATE Forum_Categories SET Category_Order = (Category_Order + 1) WHERE Category_Order >= "& request.form("Order") &" AND Category_Order <= "& strOldOrder &" AND Category_ID <> "& request.form("ID") &""
					end if
					rsCategories.open sqlCategories, adoConn
					set rsCategories = nothing
					
					strHeader = "Success"
					strMessage = "The forum settings have been updated, 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 current categories
				set rsCount = server.createobject("adodb.recordset")
				sqlCount = "SELECT COUNT(*) AS Cat_Count FROM Forum_Categories"
				rsCount.open sqlCount, adoConn
				Cat_Count = rsCount("Cat_Count")
				rsCount.close
				set rsCount = nothing
			
				'Add new category to the database
				set rsUpdate = server.createobject("adodb.recordset")
				sqlUpdate = "SELECT * FROM Forum_Categories;"
				rsUpdate.cursortype = 2
				rsUpdate.locktype = 3
				rsUpdate.open sqlUpdate, adoConn, CMDText
				rsUpdate.addnew
				rsUpdate("Category_Title") = request.form("Title")
				rsUpdate("Category_Order") = Cat_Count
				rsUpdate.update
				rsUpdate.close
				set rsUpdate = nothing
				strHeader = "Success"
				strMessage = "The forum settings have been updated, 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 category settings as you did not input a valid entry for the <b>"& strError &"</b> field. Please click <a href='"& Site_Forum_URL & "/Admin/forum-categories.asp'>here</a> to re-configure the categories."
		end if		
		'Display Confirmation
		%>
		<table border="0" cellpadding="2" cellspacing="1" align="center" class="main">
			<tr valign="middle" class="title">
			<td align="center"><%=Site_Name%> // <%=strHeader%></td>
			</tr>
			<tr valign="top" class="body">
			<td align="center"><%=strMessage%></td>
			</tr>
		</table>
		<%	
	else
		'Display current settings
		set rsSettings = server.createobject("adodb.recordset")
		sqlSettings = "SELECT * FROM Forum_Categories ORDER BY Category_Order"
		rsSettings.open sqlSettings, adoConn, CMDText
		if not (rsSettings.eof or rsSettings.bof) then
			CatCnt = rsSettings.recordcount
			CatData = rsSettings.getrows()
		end if
		rsSettings.close
		set rsSettings = nothing
				
		tempCnt = 0
		%>
		<table border="0" cellspacing="1" cellpadding="3" align="center" class="main" width="777">
			<tr valign="middle" class="title">
			<td align="center" colspan="4" width="760"><%=Site_Name%> // 分 类 管 理</td>
			</tr>
			<tr valign="top" class="body">
			<td colspan="4" width="760">Set the category orders using the form below.</td>
			</tr>
			<tr valign="top" class="body">
			<td width="557">分类名称:</td>
			<td colspan="1" width="100">分类序号</td>
			<td align="center" colspan="1" width="26">删除</td>
			<td colspan="1" width="63"> </td>
			</tr>
			<%
			do until tempCnt = CatCnt
				%>
				<form action="forum-categories.asp?Action=Submit&Method=Update" method="post" onSubmit="this.button.disabled = true;">
				<tr valign="top" class="body">
				<td width="557"><input name="Title" type="text" id="Title" style="border: 1px solid black;" value="<%=CatData(1, tempCnt)%>" size="60"></td>
				<td align="left" width="100">
				<select name="Order" style="width: 100px; border: 1px solid black">
					<%
					tempCnt2 = 0
					do until tempCnt2 = CatCnt
						%>
             				<option value="<%=tempCnt2%>" <%if tempCnt2 = CatData(2, tempCnt) then response.write("selected")%>><%=tempCnt2%></option>
						<%
						tempCnt2 = tempCnt2 + 1
					loop
					%>		
				</select>
				</td>
				<td align="center" valign="middle" width="26"><input name="Delete" type="checkbox" id="Delete" value="1"></td>
				<td align="center" width="63"><input name="ID" type="hidden" value="<%=CatData(0, tempCnt)%>"><input name="button" type="submit" value="Update"></td>
				</tr>
				</form>
				<%
				tempCnt = tempCnt + 1
			loop
			if CatCnt = 0 then
				%>
				<tr valign="top" class="body">
				<td align="left" colspan="4" width="760">There are currently no categories configured for these boards. You need to add a category using the form below before you can add any forums to your message boards.</td>
				</tr>
				<%
			end if
			%>						
		</table>
		<table border="0" cellspacing="1" cellpadding="3" align="center" class="main">
			<form action="forum-categories.asp?Action=Submit&Method=New" method="post" onSubmit="this.button.disabled = true;">
			<tr valign="middle" class="title">
			<td align="center"><%=Site_Name%> // 添 加 分 类</td>
			</tr>
			<tr valign="top" class="body">
			<td>Add the title for the new category in the box below. New categories will automatically be assigned the lowest possible category order.</td>
			</tr>
			<tr valign="top" class="body">
			<td>
			分类名称:<br>
			<input name="Title" type="text" id="Title" style="border: 1px solid black;" value="" size="60" maxlength="100"></td>
			</tr>
			<tr valign="top" class="body">
			<td align="right"><input name="Order" type="hidden" value="<%=(CatCnt+1)%>"><input name="button" type="submit" value="Update"></td>
			</tr>
			</form>
		</table>
	<%
	end if
	%>
	</td>
  	</tr>
</table>

</body>
</html>

⌨️ 快捷键说明

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