Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

The Code Project Discussion boards

, , 25 Aug 2001
The Discussion board ASP scripts as used in The Code Project. This is an open source project for the Code Project community.
CodeProject-asp-forum.zip
CodeProject-asp-forum
_vti_cnf
img_forum
admin_del.gif
admin_delall.gif
admin_modify.gif
ind.gif
news_none.gif
news_selected.gif
news_unselected.gif
smiley_biggrin.gif
smiley_frown.gif
smiley_redface.gif
smiley_smile.gif
smiley_wink.gif
t.gif
images
blind.gif
t.gif
_vti_cnf
t.gif
blind.gif
forum
_vti_cnf
files
forum.inc.bak
_vti_cnf
forum.inc.bak
database
forum.mdb
CodeProject-AspForum-AX.zip
src
app
AspForum.aps
AspForum.clw
AspForum.def
AspForum.dsp
AspForum.tlb
AspForumps.def
AspForumps.mk
Forum2.rgs
AspForum.dsw
AspForum.opt
common
MemoryEx.inl
foreign
hightime.inl
CodeProject-forum.zip
CodeProject-forum
Common
forum
app
Includes
bin
AspForum.dll
data
forum.mdb
Images
admin_del.gif
admin_delall.gif
admin_modify.gif
IND.GIF
news_none.gif
news_selected.gif
news_unselected.gif
smiley_biggrin.gif
smiley_confused.gif
smiley_cool.gif
smiley_eek.gif
smiley_frown.gif
smiley_mad.gif
smiley_redface.gif
smiley_rolleyes.gif
smiley_smile.gif
smiley_tongue.gif
smiley_wink.gif
t.gif
DELETE.GIF
MODIFY.GIF
RED.GIF
WHITE.GIF
NEW.GIF
cplogo.gif
CodeProject-php-forum.zip
css
img_forum
admin_del.gif
admin_delall.gif
admin_modify.gif
cplogo.gif
DELETE.GIF
IND.GIF
MODIFY.GIF
NEW.GIF
news_new.gif
news_none.gif
news_selected.gif
news_unselected.gif
RED.GIF
smiley_biggrin.gif
smiley_confused.gif
smiley_cool.gif
smiley_eek.gif
smiley_frown.gif
smiley_mad.gif
smiley_redface.gif
smiley_rolleyes.gif
smiley_smile.gif
smiley_tongue.gif
smiley_wink.gif
t.gif
WHITE.GIF
<% option explicit 

' ###########################################################################
' #
' # file:
' # 	index.asp
' #
' # description:
' # 	start file for the forum.
' #
' # version:
' # 	2000-02-06 Uwe Keim   file created.
' #
' # copyright:
' #		Written by Uwe Keim <keim@zeta-software.de>
' #		Adapted by Chris Maunder <cmaunder@mail.com>
' #		Copyright (c) 1998-2000. All Rights Reserved.
' # 
' # 	Check the Code Project (http://www.codeproject.com) for the latest.
' # 
' #		These scripts may be used in any way you desire PROVIDING the 
' #		'"powered by CodeProject" logo remains in the top left corner of the
' #		front index page. This file may be redistributed unmodified by any 
' #		means PROVIDING it is not sold for profit without the authors written 
' #		consent, and providing that this notice and the authors' name and all
' #		copyright notices remains intact. 
' # 
' #		An email letting us know how you are using it would be nice as well. 
' # 
' #		This file is provided "as is" with no expressed or implied warranty.
' #		The author accepts no liability for any damage/loss of business that
' #		this product may cause.
' # 
' ###########################################################################

%>
<!--#include file="../common/scripts.asp"-->
<!--#include file="includes/locafx.inc"-->
<%

Dim strTitle, strDesc, strUpdate, forum_id, forum_name
strTitle   = "Welcome to the Code Project discussion boards"
strDesc    = "Please choose a discussion forum from the list below"
strUpdate  = "15 Jun 2000"
forum_id   = Request.QueryString("forumid")
forum_name = Request.QueryString("forum")


' ///////////////////////////////////////////////////////////////////
' // prepare the forum id.
	
' select the forum that is specified in the parameters for that page.
' the caller may have either specified a forum id or the short-name of a forum.
	
' translate forum name to forum id (if no id present).
if forum_id="" and forum_name<>"" then
	forum_id = fh.getForumId( forum_name )
end if

if forum_id <> "" Then
 	fh.getForumDetails forum_id, strTitle, strDesc 
End If

%><!-- #include file="includes/header.asp" --><%	

' ///////////////////////////////////////////////////////////////////
' // Get the type of view (expanded/collapsed etc)

Dim Expanded
Expanded = Request.QueryString("exp")
if Expanded = "" Then 
	Expanded = Session("expand")
	if Expanded = "" Then 
		Expanded = Request.Cookies("expand")
		if Expanded <> "" Then Session("expand") = Expanded
	End If
End If
if Expanded <> "" Then fh.setExpandedView(Expanded)

' ///////////////////////////////////////////////////////////////////
' // Get the LastVisit - it's set in LastVisit.asp

Dim LastVisit
LastVisit = Session("LastVisit")

' Look for a "DateFilter" value in the Session object, and if no value
' there, look for it in a cookie. If we get a value then set the
' forum objects filter type as that value. This "DateFilter"
' value will be stored in the Session object and cookies collection
' when the user hits the "Refresh" button. Until then it will remain
' remain at the default value
Dim DateFilter
DateFilter = Request.QueryString("df")
if DateFilter = "" Then 
	DateFilter = Session("DateFilter")
	if DateFilter = "" Then 
		DateFilter = Request.Cookies("DateFilter")
		if DateFilter <> "" Then Session("DateFilter") = DateFilter
	End If
End If
if DateFilter <> "" Then fh.setDateFilterStart DateFilter, LastVisit

' ///////////////////////////////////////////////////////////////////
' // prepare row count.

if forum_id<>"" then
		
	' messages per page
	Dim MessagesPerPage
	MessagesPerPage = Request.QueryString("app")
	if MessagesPerPage = "" Then 
		MessagesPerPage = Session("MPP")
		if MessagesPerPage = "" Then 
			MessagesPerPage = Request.Cookies("MPP")
			if MessagesPerPage = "" Then MessagesPerPage = 10
			Session("MPP") = MessagesPerPage
		End If
	End If
	if MessagesPerPage <> "" Then fh.setArticlesPerPage(MessagesPerPage)
		
	if fh.getFirstRow() = "" Then fh.setFirstRow("1")
	
	Dim StartRow, EndRow, RowCount, CommentCount
	Dim PrevRow, NextRow, LastRow
	CommentCount = CInt(fh.getSelectedArticleRsCount(forum_id, fh.getDateFilterStart, "", fh.getKeywordsFilter))	' Number of comments
	RowCount = fh.getArticlesPerPage()					' Number to show per page

	'Response.Write "<br>RowCount: " & RowCount
	'Response.Write "<br>Start date: " & fh.getDateFilterStart

	if RowCount = "All" Then							' Special case
		StartRow = 1
		RowCount = CommentCount
	Else
		StartRow = CInt(fh.getFirstRow())				' First row on page to start showing
		RowCount = CInt(RowCount)
	End If
	if StartRow > CommentCount Then StartRow = 1 
	
	EndRow = StartRow + RowCount-1						' Last row on page to show
	if EndRow > CommentCount Then EndRow = CommentCount

	PrevRow = StartRow - RowCount						' Start of previous page's rows
	if PrevRow < 1 Then PrevRow = 1

	NextRow = EndRow + 1								' Start of next pages rows. May be > CommentCount		

	if RowCount <> 0 Then
		Dim remainder
		remainder = CommentCount mod RowCount
	    if remainder = 0 Then
		    LastRow = CommentCount - RowCount + 1
	    else
		    LastRow = CommentCount - remainder + 1
	    End If
	End if

	if LastRow < 1 Then LastRow = 1						' Start of last pages rows 

	' ///////////////////////////////////////////////////////////////////
	' // Form for selecting date, messages per page etc.

	' helper function for writing the date option-comobobox values
	' and automatically selecting the current.
	sub writeDateOption(str, text, can_empty)
		if ( fh.getDateFilterStartType=str or _
			             ((fh.getDateFilterStartType="") and can_empty) ) then
			Response.Write "<option selected value=""" &str& """>" &text& "</option>" &vbCrLf
		else
			Response.Write "<option value=""" &str& """>" &text& "</option>" &vbCrLf
		end if
	end sub

	sub writeAPPOption( str, can_empty )
		if (fh.getArticlesPerPage=str) or ((fh.getArticlesPerPage="") and can_empty) then
			Response.Write "<option selected value=""" &str& """>" &str& "</option>" &vbCrLf
		else
			Response.Write "<option value=""" &str& """>" &str& "</option>" &vbCrLf
		end if
	end sub

	sub writeExpandOption( value, text, can_empty )
		if (fh.getExpandedView=value) or ((fh.getExpandedView="") and can_empty) then
			Response.Write "<option selected value=""" &value& """>" &text& "</option>" &vbCrLf
		else
			Response.Write "<option value=""" &value& """>" &text& "</option>" &vbCrLf
		end if
	end sub
%>
<br><br>
<table border=0 bgcolor="#FF9900" width=100% cellspacing=1>
<form action="<%=fh.getUriDoFilterMessages%>" method="post">
<tr><td>

<table width=100% border=0><tr>
<td width=100%><b><font color=white>&nbsp;</font></b></td>
<td nowrap valign=top>
	<font size="1" style="font-size:8pt" face="Verdana">Messages since </font>
	<select size="1" name="datefilter" style="font-size:8pt">
		<%
		if LastVisit<>"" Then
			writeDateOption datefilterLastVisit, "Since "&DateTimeString(LastVisit,True), false
		End if
		writeDateOption datefilterLastDay,  "Last Day"     , false
		writeDateOption datefilterLastWeek, "Last Week"    , false
		writeDateOption datefilterLastMonth,"Last Month"   , false
		writeDateOption datefilterLastHalf, "Last 6 Months", false
		writeDateOption datefilterLastYear, "Last Year"    , false
		writeDateOption datefilterAll,      "All"          , true
		%>
	</select>&nbsp;&nbsp;
</td>
<%
' ////////////////////////////////////////////////////////////
' Expand/Collapse
%>
<td nowrap valign=top>
	<font size="1" style="font-size:8pt" face="Verdana">View </font>
	<select size="1" name="expand" style="font-size:8pt"><%
        writeExpandOption expandNone, "Normal", True 
        'writeExpandOption expandCollapse, "Collapsed", False	- Not yet implemented
        writeExpandOption expandPreview, "Preview", False 
	%></select>&nbsp;&nbsp;
</td>
<%
' ////////////////////////////////////////////////////////////
%>
<td nowrap valign=top>
	<font size="1" style="font-size:8pt" face="Verdana">Per page </font>
	<select size="1" name="perpage" style="font-size:8pt">
		<%writeAPPOption  "5", false%>
		<%writeAPPOption  "10", false%>
		<%writeAPPOption  "25", true%>
		<%writeAPPOption  "50", false%>
		<%writeAPPOption "100", false%>
		<%'writeAPPOption "All", true%>
	</select>
</td>
<td valign=top><input type="submit" value="Refresh" name="submit" class=FormButton></td>
</tr></table>

</td></tr></form>

<tr bgcolor=#FBEDBB><td>
<% 
' ///////////////////////////////////////////////////////////////////
' // link for new message, message count, then navigation links

%><table border=0 width=100% bgcolor=#FBEDBB><tr>
<td><font size="1" face="Verdana" style="font-size:8pt"><a href="<%=fh.getUriUserNew(forum_id)%>" target="_top" title="<%=IDS_FORUM_NEW_TITLE%>"><%=IDS_FORUM_LIST_NEW%></a></font></td>
<% if CommentCount<>"0" Then %>
<td><font size="1" face="Verdana" style="font-size:8pt">
Messages <%=StartRow%> to <%=EndRow%> of <%=CommentCount%> (Total: <%=fh.getCommentCount(forum_id)%>)
</td>
<% Else %>
<td><font size="1" face="Verdana" style="font-size:8pt">Total Messages for this article: <%=fh.getCommentCount(forum_id)%></td>
<% end if %>

<% if CommentCount<>"0" Then %>
<td align=right><font face="verdana" size="1" style="font-size:8pt">
<% if StartRow <> "1" Then %>
<a href="<%=fh.getUriRow(0, "1")%>">First</a> |
<% Else %>
First |
<% End If %>
<% if StartRow <> "1" Then %>
<a href="<%=fh.getUriRow(0, PrevRow)%>">Prev</a> |
<% Else %>
Prev |
<% End If %>
<% if StartRow + RowCount <= CommentCount Then %>
<a href="<%=fh.getUriRow(0, NextRow)%>">Next</a> |
<% Else %>
Next |
<% End If %>
<% if StartRow + RowCount <= CommentCount Then %>
<a href="<%=fh.getUriRow(0, LastRow)%>">Last</a>
<% Else %>
Last
<% End If %>
</font></td>
<% end if %>
</tr></table>

</td></tr><tr><td bgcolor=white>
<%
' ///////////////////////////////////////////////////////////////////
' // in admin mode, show link to change forum properties

if fh.isInAdminMode then
	%><p><font size="1" face="Verdana">[<a href="<%=fh.getUriAdminModifyForum(forum_id)%>" target="_top"><%=IDS_FORUM_LIST_ADMINFORUM%></a>]</font></p><%
end if

' ///////////////////////////////////////////////////////////////////
' // include the actual article list.
%>
<!--#include file="includes/main.asp"-->
<%
' ///////////////////////////////////////////////////////////////////
' // Navigation links
%>	
</td></tr></table>
<%
else
	set rsForums = fh.getForumsRs
%>

<table border=0 width="100%" cellspacing=7>
<tr valign=bottom><td><b>Forum</b></td><td><b>Description</b></td><td align=right><b>Total</b></td>
<%if LastVisit<>"" Then%>
<td align=right nowrap><b>New<sup>*</sup></b></td>
<% Else %>
<td>&nbsp;</td>
<% End If %>
</tr>
<tr><td colspan=4><hr size=1 width=100% noshade></td></tr>
<%
	rsForums.MoveFirst
	while not rsForums.Eof

		Dim id
		id = rsForums("ID")
		strTitle = rsForums("Name")
		strDesc = rsForums("Description")

		Response.Write "<tr valign=top>"
		Response.Write "<td nowrap><a href='" &myself& "?forumid=" &id& "'>" & strTitle & "</a></td>" & vbCRLF
		Response.Write "<td>" & strDesc & "</td>" & vbCRLF
		Response.Write "<td align=right>" & fh.getCommentCount(id) & "</td>"
		if LastVisit<>"" Then
			Response.Write "<td align=right>" & fh.getNewCommentCount(id, LastVisit) & "</td>"
		Else
			Response.Write "<td align=right>&nbsp;</td>"
		End If
		Response.Write "</tr>" & vbCRLF

		rsForums.MoveNext
	wend
		
	rsForums.close
	set rsForums = nothing

	%><tr><td colspan=4><hr size=1 width=100% noshade><br><% 

	if LastVisit<>"" Then 
		%><sup>*</sup>New messages since <%=DateTimeString(LastVisit, False)%>. Local time is <%=DateTimeString(Now(), False)%></td></tr><% 
	End If 
	
%>
</table>
		
<%end if %>
<!--#include file="includes/cleanup.inc"-->
<!--#include file="includes/footer.asp" -->

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Authors

Chris Maunder
Founder CodeProject
Canada Canada
Chris is the Co-founder, Administrator, Architect, Chief Editor and Shameless Hack who wrote and runs The Code Project. He's been programming since 1988 while pretending to be, in various guises, an astrophysicist, mathematician, physicist, hydrologist, geomorphologist, defence intelligence researcher and then, when all that got a bit rough on the nerves, a web developer. He is a Microsoft Visual C++ MVP both globally and for Canada locally.
 
His programming experience includes C/C++, C#, SQL, MFC, ASP, ASP.NET, and far, far too much FORTRAN. He has worked on PocketPCs, AIX mainframes, Sun workstations, and a CRAY YMP C90 behemoth but finds notebooks take up less desk space.
 
He dodges, he weaves, and he never gets enough sleep. He is kind to small animals.
 
Chris was born and bred in Australia but splits his time between Toronto and Melbourne, depending on the weather. For relaxation he is into road cycling, snowboarding, rock climbing, and storm chasing.
Follow on   Twitter   Google+   LinkedIn

Uwe Keim
Chief Technology Officer Zeta Producer Desktop CMS
Germany Germany
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.
 
In his free time, he does climbing, running and mountain biking. Recently he became a father of a cute boy.
 
Some cool, free software from us:
 
Free Test Management Software - Intuitive, competitive, Test Plans. Download now!  
Homepage erstellen - Intuitive, very easy to use. Download now!  
Send large Files online for free by Email
Offline-Homepage-Baukasten

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 26 Aug 2001
Article Copyright 2000 by Chris Maunder, Uwe Keim
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid