<%
'#################################################################################
'## Copyright (C) 2000  Michael Anderson
'## 
'## This program is free software; you can redistribute it and/or
'## modify it under the terms of the GNU General Public License
'## as published by the Free Software Foundation; either version 2
'## of the License, or any later version.
'## 
'## This program is distributed in the hope that it will be useful,
'## but WITHOUT ANY WARRANTY; without even the implied warranty of
'## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'## GNU General Public License for more details.
'## 
'## You should have received a copy of the GNU General Public License
'## along with this program; if not, write to the Free Software
'## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
'## 
'## Correspondence and Questions can be sent to:
'## reinhold@bigfoot.com
'## 
'## or
'## 
'## Snitz Communications 
'## C/O: Michael Anderson
'## PO Box 200
'## Harpswell, ME 04079
'#################################################################################
%>
<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="inc_functions.asp" -->
<!--#INCLUDE FILE="inc_top.asp" -->
<%
if IsEmpty(Session("last_here_date")) then
	Session("last_here_date") = ReadLastHereDate(Request.Cookies("User")("Name"))
end if

set rs1 = Server.CreateObject("ADODB.Recordset")

'## Forum_SQL
strSql = "SELECT " & strTablePrefix & "TOTALS.P_COUNT, " & strTablePrefix & "TOTALS.T_COUNT, " & strTablePrefix & "TOTALS.U_COUNT "
strSql = strSql & " FROM " & strTablePrefix & "TOTALS"

rs1.open strSql, my_Conn

Users = rs1("U_COUNT")
Topics = rs1("T_COUNT")
Posts = rs1("P_COUNT")

rs1.Close
set rs1 = nothing

'## Forum_SQL - Get all Forums From DB
strSql = "SELECT " & strTablePrefix & "CATEGORY.CAT_ID, " & strTablePrefix & "CATEGORY.CAT_STATUS, " & strTablePrefix & "CATEGORY.CAT_NAME "
strSql = strSql & " FROM " & strTablePrefix & "CATEGORY "
strSql = strSql & " ORDER BY " & strTablePrefix & "CATEGORY.CAT_NAME ASC;"

set rs = my_Conn.Execute (strSql)
%>
<table width="95%" border="0" align="center">
<tr>
    <td><font face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>"> 
      Ultima visita: <% =ChkDate(session("last_here_date")) %> - <% =ChkTime(session("last_here_date")) %> 
      </font></td>
    <td align=right><font face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>"> 
      <% =Posts %>
      messaggi in 
      <% =Topics %>
      forum da 
      <% =Users %>
      autori&nbsp;&nbsp;</font></td>
  </tr>
</table>

<table border=0 width="95%" cellspacing=0 cellpadding=0 align=center>
  <tr>
    <td bgcolor="<% =strTableBorderColor %>">
    <table border=0 width="100%" cellspacing=1 cellpadding=4>
      <tr>
        <td align=center bgcolor="<% =strHeadCellColor %>" nowrap><b>&nbsp;</td>
          <td align=center bgcolor="<% =strHeadCellColor %>" nowrap><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>">FORUM</font></b></td>
          <td align=center bgcolor="<% =strHeadCellColor %>" nowrap><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>">TITOLO</font></b></td>
          <td align=center bgcolor="<% =strHeadCellColor %>" nowrap><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>">MESSAGGI</font></b></td>
          <td align=center bgcolor="<% =strHeadCellColor %>" nowrap><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>">ULTIMA 
            VISITA </font></b></td>
<% if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then %>
          <td align=center bgcolor="<% =strHeadCellColor %>" nowrap><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>">MODERATORE</font></b></td>
<% end if %>
<% if (mlev = 4 or mlev = 3) or (lcase(strNoCookies) = "1") then %>
        <td align=center bgcolor="<% =strHeadCellColor %>">
        <% PostingOptions() %>
        </td>
<% end if %>
      </tr>
<% If rs.EOF or rs.BOF then %>
      <tr>
        <td bgcolor="<% =strCategoryCellColor %>" colspan="<% if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then Response.Write("6") else Response.Write("5")%>"><font face="<% =strDefaultFontFace %>" color="<% =strCategoryFontColor %>" size="<% =strDefaultFontSize %>"><b>No Categories/Forums Found</b></font></td>
<%	if (mlev = 4 or mlev = 3) then %>
        <td bgcolor="<% =strCategoryCellColor %>"><font face="<% =strDefaultFontFace %>" color="<% =strCategoryFontColor %>" size="<% =strDefaultFontSize %>">&nbsp;</font></td>
<%	end if %>
      </tr>
<% Else %>
<%	do until rs.EOF %>
<%
		'## Forum_SQL - Build SQL to get forums via category
		strSql = "SELECT " & strTablePrefix & "FORUM.FORUM_ID, " & strTablePrefix & "FORUM.F_STATUS, " & strTablePrefix & "FORUM.CAT_ID, " & strTablePrefix & "FORUM.F_SUBJECT, " & strTablePrefix & "FORUM.F_URL, " & strTablePrefix & "FORUM.F_DESCRIPTION, " & strTablePrefix & "FORUM.CAT_ID, " & strTablePrefix & "FORUM.F_TOPICS, " & strTablePrefix & "FORUM.F_COUNT, " & strTablePrefix & "FORUM.F_LAST_POST, " & strTablePrefix & "FORUM.F_STATUS, " & strTablePrefix & "FORUM.F_TYPE "
		strSql = strSql & " FROM " & strTablePrefix & "FORUM "
		strSql = strSql & " WHERE " & strTablePrefix & "FORUM.CAT_ID = " & rs("CAT_ID") & " "
		strSql = strSql & " ORDER BY " & strTablePrefix & "FORUM.F_SUBJECT ASC;"

		set rsForum =  my_Conn.Execute (strSql)
		
		chkDisplayHeader = true
		 
		if rsForum.eof or rsForum.bof then
%>

      <tr>
        <td bgcolor="<% =strCategoryCellColor %>" colspan="<% if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then Response.Write("6") else Response.Write("5") end if%>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strCategoryFontColor %>" size"+1"><b><% =ChkString(rs("CAT_NAME"),"display") %></b></font></td>
<%		if (mlev = 4 or mlev = 3) or (lcase(strNoCookies) = "1") then %>
        <td bgcolor="<% =strCategoryCellColor %>" align=center valign=top nowrap><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>">
        <% call CategoryAdminOptions() %>
        </font></b></td>
<%		end if %>
      </tr>


<%
		
			Response.Write "  <tr>" & vbCrLf
			Response.Write "    <td bgcolor=""" & strForumCellColor & """ colspan="
			if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then 
				Response.Write """6""" 
			else 
				Response.Write """5"""
			end if
			Response.Write "><font face=""" & strDefaultFontFace & """ color=""" & strForumFontColor & """ size=""" & strDefaultFontSize & """><b>No Forums Found</b></font></td>" & vbCrLf
			if (mlev = 4 or mlev = 3) then
				Response.Write "    <td bgcolor=""" & strForumCellColor & """><font face=""" & strDefaultFontFace & """ color=""" & strForumFontColor & """ size=""" & strDefaultFontSize & """>&nbsp;</font></td>" & vbCrLf
			end if
			Response.Write "  </tr>" & vbCrLf
		else
			do until rsForum.Eof
				if ChkDisplayForum(rsForum("FORUM_ID")) then
					if chkDisplayHeader then
%>

      <tr>
        <td bgcolor="<% =strCategoryCellColor %>" colspan="<% if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then Response.Write("6") else Response.Write("5") end if%>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strCategoryFontColor %>" size"+1"><b><% =ChkString(rs("CAT_NAME"),"display") %></b></font></td>
<%		if (mlev = 4 or mlev = 3) or (lcase(strNoCookies) = "1") then %>
        <td bgcolor="<% =strCategoryCellColor %>" align=center valign=top nowrap><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>">
        <% call CategoryAdminOptions() %>
        </font></b></td>
<%		end if %>
      </tr>


<%
						chkDisplayHeader = false
					end if
%>
      <tr>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top>
<%					if rsForum("F_TYPE") = 0 then %>
<%						if rs("CAT_STATUS") = 0 then %>
        <a href="FORUM.asp?FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>"><img src="icon_folder_locked.gif" border=0 hspace=0 alt="Category Closed"></a>
<%						else %>
<%							if rsForum("F_STATUS") <> 0 then %>
        <a href="FORUM.asp?FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>"><% =ChkIsNew(rsForum("F_LAST_POST")) %></a>
<%							else %>
        <a href="FORUM.asp?FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>"><img src="icon_folder_locked.gif"  border=0 hspace=0 alt="FORUM Closed"></a>
<%							end if %>
<%						end if %>
<%					else %>
<%						if  rsForum("F_TYPE") = 1 then %>
        <a href="<% =rsForum("F_URL") %>"><img src="icon_url.gif"  border=0 hspace=0></a>
<%						end if %>
<%					end if %>
        </td>
        <td<% if rsForum("F_TYPE") = 1 then Response.Write(" colspan=4") %> bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><a href="<% if rsForum("F_TYPE") = 0 then Response.Write("FORUM.asp?FORUM_ID=" & rsForum("FORUM_ID") & "&CAT_ID=" & rsForum("CAT_ID") & "&Forum_Title=" & ChkString(rsForum("F_SUBJECT"),"urlpath")) else if rsForum("F_TYPE") = 1 then Response.Write(rsForum("F_URL")) end if %>"><% =ChkString(rsForum("F_SUBJECT"),"display") %></a><br>
        <font color="<% =strForumFontColor %>" face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>">
        <% = rsForum("F_DESCRIPTION") %>
        </font></td>
<%					if rsForum("F_TYPE") = 0 then %>
<%						if IsNull(rsForum("F_TOPICS")) then %>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strDefaultFontSize %>">0</font></td>
<%						else %>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strDefaultFontSize %>"><% =rsForum("F_TOPICS") %></font></td>
<%						end if %>
<%						if IsNull(rsForum("F_COUNT")) then %>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strDefaultFontSize %>">0</font></td>
<%						else %>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strDefaultFontSize %>"><% =rsForum("F_COUNT") %></font></td>
<%						end if %>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top nowrap><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strFooterFontSize %>"><b><% =ChkDate(rsForum("F_LAST_POST")) %></b><br>
        <% =ChkTime(rsForum("F_LAST_POST")) %></font></td>
<%					else %>
<%						if rsForum("F_TYPE") = 1 then %>
<%					'## Do Nothing %>
<%						end if %>
<%					end if %>
<%					if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then %>
        <td bgcolor="<% =strForumCellColor %>" align=left valign=top><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strDefaultFontSize %>"><% if (listForumModerators(rsForum("FORUM_ID")) <> "") then Response.Write(listForumModerators(rsForum("FORUM_ID"))) else Response.Write("&nbsp;") end if %></font></td>
<%					end if %>
<%					if (mlev = 4 or mlev = 3) or (lcase(strNoCookies) = "1") then %>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top nowrap>
        <% call ForumAdminOptions %>
        </td>
<%					end if %>
      </tr>
<%				end if %>
<%				rsForum.movenext %>
<%			loop %>
<%		end if %>
<%		rs.MoveNext %>
<%	loop %>
<% end if %>
    </table>           
    </td>
  </tr>
</table>

<!--<table width="95%" align="center">
  <tr>
    <td>
    <font face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>">
    <img alt="New Posts" src="icon_folder_new.gif" width=8 height=9> Contains new posts since last visit.<br>
    <img alt="Old Posts" src="icon_folder.gif" width=8 height=9> No new posts since the last visit.<br>
    </font>
    </td>
  </tr>
</table>-->
<table width="100" height="10" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td></td>
  </tr>
</table>

<% set rs = nothing %>
<% set rsForum = nothing %>
<!--#INCLUDE FILE="inc_footer.asp" --> <% sub PostingOptions() %> 
<%	if (mlev = 4) or (lcase(strNoCookies) = "1") then %> <font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"> 
<a href="post.asp?method=Category"><img border="0" src="icon_folder_new_topic.gif" alt="Create New Category"  border=0></a> 
</font> <%	end if %> <% end sub %> <%
function ChkIsNew(dt)
	if rsForum("F_STATUS") <> 0 then
		if dt > session("last_here_date") then
			ChkIsNew =  "<IMG src='icon_folder_new.gif'  border=0 hspace=0 alt='New Posts'>" 
		Else
			ChkIsNew = "<IMG src='icon_folder.gif'  border=0 hspace=0 alt='Old Posts'>" 
		end if
	else
		ChkIsNew = "<IMG src='icon_folder_locked.gif'  border=0 hspace=0 alt='Forum Locked'>"
	end if
end function
%> <% sub CategoryAdminOptions() %> <%			if (mlev = 4) or (lcase(strNoCookies) = "1") then %> 
<%				if (rs("CAT_STATUS") <> 0) then %> <a href="JavaScript:openWindow('pop_lock.asp?mode=Category&CAT_ID=<% =rs("CAT_ID") %>&Cat_Title=<% =ChkString(rs("CAT_NAME"),"JSurlpath")%>')"><img src="icon_lock.gif" alt="Lock Category" border="0" hspace="0"></a> 
<%				else %> <a href="JavaScript:openWindow('pop_open.asp?mode=Category&CAT_ID=<% =rs("CAT_ID") %>')"><img src="icon_unlock.gif" alt="Un-Lock Category" border="0" hspace="0"></a> 
<%				end if %> <%				if (rs("CAT_STATUS") <> 0) or (mlev = 4) then %> 
<a href="post.asp?method=EditCategory&CAT_ID=<% =rs("CAT_ID") %>&Cat_Title=<% =ChkString(rs("CAT_NAME"),"urlpath") %>"><img src="icon_pencil.gif" alt="Edit Category Name" border="0" hspace="0"></a> 
<%				end if %> <a href="JavaScript:openWindow('pop_delete.asp?mode=Category&CAT_ID=<% =rs("CAT_ID") %>&Cat_Title=<% =ChkString(rs("CAT_NAME"),"JSurlpath") %>')"><img src="icon_trashcan.gif" alt="Delete Category" border="0" hspace="0"></a> 
<%				if (rs("CAT_STATUS") <> 0) or (mlev = 4) then %> <a href="post.asp?method=Forum&CAT_ID=<% =rs("CAT_ID")%>&type=0"><img border="0" src="icon_folder_new_topic.gif" alt="Create New Forum" border=0 hspace="0"></a> 
<%				end if %> <%				if (rs("CAT_STATUS") <> 0) or (mlev = 4) then %> 
<a href="post.asp?method=URL&CAT_ID=<% =rs("CAT_ID")%>&type=1"><img border="0" src="icon_url.gif" alt="Create New Web Link" border=0 hspace="0"></a> 
<%				end if %> <%			else %> &nbsp; <%			end if %> 
<% end sub %> <% sub ForumAdminOptions() %> <%				if rsForum("F_TYPE") = 0 then %> 
<%					if rs("CAT_STATUS") = 0 then %> <%						if (mlev = 4) then %> 
<a href="JavaScript:openWindow('pop_open.asp?mode=Category&CAT_ID=<% =rs("CAT_ID") %>')"><img src="icon_unlock.gif" alt="Un-Lock Category" border="0" hspace="0"></a> 
<%						end if %> <%					else %> <%						if rsForum("F_STATUS") = 1 then %> 
<a href="JavaScript:openWindow('pop_lock.asp?mode=Forum&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"JSurlpath")%>')"><img src="icon_lock.gif" alt="Lock Forum" border="0" hspace="0"></a> 
<%						else %> <a href="JavaScript:openWindow('pop_open.asp?mode=Forum&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"JSurlpath")%>')"><img src="icon_unlock.gif" alt="Un-Lock Forum" border="0" hspace="0"></a> 
<%						end if %> <%					end if %> <%				end if %> 
<%				if rsForum("F_TYPE") = 0 then %> <%					if (rs("CAT_STATUS") <> 0 and rsForum("F_STATUS") <> 0) or (mlev = 4 or mlev = 3) then %> 
<a href="post.asp?method=EditForum&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>&type=0"><img src="icon_pencil.gif" alt="Edit Forum Properties" border="0" hspace="0"></a> 
<%					end if %> <%				else %> <%					if rsForum("F_TYPE") = 1 then %> 
<a href="post.asp?method=EditURL&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>&type=1"><img src="icon_pencil.gif" alt="Edit URL Properties" border="0" hspace="0"></a> 
<%					end if %> <%				end if %> <%				if (mlev = 4) or (lcase(strNoCookies) = "1") then %> 
<a href="JavaScript:openWindow('pop_delete.asp?mode=Forum&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"JSurlpath") %>')"><img src="icon_trashcan.gif" alt="Delete Forum" border="0" hspace="0"></a> 
<%				end if %> <%				if rsForum("F_TYPE") = 0 then %> <%					if (mlev = 4) or (lcase(strNoCookies) = "1") then %> 
<a href="post.asp?method=Topic&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>"><img src="icon_folder_new_topic.gif" alt="New Topic" border=0></a> 
<%					end if %> <%				end if %> <% end sub %>