%@ CodePage=65001 Language="VBScript"%>
<% Option Explicit %>
<% sBBSLangPage = "category"
BBS.SetupBBS
dim sCategoryList, iCatLock, bFirstRecord, iCategoryID, SQL, vCategoryList, vForumsList, index, iForumsIndex, iUpperBound
dim iForumsUpperBound, bCanView, sLastThreadLink, sWelcomeCenter, sFragmentWelcome, sLastPosterName
dim bCanViewThread, vForumInfo, vThreadInfo, sLastThreadActivity, sLastThreadSubject, sImageRoot, sVerification
dim vbCategory, bCategoryCollapsed
set vbCategory = new StringBuilder
if not(BBS.HasPermission(PERM_ViewBBS, -1)) then response.redirect sBBSForumRoot & "/logon.asp?error=needregistration"
if request("showall") = "true" then
response.cookies(sBBSCookieRoot & "catlock") = ""
response.cookies(sBBSCookieRoot & "catlock").path = "/"
iBBSCatLock = -1
end if
BBS.SetScheme(0)
' If we're expanding / collapsing a category
if request.querystring("action") = "expand" then
iCategoryID = BBS.ValidateNumeric(request.querystring("cat"))
response.cookies(sBBSCookieRoot & "cat" & iCategoryID & "collapsed") = 0
response.cookies(sBBSCookieRoot & "cat" & iCategoryID & "collapsed").expires = dateadd("m", 2, now)
elseif request.querystring("action") = "collapse" then
iCategoryID = BBS.ValidateNumeric(request.querystring("cat"))
response.cookies(sBBSCookieRoot & "cat" & iCategoryID & "collapsed") = 1
response.cookies(sBBSCookieRoot & "cat" & iCategoryID & "collapsed").expires = dateadd("m", 2, now)
end if
bFirstRecord = True
if len(Trim(request.querystring("catlock"))) > 0 then
iCatLock = BBS.ValidateNumeric(request.querystring("catlock"))
else
iCatLock = BBS.ValidateNumeric(request.cookies(sBBSCookieRoot & "catlock"))
end if
' Generate the forum/category listing
' If the category is locked, then only return records from that category
if iCatLock > 0 then
SQL = "select categoryid, name, url, locked, collapsedbydefault from categories where categoryid=" & BBS.ValidateNumeric(iCatLock) & ";"
else
SQL = "select categoryid, name, url, locked, collapsedbydefault from categories order by sortorder asc;"
end if
rsMaster.open SQL, dbConnection, adOpenForwardOnly, adLockReadOnly
BBS.AddQuery(SQL)
if not(rsMaster.EOF) then
vCategoryList = rsMaster.GetRows
rsMaster.Close
iUpperBound = UBOUND(vCategoryList, 2)
' Generate the category header
vbCategory.append("
" & CRLF)
for index = 0 to iUpperBound
' Work out if the category is collapsed
if len(request.cookies(sBBSCookieRoot & "cat" & vCategoryList(0, index) & "collapsed")) = 0 then
bCategoryCollapsed = vCategoryList(4, index)
else
bCategoryCollapsed = BBS.ValidateBoolean(request.cookies(sBBSCookieRoot & "cat" & vCategoryList(0, index) & "collapsed"))
end if
if iCatLock = vCategoryList(0, index) then bCategoryCollapsed = 0
' Write the category title
dictEnvironment.item("U-CATEGORYIMGURL") = BBS.ValidateField(sBBSForumRoot & "/images/forums/" & vCategoryList(2, index))
dictEnvironment.item("U-CATEGORYLINKALL") = BBS.ValidateField(sBBSForumRoot & "/category-view.asp?showall=true")
dictEnvironment.item("U-CATEGORYLINK") = sBBSForumRoot & "/category-view.asp?catlock=" & vCategoryList(0, index)
dictEnvironment.item("V-CATEGORYID")= vCategoryList(0, index)
dictEnvironment.item("V-CATEGORYNAME")= BBS.ValidateField(vCategoryList(1, index))
dictEnvironment.item("C-ISCATLOCK")= vCategoryList(3, index)
vbCategory.append "
"
' Only select and display the forums if the category isn't collapsed
if bCategoryCollapsed = 0 then
bFirstRecord = True
SQL = "select forums.forumid, forums.lastactivethread, messages.subject, threads.threadid, threads.forumid, threads.totalposts, threads.datecreated, threads.lastactivity, threads.threadsubject, threads.anonymous, threads.closed, threads.timesviewed, threads.sticky, threads.haspoll, threads.pollid, threads.hasattachment, threads.lastposteranonymous, threads.lastpostermemberid, threads.lastposterisregistered, threads.lastposterguestname, threads.memberid, threads.isregistered, threads.guestname, threads.approved, threads.seed, threads.lastpostid from (forums LEFT JOIN threads ON forums.lastactivethread = threads.threadid) LEFT JOIN messages ON threads.lastpostid = messages.messageid WHERE categoryid=" & vCategoryList(0, index) & " order by sortorder asc"
rsMaster.open SQL, dbConnection, adOpenForwardOnly, adLockReadOnly
BBS.AddQuery(SQL)
vThreadInfo = Forum.GetThreadInfoStruct()
if not(rsMaster.EOF) then
vForumsList = rsMaster.GetRows
rsMaster.Close
iForumsUpperBound = UBOUND(vForumsList, 2)
for iForumsIndex = 0 to iForumsUpperBound
vForumInfo = Forum.GetForumInfo(vForumsList(0, iForumsIndex))
vThreadInfo(TI_ThreadID) = vForumsList(0+3, iForumsIndex)
vThreadInfo(TI_ForumID) = vForumsList(1+3, iForumsIndex)
vThreadInfo(TI_TotalPosts) = vForumsList(2+3, iForumsIndex)
vThreadInfo(TI_DateCreated) = vForumsList(3+3, iForumsIndex)
vThreadInfo(TI_LastActivity) = vForumsList(4+3, iForumsIndex)
vThreadInfo(TI_Subject) = vForumsList(5+3, iForumsIndex)
vThreadInfo(TI_Anonymous) = vForumsList(6+3, iForumsIndex)
vThreadInfo(TI_Closed) = vForumsList(7+3, iForumsIndex)
vThreadInfo(TI_TimesViewed) = vForumsList(8+3, iForumsIndex)
vThreadInfo(TI_Sticky) = vForumsList(9+3, iForumsIndex)
vThreadInfo(TI_HasPoll) = vForumsList(10+3, iForumsIndex)
vThreadInfo(TI_PollID) = vForumsList(11+3, iForumsIndex)
vThreadInfo(TI_HasAttachment) = vForumsList(12+3, iForumsIndex)
vThreadInfo(TI_LastPosterAnonymous) = vForumsList(13+3, iForumsIndex)
vThreadInfo(TI_LastPosterMemberID) = vForumsList(14+3, iForumsIndex)
vThreadInfo(TI_LastPosterIsRegistered)= vForumsList(15+3, iForumsIndex)
vThreadInfo(TI_LastPosterGuestName) = vForumsList(16+3, iForumsIndex)
vThreadInfo(TI_MemberID) = vForumsList(17+3, iForumsIndex)
vThreadInfo(TI_IsRegistered) = vForumsList(18+3, iForumsIndex)
vThreadInfo(TI_GuestName) = vForumsList(19+3, iForumsIndex)
vThreadInfo(TI_Approved) = vForumsList(20+3, iForumsIndex)
vThreadInfo(TI_Seed) = vForumsList(21+3, iForumsIndex)
vThreadInfo(TI_LastPostID) = vForumsList(22+3, iForumsIndex)
bCanView = BBS.HasPermission(PERM_FORUMVIEW, vForumInfo(FI_ForumID))
bCanViewThread = BBS.HasPermission(PERM_FORUMACCESS, vForumInfo(FI_ForumID))
if bCanView then
' If this is the first forum in a category, write the forum fields
if bFirstRecord = True then
vbCategory.append ""
vbCategory.append "" & CRLF
vbCategory.append ""
vbCategory.append "" & CRLF
vbCategory.append "
" & CRLF
bFirstRecord = False
end if
' Write the forum
dictEnvironment.item("U-FORUMLINK") = sBBSForumRoot & "/forums/forum-view.asp?fid=" & vForumInfo(FI_ForumID)
dictEnvironment.item("U-IMGURL") = BBS.ValidateField(sBBSForumRoot & "/images/forums/" & vForumInfo(FI_URL))
dictEnvironment.item("V-FORUMNAME") = vForumInfo(FI_ForumName)
dictEnvironment.item("V-DESCRIPTION") = vForumInfo(FI_ForumDescription)
if bCanView then
dictEnvironment.item("V-THREADCOUNT") = vForumInfo(FI_ThreadCount)
dictEnvironment.item("V-POSTCOUNT") = vForumInfo(FI_PostCount)
else
dictEnvironment.item("V-THREADCOUNT") = ""
dictEnvironment.item("V-POSTCOUNT") = ""
end if
' Show the last active thread in the forum
if dictConfiguration("bCATEGORYLINKLASTTHREAD") = 1 and bCanViewThread then
sLastThreadLink = sBBSForumRoot & "/forums/thread-view.asp?tid=" & vForumInfo(FI_LastActiveThread) & "&posts=" & vThreadInfo(TI_TotalPosts) & "&mid=" & BBS.ValidateField(vThreadInfo(TI_LastPostID)) & "#M" & BBS.ValidateField(vThreadInfo(TI_LastPostID))
if vThreadInfo(TI_Approved) = 0 then
sLastThreadSubject = dictLanguage("GLOBAL-UNAPPROVED")
else
sLastThreadSubject = BBS.FilterView(BBS.ValidateField(vForumsList(2, iForumsIndex)))
end if
if vThreadInfo(TI_LastPosterAnonymous) = 0 then
if vThreadInfo(TI_LastPosterIsRegistered) = 1 then
sLastPosterName = BBS.CreateUsernameLinkbyId(vThreadInfo(TI_LastPosterMemberID)) & BBS.ValidateField(vThreadInfo(TI_LastPosterGuestName)) & ""
else
sLastPosterName = "" & BBS.ValidateField(vThreadInfo(TI_LastPosterGuestName)) & ""
end if
else
sLastPosterName = "" & dictLanguage.item("CATEGORY-8") & ""
end if
sLastThreadActivity = BBS.GetShortDateTime(vThreadInfo(TI_LastActivity))
else
sLastThreadSubject = ""
sLastThreadLink = ""
sLastPosterName = ""
sLastThreadActivity = ""
end if
if sLastThreadSubject = "" then
dictEnvironment.item("C-SHOWLASTTHREAD") = False
else
dictEnvironment.item("C-SHOWLASTTHREAD") = BBS.ValidateBoolean(bCanViewThread)
end if
dictEnvironment.item("V-LASTTHREADSUBJECT") = sLastThreadSubject
dictEnvironment.item("V-LINKLASTTHREAD") = sLastTHreadLink
dictEnvironment.item("V-LASTPOSTER") = sLastPosterName
dictEnvironment.item("V-LASTACTIVITY") = sLastThreadActivity
dictEnvironment.item("V-MODERATORLIST") = BBS.ListMembers (MODULE_FORUMS, USERLEVEL_Moderator, vForumInfo(FI_ForumID))
' CATEGORY ROW
vbCategory.append ("" & CRLF )
vbCategory.append ("")
vbCategory.append ("  & ") | " & CRLF)
vbCategory.append ("")
vbCategory.append (" " & BBS.ValidateField(dictEnvironment.item("V-FORUMNAME")) & " " & CRLF)
if len(dictEnvironment("V-DESCRIPTION")) > 0 then
vbCategory.append (" " & dictEnvironment("V-DESCRIPTION") & " ")
end if
if len(dictEnvironment.item("V-MODERATORLIST")) > 0 then
vbCategory.append ("" & dictLanguage("CATEGORY-5") & ": " & dictEnvironment.item("V-MODERATORLIST") & " ")
end if
vbCategory.append (" | ")
vbCategory.append ("" & dictEnvironment.item("V-THREADCOUNT") & " | " & CRLF)
vbCategory.append ("" & dictEnvironment.item("V-POSTCOUNT") & " | " & CRLF)
vbCategory.append ("")
if dictEnvironment.item("C-SHOWLASTTHREAD") = 1 then
vbCategory.append (" ")
if len(dictEnvironment("V-LASTTHREADSUBJECT")) > 35 then
vbCategory.append ("" & left(dictEnvironment("V-LASTTHREADSUBJECT"), 35) & "... ")
else
vbCategory.append ("" & dictEnvironment("V-LASTTHREADSUBJECT") & " ")
end if
vbCategory.append ("> " & dictEnvironment("V-LASTACTIVITY") & " " & dictLanguage("CATEGORY-21") & " " & dictEnvironment("V-LASTPOSTER"))
end if
vbCategory.append (" |
" & CRLF)
end if
next
sBBSFragmentOutput = ""
' CATEGORY FOOTER
if bFirstRecord = False then
vbCategory.append("
")
else
vbCategory.append("| " & dictLanguage("CATEGORY-26") & " |
")
end if
else
rsMaster.Close
vbCategory.append("| " & dictLanguage("CATEGORY-25") & " |
")
end if
end if
next
'sCategoryList = sCategoryList & "
"
end if
' Newsbox
dictEnvironment("C-SHOWNEWSBOX") = dictConfiguration("bENABLENEWSBOX")
dictEnvironment("C-SHOWLOGON") = (iBBSMemberID <= 0) and dictConfiguration("bNEWSQUICKLOGIN")
dictEnvironment("C-SHOWYOURS") = (iBBSMemberID > 0)
dictEnvironment("C-NEWSTODAYSVISITORS") = dictConfiguration("bNEWSTODAYSVISITORS")
dictEnvironment("C-NEWSBANNER") = len(dictConfiguration("sNEWSBANNER")) > 0
dictEnvironment("C-NEWSQUICKLOGIN") = dictConfiguration("bNEWSQUICKLOGIN")
dictEnvironment("C-NEWSFORUM") = dictConfiguration("iNEWSFORUM") > 0
if dictEnvironment("C-SHOWNEWSBOX") then
dictEnvironment("V-NEWSFORUM") = BBS.ValidateNumeric(dictConfiguration("iNEWSFORUM"))
if dictEnvironment("V-NEWSFORUM") > 0 then
dictEnvironment("V-NEWSTHREAD") = Forum.GetThreadInfo(Forum.GetForumInfo(dictEnvironment("V-NEWSFORUM"))(FI_LastActiveThread))
dictEnvironment("U-NEWSTHREAD") = sBBSForumRoot & "/forums/thread-view.asp?tid=" & dictEnvironment("V-NEWSTHREAD")(TI_ThreadID)
end if
if dictEnvironment("C-NEWSTODAYSVISITORS") then
dictEnvironment("V-NEWSTODAYSVISITORS") = BBS.GetComplexVariable(CV_SessionsToday)
end if
dictEnvironment("V-NEWSBANNER") = dictConfiguration("sNEWSBANNER")
end if
if dictEnvironment("C-SHOWLOGON") and dictConfiguration("bLOGONVERIFICATION") then
session("verification") = BBS.GenerateVerificationCode()
sImageRoot = sBBSForumRoot & "/images/verification-image.asp?small=1&nocache=" & timer & "&template=" & mid(sBBSTemplateRoot, instr(sBBSTemplateRoot, "templates/")+10) & "&digit="
sVerification = ""
for index = 1 to 6
sVerification = sVerification & " "
next
sVerification = sVerification & " |
"
dictEnvironment("V-VERIFICATION") = sVerification
dictEnvironment("C-VERIFICATION") = 1
else
dictEnvironment("C-VERIFICATION") = 0
end if
dictEnvironment("U-LOGON") = "logon.asp"
dictEnvironment("U-SEARCHTODAY") = sBBSForumRoot & "/search/query.asp?action=search&collapsethreads=1&searchforumid=all&keywords=&author=&days=0"
dictEnvironment("U-SEARCHYOURS") = sBBSForumRoot & "/search/query.asp?action=search&collapsethreads=1&searchforumid=all&keywords=&author=" & BBS.ValidateURL(BBS.GetUserInfoById(iBBSMemberID)(UI_Username)) & "&days=30"
dictEnvironment("U-SEARCHUNANSWERED") = sBBSForumRoot & "/search/query.asp?action=search&filter=noreplies&collapsethreads=1&searchforumid=all&keywords=&author=&days=30"
dictEnvironment.item("C-STATSLOCATION") = dictConfiguration.item("sCATEGORYSTATISTICSLOCATION")
dictEnvironment.item("C-RSSLOCATION") = dictConfiguration.item("sRSSLOCATION")
dictEnvironment.add "V-CATEGORYLIST", vbCategory.ToString() & ""
vbCategory.Clear
sBBSFragmentOutput = ""
if dictEnvironment.item("C-STATSLOCATION") = "TOP" or dictEnvironment.item("C-STATSLOCATION") = "BOTTOM" then dictEnvironment.add "V-WELCOMEBOX", Extender.WriteInfoCenter()
if dictEnvironment.item("C-RSSLOCATION") = "TOP" or dictEnvironment.item("C-RSSLOCATION") = "BOTTOM" then dictEnvironment.add "V-RSSBOX", Extender.WriteRSSBox()
dictEnvironment.add "V-TITLE", dictLanguage.item("CATEGORY-TITLE") & " - " & BBS.ValidateField(dictConfiguration("sBBSNAME"))
dictEnvironment.add "C-SHOWRANDOMQUOTES", dictConfiguration("bDISPLAYBBSQUOTES")
if iBBSUserLevel >= USERLEVEL_SupportAdministrator then dictEnvironment.add "C-SHOWADMINLINK", 1
dictEnvironment.item("V-METATAG") = ""
'Load page
%>
<% Filesystem.ExecuteBBSTemplate("/category-view.asp") %>