<?xml version="1.0" encoding="iso-8859-1"?>
<%
session.LCID = 2067
Response.Buffer = true
Response.ContentType = "text/xml"
   
Function ApplyXMLFormatting(strInput)
  strInput = Replace(strInput,"&", "&amp;")
  strInput = Replace(strInput,"'", "'")
  strInput = Replace(strInput,"""", "&quot;")
  strInput = Replace(strInput, ">", "&gt;")
  strInput = Replace(strInput,"<","&lt;")
  
  ApplyXMLFormatting = strInput
End Function   

function AspToMySql(waarde)

	if waarde <> "" then
	arrWaarden = split(waarde, "-")
	
	AspToMySql = arrWaarden(2) & "-" & arrWaarden(1) & "-" & arrWaarden(0)
	else
	AspToMySql = ""
	end if
	
end function

Function RSSDate(TheDateTime)

   TheDay = Day(TheDateTime)
   DayName = WeekdayName(Weekday(TheDateTime),True)
   TheMonth = MonthName(Month(TheDateTime),True)
   TheYear = Year(TheDateTime)
   TheHour = Hour(TheDateTime)
   TheMinute = Minute(TheDateTime)
   TheSecond = Second(TheDateTime)

   While Len(TheDay) < 2
      TheDay = CStr("0" & TheDay)
   Wend
   While Len(TheHour) < 2
      TheHour = CStr("0" & TheHour)
   Wend
   While Len(TheMinute) < 2
      TheMinute = CStr("0" & TheMinute)
   Wend
   While Len(TheSecond) < 2
      TheSecond = CStr("0" & TheSecond)
   Wend

  RSSDate = DayName & ", " & TheDay & " " & TheMonth & " " & TheYear '& " " & TheHour & ":" & TheMinute & ":" & TheSecond & " GMT"

End Function

function myfunc(a)
    myfunc = ucase(left(a,1)) & lcase(mid(a,2))
end function

function replacePictureOverzicht(strInput)

	strOutput = strInput
	
	Set RegExpObj = New RegExp
	
	with RegExpObj
		.pattern = "\[img src=(.*) storypicture=(.*)\]"
		.ignoreCase = true
		.global = true
	end with
	
	strOutput = RegExpObj.replace(strOutput, "")

	replacePictureOverzicht = strOutput

end function

function formatTekst(strInput)

	strOutput = strInput
	
	arrWaarden = split(strOutput, "[overzicht]")
	
	strOutput = replace(arrWaarden(0), "[inleiding]", "")
	strOutput = replace(strOutput, "[/inleiding]", "")

	strOutput = replace(strOutput, vbCrlf, " ")
	
	strOutput = replace(strOutput, "[adsense]", "")

	formatTekst = strOutput

end function
%>

<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Kortrijk-Shopt: recente artikels</title>
    <link>http://www.kortrijk-shopt.be/</link>
    <description>De laatste artikels die verschenen zijn op de website van Kortrijk-Shopt.</description>
    <language>nl-BE</language>
    <copyright>kortrijk-shopt.be</copyright>
    <lastBuildDate><%=RSSDate(Now())%></lastBuildDate>
	
	<image>
		<title>Kortrijk-Shopt: recente artikels</title>
		<url>http://www.kortrijk-shopt.be/images/kortrijkshopt_rss.gif</url>
		<link>http://www.kortrijk-shopt.be</link>

		<width>78</width>
		<height>74</height>
		<description>kortrijk-shopt.be</description>
	</image>	
	<%
	set dbShopt = createobject("ADODB.Connection")
	connstring = "driver={MySQL ODBC 3.51 Driver}; server =localhost; uid=shopt; pwd=htPLHZyUfdX6WBvC; database=kortrijk-shopt"
	dbShopt.open(connstring)
	
	Set RecNieuwsfeit = dbShopt.execute("SELECT * FROM artikel WHERE online = 1 AND artikelCategorieId = 1 AND datePublished <= '"&aspToMySql(replace(date(), "/", "-"))&"' AND (dateEnd >= '"&aspToMySql(replace(date(), "/", "-"))&"' OR dateEnd is null) ORDER BY datePublished DESC, artikelId DESC LIMIT 15")
	
	Do until RecNieuwsfeit.EOF
	Set RecCategorie = dbShopt.execute("SELECT * FROM artikelCategorie WHERE artikelCategorieId = "&RecNieuwsfeit("artikelCategorieId"))
	%>
	<item>
	  <title><%=ApplyXMLFormatting(RecNieuwsfeit("titel"))%></title>
	  <link>http://www.kortrijk-shopt.be/<%=RecCategorie("titelSeo")%>/<%=RecNieuwsfeit("titelSeo")%>.htm</link>
	  <description><%=ApplyXMLFormatting(myfunc(formatTekst(RecNieuwsfeit("inhoud"))))%></description>
	  <category><%=myfunc(RecCategorie("categorie"))%></category>
	</item>
	<%
	RecNieuwsfeit.MoveNext
	Loop

%>
  </channel>
</rss>