<!-- #include virtual="/inc/db.asp" -->
<%

	dim strText, Externals, exclude, m_Count
	
	m_Count = 50
	if request("count") <> "" then m_Count = cint(request("count"))
	
	Externals=true
	if request("all")="no" then Externals=False
		
	
	openDB True
	'**************************************************
	'Execute Stored Procedure
	'**************************************************
	dim m_BaseNewsPage
	dim m_SiteID
	dim m_SiteName
	
	With objCmd
	    .Commandtype = adCmdStoredProc
	    .CommandText = "rss_GetBaseNews"
	    .Parameters.refresh
	    .Parameters("@DomainName") = request("DomainName")

	    .execute()
	
	    m_BaseNewsPage = .Parameters("@BaseNewsPage")
	    m_SiteID = .Parameters("@SiteID")
	    m_SiteName = .Parameters("@SiteName")
	
	    ' Clean Up the Parameters
	    Do Until .Parameters.Count = 0
	    .Parameters.Delete(0)
	    Loop
	end with

	Init_SystemVariables

	response.expires = 0
	response.ContentType = "application/rss+xml"
	Response.AddHeader "Content-Type", "application/rss+xml;charset=UTF-8"
	Response.CodePage = 65001
	Response.CharSet = "UTF-8"


%><?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title><%=server.htmlencode(m_SiteName)%></title>
    <%if request("burl")="" then%>
	<atom:link href="http://www.prospecttrax.com/rss.asp?domainname=<%=request("DomainName")%>" rel="self" type="application/rss+xml" />
		<%if SiteVariables("RSS_Base") <> "" then%>
    <link><%=SiteVariables("RSS_Base")%>/</link>
   	<%else%>
    <link>http://www.<%=request("DomainName")%>/</link>
   	<%end if%>
   	<%else%>
	<atom:link href="<%=request("burl")%>" rel="self" type="application/rss+xml" />
	<link><%=request("burl")%></link>   	
   	<%end if%>
		<description><%=server.htmlencode(m_SiteName)%> Articles</description>
    <language>en-us</language>
	<pubDate><%=getrfcdate(Now())%></pubDate>
    <managingEditor>support@<%=request("DomainName")%> (Support)</managingEditor>
    <ttl>15</ttl>
<%	
		
		With objCmd

			.Commandtype = adCmdStoredProc
			.CommandText = "proc_GetCurrentRSSNews"
			.Parameters.refresh
			.Parameters("@Articles") = m_Count
			.Parameters("@SiteID") = m_SiteID 
			.Parameters("@IncludeExternal") = Externals
			if SiteVariables("RSS_Exclude_CatIDs") <> "" then .Parameters("@CatExclude") = SiteVariables("RSS_Exclude_CatIDs")
			if request("cat") <> "" then .Parameters("@Cat") = request("Cat")
			

			set objRS = .Execute

			Do Until .Parameters.Count = 0
				.Parameters.Delete 0
			Loop
		End With
		

		if objRS.eof then response.write "No Articles to Display"

	
		do until objRS.eof
		
			response.write "  <item>" & vbCrLf
		
			response.write "    <title><![CDATA["
			response.write filterText(objRS("ArticleTitle"))
			response.write ".]]></title>" & vbcrlf
			if len(objRS("external"))>0 then
				if SiteVariables("EXTERNAL_REDIRECT") = "" then
					response.write "    <link>" & server.htmlencode(objRS("external"))  & "</link>" & vbcrlf
				Else
					response.write "    <link>" & server.htmlencode(SiteVariables("EXTERNAL_REDIRECT") & "?sid=" & m_SiteID & "&aid=" & objRS("ArticleID") & "&l=" & server.urlencode(objRS("external")) & "&t=2")  & "</link>" & vbcrlf
				End If
			else
				response.write "    <link>" & server.htmlencode(m_BaseNewsPage & "?id=" & objRS("ArticleID"))  & "</link>" & vbcrlf
			end if				
			response.write "    <pubDate>" & getrfcdate(objRS("ArticleEventDate")) & "</pubDate>" & vbcrlf
			
			'response.write "    <description><![CDATA["
			response.write "    <description>"
			
			if request("full") = "" then 
				if isnull(objRS("ArticleSummary")) then
					strText = GetShortSummary(objRS("ArticleContent"), 300)
				else
					if objRS("ArticleSummary")="" then
						strText = GetShortSummary(objRS("ArticleContent"), 300)
					else
						strText = GetShortSummary(filterText(objRS("ArticleSummary")),300)
					end if
				end if
			else
				strText = objRS("ArticleContent")
			end if
			
			response.write server.htmlencode(replace(strText, "src=""../files", "src=""http://www.prospecttrax.com/files"))
			
			
			
			'response.write "]]></description>" & vbcrlf
			response.write "</description>" & vbcrlf
			
			if len(objRS("external"))>0 then
				if SiteVariables("EXTERNAL_REDIRECT") = "" then
					response.write "    <guid>" & server.htmlencode(objRS("external"))  & "</guid>" & vbcrlf
				Else
					response.write "    <guid>" & server.htmlencode(SiteVariables("EXTERNAL_REDIRECT") & "?sid=" & m_SiteID & "&aid=" & objRS("ArticleID") & "&l=" & server.urlencode(objRS("external")) & "&t=2")  & "</guid>" & vbcrlf
				End If
			else
				response.write "    <guid>" & server.htmlencode(m_BaseNewsPage & "?id=" & objRS("ArticleID"))  & "</guid>" & vbcrlf
			end if				
						
			response.write "  </item>" & vbCrLf
			
			objRS.movenext
		Loop
		
		closedb
	%>  </channel>
</rss>
<%


	function cleanHTML(dirtydata)
		dirtydata = replace(dirtydata, "&apos;", "'")
		dirtydata = replace(dirtydata, "&amp;", "&")
		cleanHTML = dirtydata
	end function
	
	
	Function return_RFC822_Date(myDate, offset)
	   Dim myDay, myDays, myMonth, myYear
	   Dim myHours, myMonths, myMinutes, mySeconds

	   myDate = CDate(myDate)
	   myDay = WeekdayName(Weekday(myDate),true)
	   myDays = Day(myDate)
	   myMonth = MonthName(Month(myDate), true)
	   myYear = Year(myDate)
	   myHours = zeroPad(Hour(myDate), 2)
	   myMinutes = zeroPad(Minute(myDate), 2)
	   mySeconds = zeroPad(Second(myDate), 2)

	   return_RFC822_Date = myDay&", "& _
									  myDays&" "& _
									  myMonth&" "& _ 
									  myYear&" "& _
									  myHours&":"& _
									  myMinutes&":"& _
									  mySeconds&" "& _ 
									  offset
	End Function 
	Function zeroPad(m, t)
	   zeroPad = String(t-Len(m),"0")&m
	End Function
	
	Function GetServerGMT()

		'// Use JScript to get the current GMT time stamp and store it in Session("ServerGMT")
		Server.Execute "GetServerGMT.asp"
		GetServerGMT = replace(Session("ServerGMT"), "UTC", "UT")

	End Function 
	
	Function getrfcdate(mydate)
  'format date in rfc-32
  'format:  Wed, 02 Oct 2002 08:00:00 EST
  
  dim myhour, myminute, mysecond, myday,mymonth, dayname, myyear

  If Hour(mydate)< 10 Then
    myhour = "0" & Hour(mydate)
  Else
    myhour = Hour(mydate)
  End If

  If minute(mydate)< 10 Then
    myminute = "0" & minute(mydate)
  Else
    myminute = minute(mydate)
  End If

  If second(mydate)< 10 Then
    mysecond = "0" & second(mydate)
  Else
    mysecond = second(mydate)
  End If

  If day(mydate)< 10 Then
    myday = "0" & day(mydate)
  Else
    myday = day(mydate)
  End If

  mymonth = monthName(Month(mydate),true)

  myyear = Year(mydate)

  dayname = WeekdayName(Weekday(mydate),true)

  mydate = dayname & ", " & myday & " " & mymonth & " " & myyear & " " & myhour & ":" & myminute & ":" & mysecond & " EST"

  getrfcdate = mydate
End Function

Function filterText(strdata)
		dim asd, filtercounter
		asd = strdata
		asd = replace(asd, "”","'")
		asd = replace(asd, "��", "'")
		asd = replace(asd, "’", "'")
		asd = replace(asd, "“", """")
		asd = replace(asd, "–", "'")
		asd = replace(asd, "’", "'")
		asd = replace(asd, "“", """")
		asd = replace(asd, "�€œ", """")
		asd = replace(asd, "�€�", "'")
		asd = replace(asd, "�€""", "")
		asd = replace(asd, "’", "'")
		asd = replace(asd, "•", "*")
		asd = replace(asd, "", "*")
		asd = replace(asd, "“", " ")
		asd = replace(asd, "�˜", " ")
		asd = replace(asd, "�'", " ")
		asd = Replace(asd, "�", "'")
		asd = Replace(asd, "&apos;", "'")
		asd = Replace(asd, "��", "'")
		asd = Replace(asd, "—", " -- ")
		asd = Replace(asd, "", "'")	
		asd = Replace(asd, "�", "'")	
		
		'for filtercounter = 1 to len(asd)
		'	if asc(mid(asd, filtercounter,1))> 127 then asd=replace(asd, mid(asd, filtercounter,1), "~")
		'next	
		'asd = replace(asd, "~", "")
	
		filterText = asd
	End Function
	
	
	Function GetShortSummary(strLongtext, maxlen)
		dim dirtydata

		strLongText = replace(strLongtext, "</p>", "  ")
		strLongText = replace(strLongtext, "<br>", "  ")
		strLongText = replace(strLongtext, "<br />", "  ")
		strLongText = RemoveHTML(strLongText)
		
		if maxlen < 151 then maxlen = 151
		if len(strLongtext) < maxlen then
			GetShortSummary = strLongtext
			exit function
		end if
		dim datastart
		datastart = maxlen - 50
		strLongText = replace(strLongtext, "�", "")
		dirtydata = left(strLongtext, datastart+300)
		if instr(datastart, dirtydata, "<p", 1) <> 0 then GetShortSummary = left(dirtydata, instr(datastart, dirtydata, "<p", 1)-1): exit function
		if instr(datastart, dirtydata, ".&nbsp;", 1) <> 0 then GetShortSummary = left(dirtydata, instr(datastart, dirtydata, ".&nbsp;", 1) + 54): exit function
		if instr(datastart, dirtydata, ". ", 1) <> 0 then GetShortSummary = left(dirtydata, instr(datastart, dirtydata, ". ", 1)): exit function
		if instr(datastart, dirtydata, "<br>", 1) <> 0 then GetShortSummary = left(dirtydata, instr(datastart, dirtydata, "<br>", 1)-1): exit function

		GetShortSummary = left(strLongtext, maxlen)

	End Function
	Function RemoveHTML( strText )
		Dim RegEx
	
		Set RegEx = New RegExp
	
		RegEx.Pattern = "<[^>]*>"
		RegEx.Global = True
	
		strText = RegEx.Replace(strText, "")
		
		strText = replace(strText, "'", "'")
		RemoveHTML = strText
		
	End Function
%>