<%
'***********************************************************************
'** Copyright (C) 2001 - 2002 Max Yuan All Rights Reserved
'**
'** By using this program, you are agreeing to the terms of the
'** GNU General Public License.
'**
'** 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 MaxWebPortal must remain intact
'** in the scripts and in the outputted HTML.
'** The "powered by" text/logo with a link back to 
'** http://www.maxwebportal.com in the footer of the pages MUST
'** remain visible when the pages are viewed on the internet or intranet.
'**
'** Support can be obtained from support forums at:
'** http://www.maxwebportal.com
'**
'** Email: maxwebportal@hotmail.com
'** ICQ: 148111300
'***********************************************************************
%><%
CurPageType = "features"
CurPageInfoChk = "1"
function CurPageInfo ()
	strOnlineQueryString = Request.QueryString
	PageName = "News Archive"
	PageAction = "Viewing<br>" 
	PageLocation = "news.asp?" & strOnlineQueryString & ""
	CurPageInfo = PageAction & " " & "<a href=" & PageLocation & ">" & PageName & "</a>"

end function
%>
<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="inc_functions.asp" -->
<!--#INCLUDE FILE="inc_top.asp" -->
<!-- #INCLUDE FILE="inc_ADOVBS.asp" -->
<table border="0" width="95%">
<tr>
    <td>
    <font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><img src="<%=strImageURL %>icon_folder_open.gif" border="0">&nbsp;<a href="default.asp">Home</a><br>
    <img src="<%=strImageURL %>icon_bar.gif" border="0"><img src="<%=strImageURL %>icon_folder_open_topic.gif" border="0">&nbsp;News Archive</font>
    </td>
</tr>
</table>
<%
Set NobjDict =   CreateObject("Scripting.Dictionary")
iPageSize = 15
If Request.QueryString("page") = "" Then
	iPageCurrent = 1
Else
	iPageCurrent = CInt(Request.QueryString("page"))
End If

    strSQL      =   "SELECT m_code, m_value FROM " & strTablePrefix & "mods WHERE m_name = 'news';"
    set NobjRec  =   my_conn.Execute(strSQL)

    while not NobjRec.EOF    
        NobjDict.Add NobjRec.Fields.Item("m_code").Value, NobjRec.Fields.Item("m_value").Value
        NobjRec.moveNext
    wend     
    
	NslLength    	=   cint(NobjDict.Item("slLength"))
	NslSort      	=   cint(NobjDict.Item("slSort"))
	NslEncode		=	cint(NobjDict.Item("slEncode"))
	NstrIMGInPosts	=	cint(NobjDict.Item("slImages"))
	NstrIcons		=	0

    set NobjDict 	=   nothing

    strSQL      	=  "SELECT " & strTablePrefix & "TOPICS.TOPIC_ID, " & _
	strTablePrefix & "TOPICS.T_SUBJECT, " & _
	strTablePrefix & "TOPICS.T_AUTHOR, " & _
	strTablePrefix & "MEMBERS.M_NAME, " & _
	strTablePrefix & "TOPICS.T_REPLIES, " & _
	strTablePrefix & "TOPICS.T_DATE, " & _
	strTablePrefix & "TOPICS.T_MESSAGE " & _
	"FROM " & strTablePrefix & "TOPICS, " & _
	strTablePrefix & "FORUM, " & _
	strMemberTablePrefix & "MEMBERS " & _
	"WHERE " & strTablePrefix & "FORUM.F_PRIVATEFORUMS = 0 AND " & _
	strTablePrefix & "TOPICS.FORUM_ID = " & strTablePrefix & "FORUM.FORUM_ID AND " & _
	strTablePrefix & "TOPICS.T_NEWS = 1 AND " & _	    				
	strTablePrefix & "TOPICS.T_AUTHOR = " & strMemberTablePrefix & "MEMBERS.MEMBER_ID "
    Select Case NslSort
    Case "2"    '   last post
	    strSQL = strSQL & "ORDER BY " & strTablePrefix & "TOPICS.T_LAST_POST DESC;"
	Case "3"    '   hot topics
		strSQL = strSQL & "ORDER BY " & strTablePrefix & "TOPICS.T_REPLIES DESC;"
	Case Else   '   last created
		strSQL = strSQL & "ORDER BY " & strTablePrefix & "TOPICS.TOPIC_ID DESC;"
	End Select
	
Set NobjRec = Server.CreateObject("ADODB.Recordset")
NobjRec.PageSize = iPageSize
NobjRec.CacheSize = iPageSize
NobjRec.Open strSQL, my_Conn, adOpenStatic, adLockReadOnly, adCmdText

reccount = NobjRec.recordcount
iPageCount = NobjRec.PageCount

If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1

If iPageCount = 0 Then

%>
<table border="0" width="95%" cellspacing="0" cellpadding="0" bgcolor="<%= strTableBorderColor %>" align="center">
  <tr>
    <td bgcolor="<%= strForumCellColor %>" width="100%">
      <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td align="left" colspan="2" bgcolor="<% =strHeadCellColor %>">
          <b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>">News</font></b>
          </td>
        </tr>
	  </table>
	</td>
  </tr>
</table>
<br>
<%
	Response.Write "<center><font color=red size=3>No news topic found!</font></center>"
Else
	NobjRec.AbsolutePage = iPageCurrent
%>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" align="center" width="95%">
<tr>
<td colspan="2" bgcolor="<% =strHeadCellColor %>" width="100%"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>"><b>News</b></font></td>
<td bgcolor="<% =strHeadCellColor %>" width="100%" align="right"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><a href="search.asp?mode=news">Search News</a></font></td>
</tr>
      
<%
 iRecordsShown = 0
    Do While iRecordsShown < iPageSize And Not NobjRec.EOF And NOT NobjRec.EOF
      NT_Subject     =   NobjRec("T_SUBJECT")
      NT_Author      =   NobjRec("T_AUTHOR")
      NM_NAME        =   NobjRec("M_NAME")
      NT_Message     =   NobjRec("T_MESSAGE")
      NT_REPLIES     =   NobjRec("T_REPLIES")
      NT_DATE        =   NobjRec("T_DATE")
      NTOPIC_ID      =   NobjRec("TOPIC_ID")
      

      If Len(NT_Message) > CInt(NslLength) Then  
      	NT_Message = Left(NT_Message, NslLength) & "..."
      Else
      	NT_Message = NT_Message
      End If

	  if NslEncode = 1 then
	    NT_Message = formatStr(NT_MESSAGE)
	  else
	  	NT_Message = HTMLencode(NT_MESSAGE)
	  end if
%> 
<tr>
<td width="65%" bgColor="<% =strPopUpTableColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strDefaultFontColor %>"><b><%= NT_SUBJECT%></b></font></td>
<td width="15%" bgColor="<% =strPopUpTableColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>" color="<% =strDefaultFontColor %>">Posted by <b><%= NM_NAME %></b></font></td>
<td width="20%" bgcolor="<% =strPopUpTableColor %>" align="right"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize-1 %>" color="<% =strDefaultFontColor %>"><b><%= ChkDate(NT_DATE) %></b><br><%= ChkTime(NT_DATE) %></font></td>
</tr>
<tr>
<td width="100%" colspan="3" bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><%= NT_MESSAGE %><br><br></font></td>
</tr>

<tr>
<td width="100%" colspan="3"  bgcolor="<% =strAltHeadCellColor %>">
<table border="0" width="275" align="left">
<tr>
<td><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize-1 %>" color="<% =strDefaultFontColor %>"><a href="link.asp?TOPIC_ID=<%= NTOPIC_ID %>">Read entire message</a></font></td>
<td><a href="JavaScript:openWindow5('pop_printer_friendly.asp?TOPIC_ID=<%= NTOPIC_ID %>')"><img border="0" src="print.gif" width="16" height="17"></a></td>
<%if (lcase(strEmail) = "1") then %><td><a href="JavaScript:openWindow('pop_send_to_friend.asp?url=<% =strForumURL %>link.asp?TOPIC_ID=<% =NTOPIC_ID %>')"><img border="0" src="icon_email.gif" height=15 width=15 border=0></a></td><%end if%>
<td><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize-1 %>" color="<% =strDefaultFontColor %>"><a href="link.asp?TOPIC_ID=<%= NTOPIC_ID %>">Comments (<%= NT_REPLIES %>)</a></font></td>
</tr>
</table>

</td>
</tr>
<%
 iRecordsShown = iRecordsShown + 1
 NobjRec.MoveNext
 Loop
%> 
</table>
<%
	NobjRec.close
	Set NobjRec  =  nothing
	iRecordsShown = 0
End If%>
<table border="0" width="95%" cellspacing="0" cellpadding="0" bgcolor="<%= strTableBorderColor %>" align="center">
<tr>
<td bgcolor="<% =strForumCellColor%>" width="100%"  align="center"><font face="<%= strDefaultFontFace %>" size="<%= strDefaultFontSize %>">
 Page <b><%= iPageCurrent %></b> of <b><%= iPageCount %></b>
<%if iPageCurrent <> 1 Then%>
	<a HREF="news.asp?page=<%= iPageCurrent - 1 %>">Previous</a> <% =iPageSize%> Topics
<%End If%>|
<%If iPageCurrent < iPageCount Then%>
	<a HREF="news.asp?page=<%= iPageCurrent + 1 %>">Next</a> <% =iPageSize%> Topics
<%End If%>
</font>
</td>
</tr>
</table>
<%if iPagecount = 0 then iPageCount = 1%>
<!--#INCLUDE FILE="inc_footer.asp" -->