<!-- #INCLUDE virtual="/lib/cn.asp" -->
<!-- #INCLUDE virtual="/lib/http_dates.asp" -->
<%

dim vMemberID, vKingdomID, vCatID, vChannelDescription
vMemberID = null
vKingdomID = null
vCatID = null
if len(request.querystring("m")) then
	vMemberID = no_xss(request.querystring("m"))
end if
if len(request.querystring("k")) > 0  then
	vKingdomID = no_xss(request.querystring("k"))
end if
if len(request.querystring("c")) > 0  then
	vCatID = no_xss(request.querystring("c"))
end if

vChannelDescription = "The art and practice of Medieval Fighting in the SCA."

with cmd
	.commandtext = "feed_articles"
	.Parameters.Append .createParameter("@memberID",3,1,4,vMemberID)
	.Parameters.Append .createParameter("@vKingdomID",3,1,4,vKingdomID)
	.Parameters.Append .createParameter("@catID",3,1,4,vCatID)
	set rs = .execute
	if not rs.eof then	
		if len(vMemberID) > 0 then
			vChannelDescription = "Articles written by " & rs.fields(3) & " of " & rs.fields(4)
		end if
		if len(vKingdomID) > 0 then
			vChannelDescription = "Articles written by the fighters of " & rs.fields(4)
		end if
		if len(vCatID) > 0 then
			vChannelDescription = rs.fields(6) & " Articles"
		end if
	end if
end with



dim oOutput,cks
set cks = Server.CreateObject("Chilkat.String")


function EntityEncode(strin)
	dim strout
	if len(strIn) > 0 then
		cks.str = strin
		cks.HtmlEntityEncode
		strout = cks.str
	end if
	EntityEncode = strout
end function



set oOutput = new faststring
with oOutput
	.append "<?xml version=""1.0"" encoding=""UTF-8""?>"
	'.append "<rss version=""2.0"" xmlns:dc=""http://purl.org/dc/elements/1.1/"">"
	.append "<rss version=""2.0"" xmlns:atom=""http://www.w3.org/2005/Atom"">"
	.append "<channel>"
	.append "<title>"& vChannelDescription &"</title>"
	.append "<atom:link href=""http://www.scafighting.com/rss-articles.xml"" rel=""self"" type=""application/rss+xml"" />"
	.append "<link>http://www.scafighting.com/rss-articles.xml</link>"
	.append "<language>en-us</language>"
	.append "<description>SCAFighting.com Feeds - "& vChannelDescription &" </description>"
	do while not rs.eof
		.append "<item>"
		.append "<title>" & EntityEncode(rs.fields("title")) & "</title>"
		.append "<description>"& EntityEncode(rs.fields("abstract")) &"</description>"
		.append "<pubDate>"& DateToHTTPDate(rs.fields("dateadded")) &"</pubDate>"
		.append "<author>spam@scafighting.com (" & EntityEncode(rs.fields("sname")) &" of " & EntityEncode(rs.fields("kingdomname")) & ")</author>"
		'.append "<dc:creator>"& EntityEncode(rs.fields("sname")) &" of " & EntityEncode(rs.fields("kingdomname")) & "</dc:creator>"
		.append "<guid isPermaLink=""true"">http://www.scafighting.com/article.asp?a="&  rs.fields("uid") &"</guid>"
		.append "<link>http://www.scafighting.com/article.asp?a="&  rs.fields("uid") &"</link>"
		.append "<category>"& EntityEncode(rs.fields("catname")) &"</category>"
    	.append "</item>"
		rs.movenext
	loop
	.append "</channel></rss>"
end with

Response.Clear()
response.ContentType="text/XML"
response.write oOutput.concat
%>
  
