Click here to Skip to main content
15,896,111 members
Articles / Programming Languages / ASP

StP Forum

Rate me:
Please Sign up or sign in to vote.
4.13/5 (8 votes)
17 Mar 20028 min read 89.9K   1.9K   51  
ASP-based forum for your website.
<!-- METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4"  -->
<!--#include file=config.asp -->
<%
dim con, rec, rec2, sSQL, sSQL2, RecordsAffected, arImages, abspage, i, bUserExists
arImages = Split(MessageImages, "|", -1, 0)
set con = Server.CreateObject("ADODB.Connection")
con.Open ConnString


if Request.QueryString("forumid").Count > 0 then
	if Request.QueryString("delete").Count > 0 then
		RecordsAffected = 0
		if Session(USER_LEVEL) = 3 then
			sSQL = "DELETE FROM ReplyT WHERE R_Topic_ID=" & Request.QueryString("delete")
			sSQL2 = "DELETE FROM TopicsT WHERE Topic_ID=" & Request.QueryString("delete")
		elseif Session(USER_LEVEL) = 2 then
			sSQL =	"DELETE FROM ReplyT WHERE R_Topic_ID=" & Request.QueryString("delete") &_
					" AND '" & Replace(Session(USER_NAME), "'", "''") & "'=(SELECT F_Moderator FROM ForumT WHERE Forum_ID=" & Request.QueryString("forumid") & ")"
			sSQL2 = "DELETE FROM TopicsT WHERE Topic_ID=" & Request.QueryString("delete") &_
					" AND '" & Replace(Session(USER_NAME), "'", "''") & "'=(SELECT F_Moderator FROM ForumT WHERE Forum_ID=" & Request.QueryString("forumid") & ")"
		else
			sSQL =	"DELETE FROM ReplyT WHERE R_Topic_ID=" & Request.QueryString("delete") &_
					" AND '" & Replace(Session(USER_NAME), "'", "''") & "'=(SELECT T_Originator FROM TopicsT WHERE Topic_ID=" & Request.QueryString("delete") & ")"
			sSQL2 = "DELETE FROM TopicsT WHERE Topic_ID=" & Request.QueryString("delete") &_
					" AND '" & Replace(Session(USER_NAME), "'", "''") & "'=T_Originator"
		end if
		con.Execute sSQL, RecordsAffected, adExecuteNoRecords
		if RecordsAffected > 0 then
			sSQL = "UPDATE ForumT SET F_Posts=(F_Posts-" & RecordsAffected & ") WHERE Forum_ID=" & Request.QueryString("forumid")
			con.Execute sSQL, adExecuteNoRecords
		end if
		RecordsAffected = 0
		con.Execute sSQL2, RecordsAffected, adExecuteNoRecords
		if RecordsAffected > 0 then
			sSQL = "UPDATE ForumT SET F_Topics=(F_Topics-1) WHERE Forum_ID=" & Request.QueryString("forumid")
			con.Execute sSQL, adExecuteNoRecords
		end if
	end if
	
	if Request.QueryString("action") = "close" then
		sSQL = "UPDATE TopicsT SET T_Status=(NOT T_Status) WHERE Topic_ID=" & Request.QueryString("id")		
		if Session(USER_LEVEL) = 2 then
			sSQL = sSQL & " AND '" & Replace(Session(USER_NAME), "'", "''") & "'=(SELECT F_Moderator FROM ForumT WHERE Forum_ID=" & Request.QueryString("forumid") & ")"
		elseif Session(USER_LEVEL) <> 3 then
			sSQL = ""
		end if
		if Len(sSQL) > 0 then con.Execute sSQL, adExecuteNoRecords
	end if
%>
<p align="left">
	[<a href="<%=ForumFile%>"><%=ForumName%></a>]-&gt;
	[<%=Request.QueryString("fname")%>]
</p>
<table WIDTH="100%" ALIGN="center" CELLSPACING="1" CELLPADDING="5" bgcolor="<%=CategoryCellColor%>">
	<tr>
		<td colspan="7" align="right">
		
		<a href="<%=PostFile%>?forumid=<%=Request.QueryString("forumid")%>&amp;fname=<%=Server.URLEncode(Request.QueryString("fname"))%>">
		<%if Len(NewTopicImage) = 0 then%>
		::New topic::
		<%else%>
		<img src="<%=ImagesDir & NewTopicImage%>" alt="New topic">
		<%end if%>
		</a>&nbsp;
		
		<%if Len(Session(USER_NAME)) = 0 then%>
			<a href="<%=ProfileFile%>">
			<%if Len(RegisterImage) = 0 then%>
			::Register::
			<%else%>
			<img src="<%=ImagesDir & RegisterImage%>" alt="Register">
			<%end if%>
			</a>&nbsp;
			<a href="<%=LoginFile%>">
			<%if Len(LoginImage) = 0 then%>
			::Login::
			<%else%>
			<img src="<%=ImagesDir & LoginImage%>" alt="Login">
			<%end if%>
			</a>&nbsp;
		<%else%>
		
			<a href="<%=ProfileFile%>">
			<%if Len(ProfileImage) = 0 then%>
			::Profile::
			<%else%>
			<img src="<%=ImagesDir & ProfileImage%>" alt="My profile">
			<%end if%>
			</a>&nbsp;
		
		<%end if%>
		
		<A href="<%=SearchFile%>">
		<%if Len(SearchImage) = 0 then%>
		::Search::
		<%else%>
		<IMG src="<%=ImagesDir & SearchImage%>" alt="Search the forums">
		<%end if%>
		</A>
		
		</td>
	</tr>
	<tr>
		<td bgcolor="<%=HeadCellColor%>" align="center" width="50%" colspan="3"><font size="1" color="<%=HeadFontColor%>"><b>Topic</b></font></td>
		<td bgcolor="<%=HeadCellColor%>" align="center"><font size="1" color="<%=HeadFontColor%>"><b>Originator</b></font></td>
		<td bgcolor="<%=HeadCellColor%>" align="center"><font size="1" color="<%=HeadFontColor%>"><b>Replies</b></font></td>
		<td bgcolor="<%=HeadCellColor%>" align="center"><font size="1" color="<%=HeadFontColor%>"><b>Views</b></font></td>
		<td bgcolor="<%=HeadCellColor%>" align="center"><font size="1" color="<%=HeadFontColor%>"><b>Last post</b></font></td>
	</tr>
<%
	sSQL =	"SELECT TopicsT.*, ForumT.F_Status, ForumT.F_Moderator " &_
			"FROM ForumT INNER JOIN TopicsT ON ForumT.Forum_ID = TopicsT.T_Forum_id " &_
			"WHERE T_Forum_id=" & Request.QueryString("forumid") & " ORDER BY T_Lastpost DESC,  T_Date Desc"
	set rec = Server.CreateObject("ADODB.Recordset")
	rec.CursorLocation = adUseClient
	rec.CacheSize = 25
	rec.PageSize = 25
	rec.Open sSQL, con, adOpenForwardOnly, adLockReadOnly
	if rec.PageCount > 0 then
		if Request("page").Count = 0 or CInt(Request("page")) = 0  or rec.PageCount < CInt(Request("page")) then
			rec.AbsolutePage = 1
		else
			rec.AbsolutePage = CInt(Request("page"))
		end if
	end if
	abspage = rec.AbsolutePage
	for i=1 to rec.PageSize
		if not rec.EOF then
%>
	<tr>
		<td bgcolor="<%=ForumCellColor%>" align="center">
			<%if rec(T_STATUS) = False then%>
			<img src="<%=ImagesDir%>lock.gif" alt="Thread locked">
			<%else%>
			&nbsp;
			<%end if%>
		</td>
		<td bgcolor="<%=ForumCellAltColor%>" align="center">
			<%if rec(T_IMAGE) <> 0 then%>
			<img src="<%=ImagesDir & arImages(rec(T_IMAGE) - 1)%>">
			<%end if%>
		</td>
		<td bgcolor="<%=ForumCellColor%>"><font color="<%=ForumFontColor%>">
			<a class="SmartLink" href="<%=ForumFile%>?topicid=<%=rec(TOPIC_ID)%>&amp;fname=<%=Server.URLEncode(Request.QueryString("fname"))%>&amp;fid=<%=Request.QueryString("forumid")%>&amp;tname=<%=Server.URLEncode(rec(T_SUBJECT))%>&amp;d=<%=Date2Number(rec(T_LASTPOST))%>"><%=rec(T_SUBJECT)%></a>
			<%if Session(USER_LEVEL) = 3 or (Session(USER_LEVEL) = 2 and rec("F_Moderator") = Session(USER_NAME)) then%>
			<div align="center"><font size="1">[<a href="<%=ForumFile%>?action=close&amp;forumid=<%=Request.QueryString("forumid")%>&amp;id=<%=rec(TOPIC_ID)%>&amp;fname=<%=Request.QueryString("fname")%>">open/close</a>]</font></div>
			<%end if%>
		</font></td>
		<td bgcolor="<%=ForumCellAltColor%>"><font color="<%=ForumFontColor%>"><a href="<%=MembersFile%>?name=<%=Server.URLEncode(rec(T_ORIGINATOR))%>" title="View <%=Replace(rec(T_ORIGINATOR),"**Anonymous**|","")%> info"><%=Replace(rec(T_ORIGINATOR),"**Anonymous**|","")%></a></font></td>
		<td bgcolor="<%=ForumCellColor%>"><font color="<%=ForumFontColor%>"><%=rec(T_REPLIES)%></font></td>
		<td bgcolor="<%=ForumCellAltColor%>"><font color="<%=ForumFontColor%>"><%=rec(T_VIEWS)%></font></td>
		<td bgcolor="<%=ForumCellColor%>"><font color="<%=ForumFontColor%>" size="1"><%=FormatDateTime(rec(T_LASTPOST), vbGeneralDate)%><br>by <a href="<%=MembersFile%>?name=<%=Server.URLEncode(rec(T_LASTPOSTER))%>"><%=Replace(rec(T_LASTPOSTER),"**Anonymous**|","")%></a></font></td>
	</tr>
<%
			rec.MoveNext
		end if
	Next
%>
	<tr>
		<td colspan="7" style="padding-top:0px; padding-bottom:0px; padding-left:10px; padding-right:10px; font-size:xx-small">
		<%if abspage > 1 then%>
			<A href="<%=ForumFile%>?page=<%=(abspage - 1)%>&fname=<%=Request.QueryString("fname")%>&forumid=<%=Request.QueryString("forumid")%>"><FONT size=1>&lt;&lt;&nbsp;Prev</FONT></A>
		<%end if%>
		<%for i=1 to rec.PageCount
			if i = abspage then%>
				<FONT size=2>[<%=i%>]</FONT>&nbsp;
		<%	else%>
				<FONT size=1>&nbsp;[<A href="<%=ForumFile%>?page=<%=i%>&fname=<%=Request.QueryString("fname")%>&forumid=<%=Request.QueryString("forumid")%>"><%=i%></A>]&nbsp;</FONT>
		<%	end if
		Next
		if (abspage < rec.PageCount and abspage > 0) then%>
			<A href="<%=ForumFile%>?page=<%=(abspage + 1)%>&fname=<%=Request.QueryString("fname")%>&forumid=<%=Request.QueryString("forumid")%>"><FONT size=1>Next&nbsp;&gt;&gt;</FONT></A>
		<%end if%>
		</td>
	</tr>
	<tr>
		<td colspan="7" style="padding-top:0px; padding-bottom:0px; padding-left:10px; padding-right:10px; font-size:xx-small" align="right">
		<a href="http://www.saintopatrick.com" target="_blank">StP Forum v1.0</a>
		</td>
	</tr>
</table>
<%
	rec.close
	set rec = nothing
%>

<!--***********************************************************-->


<%
elseif Request.QueryString("topicid").Count > 0 then
	if Request.QueryString("delete").Count > 0 then
		RecordsAffected = 0
		if Session(USER_LEVEL) = 3 then
			sSQL = "DELETE FROM ReplyT WHERE Reply_ID=" & Request.QueryString("delete")
		elseif Session(USER_LEVEL) = 2 then
			sSQL =	"DELETE FROM ReplyT WHERE Reply_ID=" & Request.QueryString("delete") &_
					" AND '" & Replace(Session(USER_NAME), "'", "''") & "'=(SELECT F_Moderator FROM ForumT WHERE Forum_ID=" & Request.QueryString("fid") & ")"
		else
			sSQL =	"DELETE FROM ReplyT WHERE Reply_ID=" & Request.QueryString("delete") &_
					" AND '" & Replace(Session(USER_NAME), "'", "''") & "'=R_Posted_BY"
		end if
		con.Execute sSQL, RecordsAffected, adExecuteNoRecords
		if RecordsAffected > 0 then
			sSQL = "UPDATE ForumT SET F_Posts=(F_Posts-1) WHERE Forum_ID=" & Request.QueryString("fid")
			con.Execute sSQL, adExecuteNoRecords
			sSQL = "UPDATE TopicsT SET T_Replies=(T_Replies-1) WHERE Topic_ID=" & Request.QueryString("topicid")
			con.Execute sSQL, adExecuteNoRecords
		end if
	else
		sSQL = "UPDATE TopicsT SET T_Views=(T_Views+1) WHERE Topic_ID=" & Request.QueryString("topicid")
		con.Execute sSQL, adExecuteNoRecords
	end if
%>
<p align="left">
	[<a href="<%=ForumFile%>"><%=ForumName%></a>]-&gt;
	[<a href="<%=ForumFile%>?fname=<%=Server.URLEncode(Request.QueryString("fname"))%>&amp;forumid=<%=Request.QueryString("fid")%>"><%=Request.QueryString("fname")%></a>]-&gt;
	[<%=Request.QueryString("tname")%>]
</p>
<table WIDTH="100%" ALIGN="center" CELLSPACING="1" CELLPADDING="5" bgcolor="<%=CategoryCellColor%>">
	<tr>
		<td colspan="2" align="right">
		<a href="<%=PostFile%>?topicid=<%=Request.QueryString("topicid")%>&amp;fname=<%=Server.URLEncode(Request.QueryString("fname"))%>&amp;fid=<%=Request.QueryString("fid")%>&amp;tname=<%=Server.URLEncode(Request.QueryString("tname"))%>">
		<%if Len(ReplyImage) = 0 then%>
		::Reply::
		<%else%>
		<img src="<%=ImagesDir & ReplyImage%>" alt="New topic">
		<%end if%>
		</a>&nbsp;
		
		<%if Len(Session(USER_NAME)) = 0 then%>
			<a href="<%=ProfileFile%>">
			<%if Len(RegisterImage) = 0 then%>
			::Register::
			<%else%>
			<img src="<%=ImagesDir & RegisterImage%>" alt="Register">
			<%end if%>
			</a>&nbsp;
			<a href="<%=LoginFile%>">
			<%if Len(LoginImage) = 0 then%>
			::Login::
			<%else%>
			<img src="<%=ImagesDir & LoginImage%>" alt="Login">
			<%end if%>
			</a>&nbsp;
		<%else%>
		
			<a href="<%=ProfileFile%>">
			<%if Len(ProfileImage) = 0 then%>
			::Profile::
			<%else%>
			<img src="<%=ImagesDir & ProfileImage%>" alt="My profile">
			<%end if%>
			</a>
		
		<%end if%>
		
		<A href="<%=SearchFile%>">
		<%if Len(SearchImage) = 0 then%>
		::Search::
		<%else%>
		<IMG src="<%=ImagesDir & SearchImage%>" alt="Search the forums">
		<%end if%>
		</A>

		</td>
	</tr>

	<tr>
		<td bgcolor="<%=HeadCellColor%>"><font size="1" color="<%=HeadFontColor%>">Author</font></td>
		<td bgcolor="<%=HeadCellColor%>"><font size="1" color="<%=HeadFontColor%>">Thread</font></td>
	</tr>
<%
	dim moderator
	set rec = Server.CreateObject("ADODB.Recordset")
	sSQL =	"SELECT TopicsT.*, UsersT.*, ForumT.F_Moderator " &_
			"FROM ForumT RIGHT JOIN (UsersT RIGHT JOIN TopicsT ON UsersT.Name = TopicsT.T_Originator) ON ForumT.Forum_ID = TopicsT.T_Forum_id " &_
			"WHERE TopicsT.Topic_ID=" & Request.QueryString("topicid")
	rec.Open sSQL, con, adOpenForwardOnly, adLockReadOnly
	moderator = rec("F_Moderator")
	bUserExists = not IsNull(rec("Name"))
%>
	<tr>
		<td valign="top" rowspan="3" bgcolor="<%=ForumCellAltColor%>" width="35%">
			<font color="<%=ForumFontColor%>"><b><%=Replace(rec("T_Originator"),"**Anonymous**|","")%></b><br>
			<%if bUserExists then%>
			<br><font size="1">Registered: <%=FormatDateTime(rec("DATEREGISTERED"), vbLongDate)%><br>
			Location: <%=rec("COUNTRY")%><br>
			Posts: <%=rec("POSTS")%></font>
			<%else%>
			<font size=1><I>Unregistered user</I></font>
			<%end if%>
		</font></td>
		<td bgcolor="<%=ForumCellAltColor%>"><font color="<%=ForumFontColor%>" size="1">
			<%if rec("T_Image") <> 0 then%>
			<img src="<%=ImagesDir & arImages(rec("T_Image") - 1)%>">
			<%else%>
			&nbsp;
			<%end if%>
			<b><%=rec("T_SUBJECT")%></b>
		</font></td>
	</tr>
	<tr>
		<td bgcolor="<%=ForumCellAltColor%>" style="padding-top:20px; padding-bottom:20px"><font color="<%=ForumFontColor%>"><%=FormatText(rec("T_MESSAGE"))%></font></td>
	</tr>
	<tr>
		<td bgcolor="<%=ForumCellAltColor%>"><font color="<%=ForumFontColor%>" size="1">
			<%if bUserExists then%>
				::<a href="<%=membersFile%>?name=<%=Server.URLEncode(rec("Name"))%>">profile</a>::&nbsp;
				<%if Len(rec("Homepage")) > 0 then%>
				::<a href="<%=rec("Homepage")%>" target="_blank">homepage</a>::&nbsp;
				<%end if%>
				::<a href="<%=EmailFile%>?name=<%=Server.URLEncode(rec("Name"))%>" target="_blank">e-mail</a>::&nbsp;
			<%end if%>
			<%if Session(USER_LEVEL) = 3 or (Session(USER_LEVEL) = 2 and Session(USER_NAME) = moderator) or Session(USER_NAME) = rec("T_ORIGINATOR") then%>
			<span align="right">
				::<a href="<%=PostFile%>?id=<%=rec("Topic_ID")%>&amp;forumid=<%=rec("T_Forum_ID")%>&amp;fname=<%=Server.URLEncode(Request.QueryString("fname"))%>">edit</a>::&nbsp;
				::<a href="<%=ForumFile%>?forumid=<%=Request.QueryString("fid")%>&amp;fname=<%=Server.URLEncode(Request.QueryString("fname"))%>&amp;delete=<%=Request.QueryString("topicid")%>">delete</a>::
			</span>
			<%end if%>
		</font></td>
	</tr>
<%
	rec.Close
	
	dim arRows, intEnd, intTotalRecords, intPageSize, intStart, intCurrentRecord
	sSQL =	"SELECT ReplyT.Reply_ID, ReplyT.R_Posted_By, ReplyT.R_Subject, ReplyT.R_Message, ReplyT.R_Date, ReplyT.R_Image, UsersT.Name, UsersT.Level, UsersT.Country, UsersT.Homepage, UsersT.DateRegistered, UsersT.Posts, ReplyT.R_Topic_ID " &_
			"FROM ReplyT LEFT JOIN UsersT ON ReplyT.R_Posted_By = UsersT.Name " &_
			"WHERE ReplyT.R_Topic_ID=" & Request.QueryString("topicid")
	rec.CursorLocation = adUseServer
	rec.Open sSQL, con, adOpenForwardOnly, adLockReadOnly
	if not rec.EOF and not rec.BOF then 
		arRows = rec.GetRows
		intTotalRecords = UBound(arRows, 2) + 1
	else
		intTotalRecords = 0
	end if
	rec.Close
	intPageSize = 20
	if Len(Request("page")) = 0 or IsNumeric(Request("page")) = False  or Int(intTotalRecords/intPageSize) < CInt(Request("page")) then
		abspage = 1
	else
		abspage = CInt(Request("page"))
	end if
	intStart = (abspage - 1) * intPageSize
	intEnd = intStart + intPageSize - 1
	intCurrentRecord = intStart
	do while intCurrentRecord < intEnd and intTotalRecords > 0
		bUserExists = not IsNull(arRows(7, intCurrentRecord))
%>
	<tr>
		<td valign="top" rowspan="3" bgcolor="<%=ForumCellColor%>">
			<font color="<%=ForumFontColor%>"><b>
				<%=Replace(arRows(1, intCurrentRecord), "**Anonymous**|", "")%>
			</b><br>
			<%if bUserExists then%>
			<br><font size="1">Registered: <%=FormatDateTime(arRows(10,intCurrentRecord), vbLongDate)%><br>
			Location: <%=arRows(8, intCurrentRecord)%><br>
			Posts: <%=arRows(11, intCurrentRecord)%></font>
			<%else%>
			<font size=1><I>Unregistered user</I></font>
			<%end if%>
		</font></td>
		<td bgcolor="<%=ForumCellColor%>"><font color="<%=ForumFontColor%>" size="1">
			<%if arRows(5, intCurrentRecord) <> 0 then%>
			<img src="<%=ImagesDir & arImages(arRows(5, intCurrentRecord) - 1)%>">
			<%end if%>
			<b><%=arRows(2, intCurrentRecord)%></b>
		</font></td>
	</tr>
	<tr>
		<td bgcolor="<%=ForumCellColor%>" style="padding-top:20px; padding-bottom:20px"><font color="<%=ForumFontColor%>"><%=FormatText(arRows(3, intCurrentRecord))%></font></td>
	</tr>
	<tr>
		<td bgcolor="<%=ForumCellColor%>"><font color="<%=ForumFontColor%>" size="1">
			<%if bUserExists then%>
			::<a href="<%=membersFile%>?name=<%=Server.URLEncode(arRows(6, intCurrentRecord))%>">profile</a>::&nbsp;
			<%if Len(arRows(9, intCurrentRecord)) > 0 then%>
			::<a href="<%=arRows(9, intCurrentRecord)%>" target="_blank">homepage</a>::&nbsp;
			<%end if%>
			::<a href="<%=EmailFile%>?name=<%=Server.URLEncode(arRows(6, intCurrentRecord))%>" target="_blank">e-mail</a>::&nbsp;
			<%end if%>
			<%if Session(USER_LEVEL) = 3 or (Session(USER_LEVEL) = 2 and Session(USER_NAME) = moderator) or (Session(USER_NAME) = arRows(6, intCurrentRecord) and bUserExists) then%>
			<span align="right">
				::<a href="<%=PostFile%>?id=<%=arRows(0, intCurrentRecord)%>&amp;topicid=<%=arRows(12, intCurrentRecord)%>">edit</a>::&nbsp;
				::<a href="<%=ForumFile%>?fid=<%=Request.QueryString("fid")%>&amp;fname=<%=Server.URLEncode(Request.QueryString("fname"))%>&amp;delete=<%=arRows(0, intCurrentRecord)%>&amp;topicid=<%=Request.QueryString("topicid")%>&amp;tname=<%=Server.URLEncode(Request.QueryString("tname"))%>">delete</a>::
			</span>
			<%end if%>
		</font></td>
	</tr>
<%
		intCurrentRecord = intCurrentRecord + 1
		if intCurrentRecord >= intTotalRecords then Exit Do
	Loop 
%>
	<tr>
		<td colspan="2" style="padding-top:0px; padding-bottom:0px; padding-left:10px; padding-right:10px; font-size:xx-small">
		<%if abspage > 1 then%>
			<A href="<%=ForumFile%>?page=<%=(abspage - 1)%>&fname=<%=Server.URLEncode(Request.QueryString("fname"))%>&fid=<%=Request.QueryString("fid")%>&topicid=<%=Request.QueryString("topicid")%>&tname=<%=Server.URLEncode(Request.QueryString("tname"))%>"><FONT size=1>&lt;&lt;&nbsp;Prev</FONT></A>
		<%end if%>
		<%for i=1 to Int(intTotalRecords/intPageSize + 1)
			if i = abspage then%>
				<FONT size=2>[<%=i%>]</FONT>&nbsp;
		<%	else%>
				<FONT size=1>&nbsp;[<A href="<%=ForumFile%>?page=<%=i%>&fname=<%=Server.URLEncode(Request.QueryString("fname"))%>&fid=<%=Request.QueryString("fid")%>&topicid=<%=Request.QueryString("topicid")%>&tname=<%=Server.URLEncode(Request.QueryString("tname"))%>"><%=i%></A>]&nbsp;</FONT>
		<%	end if
		Next
		if (abspage < Int(intTotalRecords/intPageSize) and abspage > 0) then%>
			<A href="<%=ForumFile%>?page=<%=(abspage + 1)%>&fname=<%=Server.URLEncode(Request.QueryString("fname"))%>&fid=<%=Request.QueryString("fid")%>&topicid=<%=Request.QueryString("topicid")%>&tname=<%=Server.URLEncode(Request.QueryString("tname"))%>"><FONT size=1>Next&nbsp;&gt;&gt;</FONT></A>
		<%end if%>
		</td>
	</tr>
	<tr>
		<td colspan="2" style="padding-top:0px; padding-bottom:0px; padding-left:10px; padding-right:10px; font-size:xx-small" align="right">
		<a href="http://www.saintopatrick.com" target="_blank">StP Forum v1.0</a>
		</td>
	</tr>
<%
	set rec = nothing
%>
</table>



<!--***********************************************************-->


<%
else
	if Request.QueryString("action") = "close" then
		sSQL = "UPDATE ForumT SET F_Status=(NOT F_Status) WHERE Forum_ID=" & Request.QueryString("id")
		if Session(USER_LEVEL) = 2 then
			sSQL = sSQL & " AND F_Moderator='" & Replace(Session(USER_NAME), "'", "''") & "'"
		elseif Session(USER_LEVEL) <> 3 then
			sSQL = ""
		end if
		if Len(sSQL) > 0 then
			con.Execute sSQL, adExecuteNoRecords
		end if
	end if
	
	set rec = Server.CreateObject("ADODB.Recordset")
	set rec2 = Server.CreateObject("ADODB.Recordset")
	sSQL = "SELECT * FROM CategoryT ORDER BY Cat_Date ASC"
	rec.CursorLocation = adUseClient
	rec2.CursorLocation = adUseClient
	rec.Open sSQL, con, adOpenForwardOnly, adLockReadOnly
%>
<table WIDTH="100%" ALIGN="center" BORDER="0" CELLSPACING="1" CELLPADDING="5" BGCOLOR="<%=CategoryCellColor%>">
	<tr>
		<td colspan="7" align="right">
		
		<%if Len(Session(USER_NAME)) = 0 then%>
			<a href="<%=ProfileFile%>">
			<%if Len(RegisterImage) = 0 then%>
			::Register::
			<%else%>
			<img src="<%=ImagesDir & RegisterImage%>" alt="Register">
			<%end if%>
			</a>&nbsp;
			<a href="<%=LoginFile%>">
			<%if Len(LoginImage) = 0 then%>
			::Login::
			<%else%>
			<img src="<%=ImagesDir & LoginImage%>" alt="Login">
			<%end if%>
			</a>&nbsp;
		<%else%>
		
			<a href="<%=ProfileFile%>">
			<%if Len(ProfileImage) = 0 then%>
			::Profile::
			<%else%>
			<img src="<%=ImagesDir & ProfileImage%>" alt="My profile">
			<%end if%>
			</a>
		
		<%end if%>
		
		<A href="<%=SearchFile%>">
		<%if Len(SearchImage) = 0 then%>
		::Search::
		<%else%>
		<IMG src="<%=ImagesDir & SearchImage%>" alt="Search the forums">
		<%end if%>
		</A>

		</td>
	</tr>
	
	<tr>
		<td bgcolor="<%=HeadCellColor%>">&nbsp;</td>
		<td bgcolor="<%=HeadCellColor%>" width="50%"><font size="1" color="<%=HeadFontColor%>">Forum</font></td>
		<td bgcolor="<%=HeadCellColor%>"><font size="1" color="<%=HeadFontColor%>">Posts</font></td>
		<td bgcolor="<%=HeadCellColor%>"><font size="1" color="<%=HeadFontColor%>">Threads</font></td>
		<td bgcolor="<%=HeadCellColor%>" align="center"><font size="1" color="<%=HeadFontColor%>">Last post</font></td>
		<td bgcolor="<%=HeadCellColor%>" align="center"><font size="1" color="<%=HeadFontColor%>">Moderator</font></td>
	</tr>
<%
	dim HighlightColor
	if HighlightRows then
		HightlightColor = ForumCellAltColor
	else
		HightlightColor = ForumCellColor
	end if
	do while not rec.EOF 
		sSQL = "SELECT * FROM ForumT WHERE F_Cat=" & rec(CAT_ID) & " ORDER BY F_Date ASC"
		rec2.Open sSQL, con, adOpenForwardOnly, adLockReadOnly 
%>
	<tr>
		<td bgcolor="<%=CategoryCellColor%>"></td>
		<td bgcolor="<%=CategoryCellColor%>" colspan="6"><font color="<%=CategoryFontColor%>"><%=rec(CAT_NAME)%></font></td>
	</tr>
<%
		do while not rec2.EOF
%>
	<tr>
		<td bgcolor="<%=ForumCellAltColor%>" align="center">
			<%if rec2(F_STATUS) = False then%>
			<img src="<%=ImagesDir%>lock.gif" alt="Forum locked">
			<%else%>
			&nbsp;
			<%end if%>
		</td>
		<td bgcolor="<%=ForumCellColor%>" onmouseover="bgColor='<%=HightlightColor%>'" onmouseout="bgColor='<%=ForumCellColor%>'"><font color="<%=ForumFontColor%>">
			<a class="SmartLink" href="<%=ForumFile%>?forumid=<%=rec2(FORUM_ID)%>&amp;fname=<%=Server.URLEncode(rec2(F_NAME))%>&amp;d=<%=Date2Number(rec2(F_LASTPOST))%>"><%=rec2(F_NAME)%></a><br>
			<font size="1"><%=rec2(F_DESCRIPTION)%></font>
			<%if Session(USER_LEVEL) = 3 or (Session(USER_LEVEL)=2 and Session(USER_NAME) = rec2(F_MODERATOR)) then%>
			<div align="right"><font size="1">[<a href="<%=ForumFile%>?action=close&amp;id=<%=rec2(FORUM_ID)%>">open/close</a>]</font></div>
			<%end if%>
			</font></td>
		<td bgcolor="<%=ForumCellAltColor%>" align="center"><font color="<%=ForumFontColor%>"><%=rec2(F_POSTS)%></font></td>
		<td bgcolor="<%=ForumCellColor%>" align="center"><font color="<%=ForumFontColor%>"><%=rec2(F_TOPICS)%></font></td>
		<td bgcolor="<%=ForumCellAltColor%>"><font color="<%=ForumFontColor%>" size="1">
			<%if Len(rec2(F_LASTPOSTER)) > 0 then%>
			<%=FormatDateTime(rec2(F_LASTPOST), vbGeneralDate)%><br>by <a href="<%=MembersFile%>?name=<%=Server.URLEncode(rec2(F_LASTPOSTER))%>" title="View <%=Replace(rec2(F_LASTPOSTER),"**Anonymous**|", "")%>'s info"><b><%=Replace(rec2(F_LASTPOSTER),"**Anonymous**|", "")%></b></a>
			<%end if%>
		</font></td>
		<td bgcolor="<%=ForumCellColor%>" align="center"><font color="<%=ForumFontColor%>">
			<%if Len(rec2(F_MODERATOR)) > 0 then%>
			<a href="<%=MembersFile%>?name=<%=Server.URLEncode(rec2(F_MODERATOR))%>"><%=rec2(F_MODERATOR)%></a></font>
			<%end if%>
		</td>
	</tr>
<%
			rec2.MoveNext
		loop
		rec.MoveNext
		rec2.Close 
	loop
	rec.Close
	set rec = nothing
	set rec2 = nothing
%>

<%	if Session(USER_LEVEL) = 3 then%>
	<tr><td colspan="7" bgcolor="<%=HeadCellColor%>" align="center">
	<a href="<%=AdminFile%>" title="Administration">Administration</a>
	</td></tr>
<%	end if%>

	<tr>
		<td colspan="7" style="padding-top:0px; padding-bottom:0px; padding-left:10px; padding-right:10px; font-size:xx-small" align="right">
		<a href="http://www.saintopatrick.com" target="_blank">StP Forum v1.0</a>
		</td>
	</tr>
</table>


<%
end if

con.Close
set con = nothing
%>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Team Leader Varonis
Israel Israel
I was born in small town Penza, Russia, in October 13th, 1975 yr. So my mother tongue is Russian. I finished the school there and learned in University, then I came to Israel and since then, I live there (or here *s*)
My profession is a C++ programmer under MS Windows platforms, but my hobby is Web development and ASP programming.

I started interesting in computers and programming somewere in 1990-1991 yrs., when my father brought home our first computer - Sinclair ZX Spectrum (he made it by himself). So I learned Basic and joined the Basic programmers club at my school (me and my friend were the only 2 guys from all school there, lol). After I finished the school (1992yr) I decided to continue my study at University and got specialization Operation Systems and Software Engineer. Although I still like my profession, but I always wanted something new, thus I learned HTML, Javascript and ASP which turned to be my hobby Smile | :)

Comments and Discussions