%
'#################################################################################
'## Copyright (C) 2000-01 Michael Anderson and Pierre Gorissen
'## 
'## 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.
'##
'## All copyright notices regarding Snitz Forums 2000
'## must remain intact in the scripts and in the outputted HTML
'## The "powered by" text/logo with a link back to 
'## http://forum.snitz.com in the footer of the pages MUST
'## remain visible when the pages are viewed on the internet or intranet.
'## 
'## 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.
'## 
'## Support can be obtained from support forums at:
'## http://forum.snitz.com 
'##
'## Correspondence and Marketing Questions can be sent to:
'## reinhold@bigfoot.com
'## 
'## or
'## 
'## Snitz Communications 
'## C/O: Michael Anderson
'## PO Box 200
'## Harpswell, ME 04079
'#################################################################################
if Request.QueryString("TOPIC_ID") = "" and Request.QueryString("mode") <> "getIP" and Request.Form("Method_Type") <> "login" and Request.Form("Method_Type") <> "logout" then
	Response.Redirect "default.asp"
	Response.End
else
	Topic_ID = Request.QueryString("TOPIC_ID")
end if 
 %>
<%
Dim ArchiveView
select case Request.QueryString("mode")
	case "getIP"
%>
<%
		if request("ARCHIVE") = "true" then
			strActivePrefix = strArchiveTablePrefix
			ArchiveView = "true"
			ArchiveLink = "ARCHIVE=true&"
		else
			strActivePrefix = strTablePrefix
			ArchiveView = ""
			ArchiveLink = ""
		end if
		DisplayIP
		IP = ""
		Title = ""
 %>
<%
		Response.End
	case else
		'## Do Nothing - Continue
end select
 %>
<% 
if request("ARCHIVE") = "true" then
	strActivePrefix = strTablePrefix & "A_"
	ArchiveView = "true"
else
	strActivePrefix = strTablePrefix
	ArchiveView = ""
end if
Member_ID = getNewMemberNumber()
if (strAuthType = "nt") then
	call NTauthenticate()
	if (ChkAccountReg() = "1") then
		call NTUser()
	end if
end if
'## Forum_SQL - Get original topic and check if the Category, Forum or Topic Status and existence
strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.M_NAME, " & _
	strMemberTablePrefix & "MEMBERS.M_ICQ, " & _
	strMemberTablePrefix & "MEMBERS.M_YAHOO, " & _
	strMemberTablePrefix & "MEMBERS.M_AIM, " & _
	strMemberTablePrefix & "MEMBERS.M_TITLE, " & _
	strMemberTablePrefix & "MEMBERS.M_HOMEPAGE, " & _
	strMemberTablePrefix & "MEMBERS.MEMBER_ID, " & _
	strMemberTablePrefix & "MEMBERS.M_LEVEL, " & _
	strMemberTablePrefix & "MEMBERS.M_POSTS, " & _
	strMemberTablePrefix & "MEMBERS.M_COUNTRY, " & _
	strActivePrefix & "TOPICS.T_DATE, " & _
	strActivePrefix & "TOPICS.T_SUBJECT, " & _
	strActivePrefix & "TOPICS.T_AUTHOR, " & _
	strActivePrefix & "TOPICS.TOPIC_ID, " & _
	strActivePrefix & "TOPICS.T_STATUS, " & _
	strTablePrefix & "CATEGORY.CAT_STATUS, " & _
	strTablePrefix & "CATEGORY.CAT_ID, " & _
	strTablePrefix & "CATEGORY.CAT_SUBSCRIPTION, " & _ 
	strTablePrefix & "CATEGORY.CAT_MODERATION, " & _
	strTablePrefix & "FORUM.F_STATUS, " & _
	strTablePrefix & "FORUM.FORUM_ID, " & _ 
	strTablePrefix & "FORUM.F_SUBSCRIPTION, " & _
	strTablePrefix & "FORUM.F_SUBJECT, " & _
	strTablePrefix & "FORUM.F_MODERATION, " & _
	strActivePrefix & "TOPICS.T_MESSAGE " & _
	" FROM " & strActivePrefix & "TOPICS, " & _ 
	strTablePrefix & "FORUM, " & _ 
	strTablePrefix & "CATEGORY, " & _
	strMemberTablePrefix & "MEMBERS " & _
	" WHERE " & strActivePrefix & "TOPICS.TOPIC_ID = " & Topic_ID & _
	" AND " & strTablePrefix & "FORUM.FORUM_ID = " & strActivePrefix & "TOPICS.FORUM_ID " & _
	" AND " & strTablePrefix & "CATEGORY.CAT_ID = " & strActivePrefix & "TOPICS.CAT_ID " & _
	" AND " & strMemberTablePrefix & "MEMBERS.MEMBER_ID = " & strActivePrefix & "TOPICS.T_AUTHOR "
set rsTopic = my_Conn.Execute (StrSql)
if rsTopic.EOF then
	rsTopic.close
	set rsTopic = Nothing
	Response.Redirect("link.asp?TOPIC_ID=" & Topic_ID & "")
'	Response.Redirect(strForumURL)
else
	Cat_Status = rsTopic("CAT_STATUS")
	Cat_ID = rsTopic("CAT_ID")
	Cat_Subscription = rsTopic("CAT_SUBSCRIPTION")
	Cat_Moderation = rsTopic("CAT_MODERATION")
	Forum_Status = rsTopic("F_STATUS")
	Forum_ID = rsTopic("FORUM_ID")
	Forum_Subject = rsTopic("F_SUBJECT")
	Forum_Subscription = rsTopic("F_SUBSCRIPTION")
	Forum_Moderation = rsTopic("F_MODERATION")
	Topic_Subject = rsTopic("T_SUBJECT")
	Topic_Status = rsTopic("T_STATUS")
	Topic_Author = rsTopic("T_AUTHOR")
	Topic_Message = rsTopic("T_MESSAGE")
end if
if strPrivateForums = "1" then
	if Request("Method_Type") = "" then
		chkUser4(Forum_ID)
	end if
end if
if (mLev = 4) or (chkForumModerator(Forum_ID, ChkString(STRdbntUserName, "decode"))= "1") or (lcase(strNoCookies) = "1") then
 	AdminAllowed = 1
else   
 	AdminAllowed = 0
end if
if strModeration > 0 and Cat_Moderation > 0 and Forum_Moderation > 0 and AdminAllowed = 0 then
        Moderation = "Y"
else
        Moderation = "N"
end if
if (Moderation = "Y" and Topic_Status > 1 and Topic_Author <> MemberID) then
	Response.write "
Viewing of this Topic is not permitted until it has been moderated.
Please try again later
" &_
					"" &_
					"Go Back
"
	WriteFooter
	Response.end
else
	mypage = request("whichpage")
	if mypage = "" then
	   mypage = 1
	end if
	mySQL = request("strSql")
	if mySQL = "" then
	   mySQL = SQLtemp
	end if
 %>
<%
	'## Forum_SQL
	strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.M_NAME, " & _
		strMemberTablePrefix & "MEMBERS.M_ICQ, " & _
		strMemberTablePrefix & "MEMBERS.M_YAHOO, " & _
		strMemberTablePrefix & "MEMBERS.M_AIM, " & _
		strMemberTablePrefix & "MEMBERS.M_TITLE, " & _
		strMemberTablePrefix & "MEMBERS.MEMBER_ID, " & _
		strMemberTablePrefix & "MEMBERS.M_HOMEPAGE, " & _
		strMemberTablePrefix & "MEMBERS.M_LEVEL, " & _
		strMemberTablePrefix & "MEMBERS.M_POSTS, " & _
		strMemberTablePrefix & "MEMBERS.M_COUNTRY, " & _
		strActivePrefix & "REPLY.REPLY_ID, " & _
		strActivePrefix & "REPLY.FORUM_ID, " & _
		strActivePrefix & "REPLY.R_AUTHOR, " & _
		strActivePrefix & "REPLY.TOPIC_ID, " & _
		strActivePrefix & "REPLY.R_MESSAGE, " & _
		strActivePrefix & "REPLY.R_STATUS, " & _
		strActivePrefix & "REPLY.R_DATE " & _
		" FROM " & strMemberTablePrefix & "MEMBERS, " & strActivePrefix & "REPLY " & _
		" WHERE " & strMemberTablePrefix & "MEMBERS.MEMBER_ID = " & strActivePrefix & "REPLY.R_AUTHOR " & _
		" AND   TOPIC_ID = " & Topic_ID & " "
		' DEM --> if not a Moderator, all unapproved posts should not be viewed.
		if AdminAllowed = 0 then
			strSql = strSql & " AND (" & strActivePrefix & "REPLY.R_STATUS < "
			if Moderation = "Y" then
				' Ignore unapproved/rejected posts
				strSql = strSql & "2"
			else
				' Ignore any previously rejected topic
				strSql = strSql & "3"
			end if
		strSql = strSql & " OR R_AUTHOR = " & MemberID & ")"
	end if
	strSql = strSql & " ORDER BY " & strActivePrefix & "REPLY.R_DATE ASC"
	if strDBType = "mysql" then 'MySql specific code
		if mypage > 1 then
 			intOffset = CInt((mypage-1) * strPageSize)
			strSql = strSql & " LIMIT " & intOffset & ", " & strPageSize & " "
		end if
		'## Forum_SQL - Get the total pagecount 
		strSql2 = "SELECT COUNT(" & strActivePrefix & "REPLY.TOPIC_ID) AS REPLYCOUNT "
		strSql2 = strSql2 & " FROM " & strMemberTablePrefix & "MEMBERS, " & strActivePrefix & "REPLY "
		strSql2 = strSql2 & " WHERE " & strMemberTablePrefix & "MEMBERS.MEMBER_ID = " & strActivePrefix & "REPLY.R_AUTHOR "
		strSql2 = strSql2 & " AND   TOPIC_ID = " & Topic_ID & " "
		
		set rsCount = my_Conn.Execute(strSql2)
		if not rsCount.eof then
			maxpages = (rsCount("REPLYCOUNT")  \ strPageSize )
			if rsCount("REPLYCOUNT") mod strPageSize <> 0 then
				maxpages = maxpages + 1
			end if
		else
			maxpages = 1
		end if 
	
		rsCount.close
		set rsCount = nothing
		set rsReplies = Server.CreateObject("ADODB.Recordset")
		rsReplies.open  strSql,  my_Conn, 3
		if not(rsReplies.EOF) then
			rsReplies.movefirst
		end if
		
	else 'end MySql specific code
	
		set rsReplies = Server.CreateObject("ADODB.Recordset")
		rsReplies.cachesize = strPageSize
		rsReplies.open  strSql,  my_Conn, 3
		If not (rsReplies.EOF or rsReplies.BOF) then  '## No replies found in DB
			rsReplies.movefirst
			rsReplies.pagesize = strPageSize
			rsReplies.absolutepage = mypage '**
			maxpages = cint(rsReplies.pagecount)
		end if
	end if
	i = 0 
 %>
  
	|  All Forums 
  <% If ArchiveView = "true" then %>  <% Else  %>  <% End If %>
	 <% =ChkString(Forum_Subject,"display") %> <% If ArchiveView = "true" then %>
    <% =ChkString(Topic_Subject,"title") %>
<%	elseif Cat_Status <> 0 and Forum_Status <> 0 and Topic_Status <> 0 then %>    <% =ChkString(Topic_Subject,"title") %>
<%	else %>    <% =ChkString(Topic_Subject,"title") %>
<%	end if %> | <% call PostingOptions() %> | 
  
| <% if maxpages > 1 then %> 
      <% else %>
        | Page: | <% Call DropDownPaging() %> |  | <% end if %> | 
  
    | 
      
        <% 
	if mypage = 1 then 
		Call GetFirst() 
	end if
	
	rsTopic.close
	set rsTopic = Nothing
	'## Forum_SQL
	strSql = "UPDATE " & strActivePrefix & "TOPICS "
	strSql = strSql & " SET " & strActivePrefix & "TOPICS.T_VIEW_COUNT = (" & strActivePrefix & "TOPICS.T_VIEW_COUNT + 1) "
	strSql = strSql & " WHERE (" & strActivePrefix & "TOPICS.TOPIC_ID = " & Topic_ID & ");"
	my_conn.Execute (strSql)
 
	if rsReplies.EOF or rsReplies.BOF then  '## No replies found in DB
		Response.Write ""
	else	
		intI = 0 
		howmanyrecs = 0
		rec = 1
	
		do until rsReplies.EOF or (mypage = 1 and rec > CInt(strPageSize)) or (mypage > 1 and rec > CInt(strPageSize)) '**
			Reply_Content = rsReplies("R_MESSAGE")		
			if intI = 0 then 
				CColor = strAltForumCellColor
			else
				CColor = strForumCellColor
			end if
 %>| >Author | ><% if strShowTopicNav = "1" then Call Topic_nav()  else Response.Write("Topic") end if%><%	if (AdminAllowed = 1) then %> | <% call AdminOptions() %><%	else %> | <%	end if %> |  
        <%			
		    rsReplies.MoveNext
		    intI  = intI + 1
		    if intI = 2 then 
			intI = 0
		    end if
		    rec = rec + 1
		loop
	end if
 %>| <%			if strUseExtendedProfile then %>
		">
<%			else %>
		')">
<%			end if %>	
		<% =ChkString(rsReplies("M_NAME"),"display") %>
        
<%			if strShowRank = 1 or strShowRank = 3 then %> <% = ChkString(getMember_Level(rsReplies("M_TITLE"), rsReplies("M_LEVEL"), rsReplies("M_POSTS")),"display") %>
<%			end if %>
<%			if strShowRank = 2 or strShowRank = 3 then %>
 <% = getStar_Level(rsReplies("M_LEVEL"), rsReplies("M_POSTS")) %>
<%			end if %>
 
 <% =rsReplies("M_COUNTRY") %>
 <% =rsReplies("M_POSTS") %> Posts
 | colspan="3"<% else %>colspan="2"<% end if %> valign="top">
		">
		<%	' DEM --> Start of Code altered for moderation
			if rsReplies("R_STATUS") < 2 then
				Response.Write " ![]() Posted - " & ChkDate(rsReplies("R_DATE")) & " : " & ChkTime(rsReplies("R_DATE")) & "" & vbNewline
			elseif rsReplies("R_STATUS") = 2 then
				Response.Write "NOT MODERATED!!!" & vbNewline
			elseif rsReplies("R_STATUS") = 3 then
				Response.Write " ![]() ON HOLD" & vbNewline
			end if
			' DEM --> End of Code added for moderation.
		if strUseExtendedProfile then %>
		 ">  <% else %>
		 ')">  <% end if %>	
   
<%		if (lcase(strEmail) = "1") then 
			if (mlev <> 0) or (mlev = 0 and  strLogonForMail <> "1") then 
%>
				 ')">  <%			end if
		else
%>
			 ')">  <%		end if %>  
<%			if strHomepage = "1" then %>
<%				if rsReplies("M_Homepage") <> " " then %>
         " target="_blank">  's Homepage" border="0" align="absmiddle" hspace="6">
<%				end if %>
<%			end if %>
<%			if (AdminAllowed = 1 or rsReplies("MEMBER_ID") = Member_ID) or (strNoCookies = "1") then %>
<%				if (Cat_Status <> 0 and Forum_Status <> 0 and Topic_Status <> 0) or (AdminAllowed = 1) then %>
         &TOPIC_ID=<% =Topic_ID %>&FORUM_ID=<% =Forum_ID %>&CAT_ID=<% =Cat_ID %>&Author=<% =ChkString(rsReplies("R_AUTHOR"),"urlpath") %>&Forum_Title=<% =ChkString(Forum_Subject,"urlpath") %>&Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>">  <%				end if %>
<%			end if %>
<%			if strICQ = "1" then %>
<%			  if Trim(rsReplies("M_ICQ")) <> "" then %>
         &M_NAME=<% =ChkString(rsReplies("M_NAME"),"JSurlpath") %>')">  &img=5" height=15 width=15 alt="Send <% = ChkString(rsReplies("M_NAME"),"display")  %> an ICQ Message" border="0" align="absmiddle" hspace="6">
<%			  end if %>
<%			end if %>
<%			if strYAHOO = "1" then %>
<%			  if Trim(rsReplies("M_YAHOO")) <> "" then %>
         &.src=pg')">  a Yahoo! Message" border="0" align="absmiddle" hspace="6">
<%			  end if %>
<%			end if %>
<%			if (strAIM = "1") then %>
<%				if Trim(rsReplies("M_AIM")) <> "" then %>
         &M_NAME=<% =ChkString(rsReplies("M_NAME"),"urlpath") %>')">  an instant message" border="0" align="absmiddle" hspace="6">
<%				end if %>
<%			end if %>
<%			if ((Cat_Status <> 0 and Forum_Status <> 0 and Topic_Status = 1) or (AdminAllowed = 1 and Topic_Status <= 1)) and ArchiveView = "" then %>
         &TOPIC_ID=<% =Topic_ID %>&FORUM_ID=<% =Forum_ID %>&CAT_ID=<% =Cat_ID %>&Forum_Title=<% =ChkString(Forum_Subject,"urlpath") %>&Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>&M=<% =Request.QueryString("M") %>">  <%			end if %>
<%			if (strIPLogging = "1") then %>
<%				if (AdminAllowed = 1) or (strNoCookies = "1") then %>
         &FORUM_ID=<% =Forum_ID %>')">  <%				end if %>
<%			end if %>
<%			if (AdminAllowed = 1 or rsReplies("MEMBER_ID") = Member_ID) or (strNoCookies = "1") then %>
<%				if (Cat_Status <> 0 and Forum_Status <> 0 and Topic_Status <> 0) or (AdminAllowed = 1) then %>
         &TOPIC_ID=<% =Topic_ID %>&FORUM_ID=<% =Forum_ID %>')">  <%              		end if
                ' DEM --> Start of Code added for Full Moderation
				if (AdminAllowed = 1 and rsReplies("R_STATUS") > 1) then
					ReplyString = "Reply_ID=" & rsReplies("REPLY_ID") & "&CAT_ID=" & Cat_ID & "&FORUM_ID=" & Forum_ID & "&TOPIC_ID=" & Topic_ID
					Response.Write " ![]() " & vbNewline
				End if
				' DEM --> End of Code added for Full Moderation
			end if %> <% =formatStr(Reply_Content) %>
  |  | 
  
    | 
      
        | <% if maxpages > 1 then %> 
          <% else %>
            | Topic is <% =maxpages %> Pages Long: | <% Call Paging() %> |  | <% end if %> | <% if (AdminAllowed = 1) then %>
<%	call AdminOptions() %>
<% else %>
         
<% end if %> |  | 
  
    | <%	 Call PostingOptions() %> |  | 
<%
WriteFooter
end if
sub GetFirst()
%>
      
        | <% if strUseExtendedProfile then %>
		">
        <% else %>
		')">
		<% end if %>	
		<% =ChkString(rsTopic("M_NAME"),"display") %>
        
<%		if strShowRank = 1 or strShowRank = 3 then %> <% = ChkString(getMember_Level(rsTopic("M_TITLE"), rsTopic("M_LEVEL"), rsTopic("M_POSTS")),"display") %>
<%		end if %>
<%		if strShowRank = 2 or strShowRank = 3 then %>
 <% = getStar_Level(rsTopic("M_LEVEL"), rsTopic("M_POSTS")) %>
<%		end if %>
 
 <% =rsTopic("M_COUNTRY") %>
 <% =rsTopic("M_POSTS") %> Posts
 | colspan="3"<% else %>colspan="2"<% end if %> valign="top">
		<%
		if Topic_Status < 2 then
			Response.Write " ![]() Posted - " & ChkDate(rsTopic("T_DATE")) & " : " & ChkTime(rsTopic("T_DATE")) & "" & vbNewline
		elseif Topic_Status = 2 then
			Response.Write "NOT MODERATED!!!" & vbNewline
		elseif Topic_Status = 3 then
			Response.Write " ![]() ON HOLD" & vbNewline
		end if
	        if strUseExtendedProfile then %>
		 ">  <% 		else %>
		 ')">  <% 		end if
		if (lcase(strEmail) = "1") then 
			if (mlev <> 0) or (mlev = 0 and  strLogonForMail <> "1") then 
%>
				 ')">  <%			end if
		else
%>
			 ')">  <%		end if %>        
<%		if (strHomepage = "1") then %>
<%				if rsTopic("M_Homepage") <> " " then %>
         " target="_blank">  's Homepage" border="0" align="absmiddle" hspace="6">
<%			end if %>
<%		end if %>
<%		if (AdminAllowed = 1 or rsTopic("MEMBER_ID") = Member_ID) or (strNoCookies = "1") then %>
<%			if ((Cat_Status <> 0) and (Forum_Status <> 0) and (Topic_Status <> 0)) or (AdminAllowed = 1) then %>
         &Forum_Title=<% =ChkString(Forum_Subject,"urlpath") %>&Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>">  <%			end if %>
<%		end if %>
<%		if (strICQ = "1") then %>
<%			if Trim(rsTopic("M_ICQ")) <> "" then %>
         &M_NAME=<% =ChkString(rsTopic("M_NAME"), "JSurlpath") %>')">  &img=5" height=15 width=15 alt="Send <% =ChkString(rsTopic("M_NAME"),"display")  %> an ICQ Message" border="0" align="absmiddle" hspace="6">
<%			end if %>
<%		end if %>
<%		if (strYAHOO = "1") then %>
<%		  if Trim(rsTopic("M_YAHOO")) <> "" then %>
         &.src=pg')">  a Yahoo! Message" border="0" align="absmiddle" hspace="6">
<%		  end if %>
<%		end if %>
<%		if (strAIM = "1") then %>
<%			if Trim(rsTopic("M_AIM")) <> "" then %>
         &M_NAME=<% =ChkString(rsTopic("M_NAME"), "JSurlpath") %>')">  an instant message" border="0" align="absmiddle" hspace="6">
<%			end if %>
<%		end if %>
<%			if ((Cat_Status <> 0 and Forum_Status <> 0 and Topic_Status = 1) or (AdminAllowed = 1 and Topic_Status <= 1) and ArchiveView = "" ) then %>
         &Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>">  <%			end if %>
<%		if (strIPLogging = "1") then %>
<%			if (AdminAllowed = 1) or (strNoCookies = "1") then %>
         &FORUM_ID=<% =Forum_ID %>')">  <%			end if
		end if
		' DEM --> Start of Code added for Full Moderation
		if (AdminAllowed = 1 and Topic_Status > 1) then
			TopicString = "TOPIC_ID=" & Topic_ID & "&FORUM_ID=" & Forum_ID & "&CAT_ID=" & Cat_ID
			Response.Write " ![]() " & vbNewline
		End if
		' End of Code added for Full Moderation
		if (AdminAllowed = 1) or (lcase(strNoCookies) = "1") then %>
         ')">  <%		end if %> <% =formatStr(Topic_Message) %>
 | 
<%
End Sub
sub DisplayIP()
	usr = (chkForumModerator(Request.QueryString("Forum_ID") , STRdbntUserName))
	if (chkUser((STRdbntUserName), (Request.Cookies(strUniqueID & "User")("Pword"))) = 4) then 
		usr = 1
	end if
	if usr then
		if Topic_ID <> "" then
			'## Forum_SQL
			strSql = "SELECT " & strActivePrefix & "TOPICS.T_IP, " & strActivePrefix & "TOPICS.T_SUBJECT "
			strSql = strSql & " FROM " & strActivePrefix & "TOPICS "
			strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID
			set rsIP = my_Conn.Execute(strSql)
			IP = rsIP("T_IP")
			Title = rsIP("T_Subject")
		else
			if Request.QueryString("REPLY_ID") <> "" then
				'## Forum_SQL
				strSql = "SELECT " & strActivePrefix & "REPLY.R_IP "
				strSql = strSql & " FROM " & strActivePrefix & "REPLY "
				strSql = strSql & " WHERE REPLY_ID = " & Request.QueryString("REPLY_ID")
				set rsIP = my_Conn.Execute(strSql)
				IP = rsIP("R_IP")
			end if
		end if
		set rsIP = nothing
 %>
User's IP address:
<% =ip %>
<%	else %>
Only moderators and administrators can perform this action.
<%
	end If
end sub
sub PostingOptions() 
 %>
    
<%
	if (mlev = 4 or mlev = 3 or mlev = 2 or mlev = 1) or (lcase(strNoCookies) = "1") or (STRdbntUserName = "") then
		if ((Cat_Status = 1) and (Forum_Status = 1)) then %>
    "> ">New Topic
<%		else
			if (AdminAllowed = 1) then %>
    ">
 ">New Topic
<%		else
			if (AdminAllowed = 1) then %>
    "> ">New Topic
<%			else %>
 ">New Topic
<%			else %>
     Forum Locked
<%			end if 
		end if 
		if ((Cat_Status = 1) and (Forum_Status = 1) and (Topic_Status = 1)) and ArchiveView = "" then %>
    &Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>">
 Forum Locked
<%			end if 
		end if 
		if ((Cat_Status = 1) and (Forum_Status = 1) and (Topic_Status = 1)) and ArchiveView = "" then %>
    &Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>"> &Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>">Reply to Topic
<%		else 
			if ((AdminAllowed = 1 and Topic_Status <= 1) and ArchiveView = "")  then %>
    &Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>">
<%				' DEM --> Added if statement to show normal icon for unmoderated posts.
				if Topic_Status = 1 and Cat_Status <> 0 and Forum_Status <> 0 then
					Response.Write "
 &Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>">Reply to Topic
<%		else 
			if ((AdminAllowed = 1 and Topic_Status <= 1) and ArchiveView = "")  then %>
    &Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>">
<%				' DEM --> Added if statement to show normal icon for unmoderated posts.
				if Topic_Status = 1 and Cat_Status <> 0 and Forum_Status <> 0 then
					Response.Write "         "
				else
					Response.Write "
 "
				else
					Response.Write "         "
				end if 
				Response.Write "Reply to Topic"
			else 
				if Topic_Status = 0 then
					Response.Write "
 "
				end if 
				Response.Write "Reply to Topic"
			else 
				if Topic_Status = 0 then
					Response.Write "    ![]() Topic Locked" & vbNewline
'				elseif Topic_Status = 2 then
'					Response.Write "
 Topic Locked" & vbNewline
'				elseif Topic_Status = 2 then
'					Response.Write "   ![]() Topic Not Yet Moderated" & vbNewline
'				elseif Topic_Status = 3 then
'					Response.Write "
 Topic Not Yet Moderated" & vbNewline
'				elseif Topic_Status = 3 then
'					Response.Write "   ![]() Topic is on Hold" & vbNewline
				end if
			end if
		end if 
		if (lcase(strEmail) = "1" and Topic_Status < 2) then 
			if (mlev <> 0) or (mlev = 0 and  strLogonForMail <> "1") then %>
 Topic is on Hold" & vbNewline
				end if
			end if
		end if 
		if (lcase(strEmail) = "1" and Topic_Status < 2) then 
			if (mlev <> 0) or (mlev = 0 and  strLogonForMail <> "1") then %>
    
	
    ')"> ')">Send Topic to a Friend
<%			end if 
	if strSubscription > 0 and Cat_Subscription > 0 and Forum_Subscription > 0 then
		CheckSubscription "TOPIC", MEMBER_ID, Cat_ID, Forum_ID, Topic_ID, "
 ')">Send Topic to a Friend
<%			end if 
	if strSubscription > 0 and Cat_Subscription > 0 and Forum_Subscription > 0 then
		CheckSubscription "TOPIC", MEMBER_ID, Cat_ID, Forum_ID, Topic_ID, "
", " "
	end if
%>
    
 Printer Friendly
<%		end if 
	end if 
%>
    
<% 
end sub 
sub AdminOptions() 
 %>
    
<%	if (AdminAllowed = 1) or (lcase(strNoCookies) = "1") then
		if (Cat_Status = 0) then 
			if (mlev = 4) then %>
 Printer Friendly
<%		end if 
	end if 
%>
    
<% 
end sub 
sub AdminOptions() 
 %>
    
<%	if (AdminAllowed = 1) or (lcase(strNoCookies) = "1") then
		if (Cat_Status = 0) then 
			if (mlev = 4) then %>
     <%			else %>
<%			else %>
     <%			end if
		else 
			if (Forum_Status = 0) then %>
    ')">
<%			end if
		else 
			if (Forum_Status = 0) then %>
    ')"> <%			else
				if (Topic_Status <> 0) then %>
    ')">
<%			else
				if (Topic_Status <> 0) then %>
    ')"> <%				else %>
    ')">
<%				else %>
    ')"> <%				end if
			end if
		end if %>
<%		if ((Cat_Status <> 0) and (Forum_Status <> 0) and (Topic_Status <> 0)) or (AdminAllowed = 1) then %>
    &Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>">
<%				end if
			end if
		end if %>
<%		if ((Cat_Status <> 0) and (Forum_Status <> 0) and (Topic_Status <> 0)) or (AdminAllowed = 1) then %>
    &Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>"> <%		end if %>
    ')">
<%		end if %>
    ')"> ">
    "> <%  if Topic_Status <= 1 and ArchiveView = "" then %>
    &Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>">
<%  if Topic_Status <= 1 and ArchiveView = "" then %>
    &Topic_Title=<% =ChkString(Topic_Subject,"urlpath") %>"> <%  end if
	end if 
    ' DEM --> Start of Code added for Full Moderation
    if (AdminAllowed = 1 and CheckForUnModeratedPosts("TOPIC", Cat_ID, Forum_ID, Topic_ID) > 0) then
		TopicString = "TOPIC_ID=" & Topic_ID & "&FORUM_ID=" & Forum_ID & "&CAT_ID=" & Cat_ID & "&REPLY_ID=X"
		Response.Write "
<%  end if
	end if 
    ' DEM --> Start of Code added for Full Moderation
    if (AdminAllowed = 1 and CheckForUnModeratedPosts("TOPIC", Cat_ID, Forum_ID, Topic_ID) > 0) then
		TopicString = "TOPIC_ID=" & Topic_ID & "&FORUM_ID=" & Forum_ID & "&CAT_ID=" & Cat_ID & "&REPLY_ID=X"
		Response.Write " ![]() " & vbNewline
	End if
	' DEM --> End of Code added for Full Moderation
	Response.Write "    " & vbNewline
end sub 
sub Paging()
	if maxpages > 1 then
		if Request.QueryString("whichpage") = "" then
			pge = 1
		else
			pge = Request.QueryString("whichpage")
		end if
		scriptname = request.servervariables("script_name")
		Response.Write("
" & vbNewline
	End if
	' DEM --> End of Code added for Full Moderation
	Response.Write "    " & vbNewline
end sub 
sub Paging()
	if maxpages > 1 then
		if Request.QueryString("whichpage") = "" then
			pge = 1
		else
			pge = Request.QueryString("whichpage")
		end if
		scriptname = request.servervariables("script_name")
		Response.Write("")
		for counter = 1 to maxpages
			if counter <> cint(pge) then   
				ref = "| " & " " & widenum(counter) & ""
					ref = ref & "" & counter & ""
					Response.Write ref
				else
					ref = ref & "'>" & counter & ""
					Response.Write ref
				end if
			else
				Response.Write(" | " & " " & widenum(counter) & "" & counter & "")
			end if
			if counter mod strPageNumberSize = 0 then
				Response.Write(" | 
")
			end if
		next
		Response.Write("
")
	end if
	top = "0"
end sub 
sub DropDownPaging()
	if maxpages > 1 then
		if Request("whichpage") = "" then
			pge = 1
		else
			pge = Request("whichpage")
		end if
		scriptname = request.servervariables("script_name")
		Response.write "")
	end if
	top = "0"
end sub 
Sub Topic_nav()    
    set rsLastPost = Server.CreateObject("ADODB.Recordset")
    
    strSql = "SELECT T_LAST_POST FROM " & strActivePrefix & "TOPICS " 
    strSql = strSql & "WHERE TOPIC_ID = " & Topic_ID
                
    set rsLastPost = my_Conn.Execute (StrSql)
    
    T_LAST_POST = rsLastPost("T_LAST_POST")
    
    strSQL = "SELECT T_SUBJECT, TOPIC_ID "
    strSql = strSql & "FROM " & strActivePrefix & "TOPICS "
    strSql = strSql & "WHERE T_LAST_POST > '" & T_LAST_POST
    strSql = strSql & "' AND FORUM_ID=" & Forum_ID
    strSql = strSql & " ORDER BY T_LAST_POST;"
                
    set rsPrevTopic = my_conn.Execute (strSQL)
    
    strSQL = "SELECT T_SUBJECT, TOPIC_ID "
    strSql = strSql & "FROM " & strActivePrefix & "TOPICS "
    strSql = strSql & "WHERE T_LAST_POST < '" & T_LAST_POST
    strSql = strSql & "' AND FORUM_ID=" & Forum_ID
    strSql = strSql & " ORDER BY T_LAST_POST DESC;"
                
    set rsNextTopic = my_conn.Execute (strSQL)
    
    if rsPrevTopic.EOF then
        prevTopic = "![]() "
    else
        prevTopic = "
"
    else
        prevTopic = "![]() "
    end if                    
                    
    if rsNextTopic.EOF then
        NextTopic = "
"
    end if                    
                    
    if rsNextTopic.EOF then
        NextTopic = "![]() "
    else
        NextTopic = "
"
    else
        NextTopic = "![]() "
    end if                    
    
    Response.Write (prevTopic & " Topic " & nextTopic)
    
    rsLastPost.close
    rsPrevTopic.close
    rsNextTopic.close
    set rsLastPost = nothing
    set rsPrevTopic = nothing
    set rsNextTopic = nothing
    
end sub
 %>
"
    end if                    
    
    Response.Write (prevTopic & " Topic " & nextTopic)
    
    rsLastPost.close
    rsPrevTopic.close
    rsNextTopic.close
    set rsLastPost = nothing
    set rsPrevTopic = nothing
    set rsNextTopic = nothing
    
end sub
 %>