<!-- Indsat fra functions.inc -->
<%
strDSN = "DRIVER={MySQL}; Server=mydb6.surf-town.net; Database=spoforum; Uid=spoaddict; Password=spassersoren;"

Function DBFix(tempString)
	tempString = Replace(Trim(tempString), "'", "''")
	tempString = Replace(tempString, "|", "")
	DBFix = tempString
End Function
%>






<!-- Lęs nyheder fra db -->
<%
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open strDSN


count = 0

strSQL = "SELECT *, DATE_FORMAT(date,'%d/%m kl %H:%i') AS posttime FROM 16cnyheder ORDER BY ID DESC"
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
	Do While ((Not rs.EOF) And count < 5)
		strSQL = "SELECT *, DATE_FORMAT(date,'%d/%m kl %H:%i') AS posttime, DATE_FORMAT(date,'%d-%m-%Y') AS FormDate, TIME_FORMAT(date,'%H:%i') AS FormTime FROM 16cnyheder WHERE (id =" & rs("id") & ")"
		Set formatDate = myConn.Execute(strSQL)
		dtmFormatDate = formatDate("FormDate")
		strSQL = "SELECT Count(*) AS ItemCount FROM lifnyheder Where (id = " & rs("id") & ")"
		Set recordCount = myConn.Execute(strSQL)
		
Function stripHTML(strHTML)
'Strips the HTML tags from strHTML

  Dim objRegExp, strOutput
  Set objRegExp = New Regexp

  objRegExp.IgnoreCase = True
  objRegExp.Global = True
  objRegExp.Pattern = "<(.|\n)+?>"

  'Replace all HTML tag matches with the empty string
  strOutput = objRegExp.Replace(strHTML, "")
  
  'Replace all < and > with &lt; and &gt;
  strOutput = Replace(strOutput, "<", "&lt;")
  strOutput = Replace(strOutput, ">", "&gt;")
  
  stripHTML = strOutput    'Return the value of strOutput

  Set objRegExp = Nothing
End Function

	' -- Funktion slut
		
		
		   		Function Shorten(sString, sLength) 
					If Len (sString) > sLength Then 
         				Shorten = Left(sString,sLength) & "...." 
					Else 
         				Shorten = sString
					End If 
				End Function
				sNews=Shorten(stripHTML(rs("nyhed")),100)	
	'	If count = 0 Then
			strHTML = strHTML & "<item><title>" & sNews & "</title>"
			strHTML = strHTML & "<posttime>" & rs("posttime") & "</posttime>"
			strHTML = strHTML & "<link>http://www.stolpaaos.dk/16c/nyheder.asp</link>"
			strHTML = strHTML & "<pubDate>" & rs("Date") & "</pubDate></item>"
	'	Else
	'	End if
					
		count = count + 1
		rs.MoveNext
	Loop
End If
myConn.Close
Set myConn = Nothing


'If InStr(Request.ServerVariables("HTTP_ACCEPT"), "application/xhtml+xml") > 0 Then
    Response.ContentType = "application/xml"
'Else
'    Response.ContentType = "text/html; charset=iso-8859-1"
'End If

Response.Charset = "iso-8859-1"
%><?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="0.91">
   <channel>
      <title>16c News</title>
      <link>http://www.stolpaaos.dk/16c/</link>
      <description>StolPaaOs.dk's 16c nyheder</description>
      <%=strHTML%></channel></rss>