feed.asp
上传用户:rblchem
上传日期:2022-04-27
资源大小:1941k
文件大小:7k
- <!-- #include file="INCLUDE/head.ASP" -->
- <%
- Response.ContentType="text/xml"
- Response.Expires=60
- dbcate="/"%>
- <!--#include file="INCLUDE/conn.asp" -->
- <!--#include file="INCLUDE/RegExpFunction.asp" -->
- <%
- Function IsInteger(Para)
- IsInteger=False
- If Not (IsNull(Para) Or Trim(Para)="" Or Not IsNumeric(Para)) Then
- IsInteger=True
- End If
- End Function
- Function DateToStr(DateTime,ShowType)
- Dim DateMonth,DateDay,DateHour,DateMinute,DateWeek,DateSecond
- Dim FullWeekday,shortWeekday,Fullmonth,Shortmonth,TimeZone1,TimeZone2
- TimeZone1="+0800"
- TimeZone2="+08:00"
- FullWeekday=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
- shortWeekday=Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
- Fullmonth=Array("January","February","March","April","May","June","July","August","September","October","November","December")
- Shortmonth=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
- DateMonth=Month(DateTime)
- DateDay=Day(DateTime)
- DateHour=Hour(DateTime)
- DateMinute=Minute(DateTime)
- DateWeek=weekday(DateTime)
- DateSecond=Second(DateTime)
- If Len(DateMonth)<2 Then DateMonth="0"&DateMonth
- If Len(DateDay)<2 Then DateDay="0"&DateDay
- If Len(DateMinute)<2 Then DateMinute="0"&DateMinute
- Select Case ShowType
- Case "Y-m-d"
- DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay
- Case "Y-m-d H:I A"
- Dim DateAMPM
- If DateHour>12 Then
- DateHour=DateHour-12
- DateAMPM="PM"
- Else
- DateHour=DateHour
- DateAMPM="AM"
- End If
- If Len(DateHour)<2 Then DateHour="0"&DateHour
- DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&" "&DateAMPM
- Case "Y-m-d H:I:S"
- If Len(DateHour)<2 Then DateHour="0"&DateHour
- If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
- DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&":"&DateSecond
- Case "YmdHIS"
- DateSecond=Second(DateTime)
- If Len(DateHour)<2 Then DateHour="0"&DateHour
- If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
- DateToStr=Year(DateTime)&DateMonth&DateDay&DateHour&DateMinute&DateSecond
- Case "ym"
- DateToStr=Right(Year(DateTime),2)&DateMonth
- Case "d"
- DateToStr=DateDay
- Case "ymd"
- DateToStr=Right(Year(DateTime),4)&DateMonth&DateDay
- Case "mdy"
- Dim DayEnd
- select Case DateDay
- Case 1
- DayEnd="st"
- Case 2
- DayEnd="nd"
- Case 3
- DayEnd="rd"
- Case Else
- DayEnd="th"
- End Select
- DateToStr=Fullmonth(DateMonth-1)&" "&DateDay&DayEnd&" "&Right(Year(DateTime),4)
- Case "w,d m y H:I:S"
- DateSecond=Second(DateTime)
- If Len(DateHour)<2 Then DateHour="0"&DateHour
- If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
- DateToStr=shortWeekday(DateWeek-1)&","&DateDay&" "& Left(Fullmonth(DateMonth-1),3) &" "&Right(Year(DateTime),4)&" "&DateHour&":"&DateMinute&":"&DateSecond&" "&TimeZone1
- Case "y-m-dTH:I:S"
- If Len(DateHour)<2 Then DateHour="0"&DateHour
- If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
- DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&"T"&DateHour&":"&DateMinute&":"&DateSecond&TimeZone2
- Case Else
- If Len(DateHour)<2 Then DateHour="0"&DateHour
- DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute
- End Select
- End Function
- %>
- <%
- Set conn=ConnectDB()
- Dim cate_ID,FeedCate,FeedTitle,memName,FeedRows
- cate_ID=Request.QueryString("cateID")
- call CheckParameter(cate_ID,"int",empty)
- FeedCate=False
- FeedTitle=XNA_Title
- IF IsInteger(cate_ID) = False Then
- SQL="SELECT TOP "&XML_NUM&" * from Article order by pubDate desc"
- Else
- SQL="SELECT TOP "&XML_NUM&" * from [Article] INNER JOIN [Category] ON Article.Category_id = Category.Category_id WHERE Article.Category_id="&cate_ID&" order by pubDate desc"
- FeedCate=True
- End IF
- Set RS=Conn.ExeCute(SQL)
- if RS.EOF or RS.BOF then
- ReDim FeedRows(0,0)
- else
- if FeedCate then FeedTitle=XNA_Title & " - " & RS("Category_Name")
- FeedRows=RS.getrows()
- end if
- RS.close
- set RS=nothing
- CloseDB(conn)
- Set objXMLdoc = CreateObject("Microsoft.XMLDOM")
- objXMLdoc.preserveWhiteSpace = True
- Set objPI = objXMLdoc.createProcessingInstruction ("xml","version='1.0' encoding='utf-8'")
- objXMLdoc.insertBefore objPI, objXMLdoc.childNodes(0)
- Set objXMLroot = objXMLdoc.createNode("element", "rss", "")
- objXMLroot.SetAttribute "version", "2.0"
- objXMLdoc.AppendChild(objXMLroot)
- set objXMLchannel = objXMLdoc.createNode("element", "channel", "")
- objXMLroot.AppendChild(objXMLchannel)
- set objXMLTitle = objXMLdoc.createNode("element", "title", "")
- objXMLTitle.Text = FeedTitle
- objXMLchannel.AppendChild(objXMLTitle)
- set objXMLink = objXMLdoc.createNode("element", "link", "")
- objXMLink.Text = XNA_URL
- objXMLchannel.AppendChild(objXMLink)
- set objXMLDescription = objXMLdoc.createNode("element", "description", "")
- objXMLDescription.Text = XNA_description
- objXMLchannel.AppendChild(objXMLDescription)
- set objXMLanguage = objXMLdoc.createNode("element", "language", "")
- objXMLanguage.Text = "zh-cn"
- objXMLchannel.AppendChild(objXMLanguage)
- set objXMLPubDate = objXMLdoc.createNode("element", "pubDate", "")
- objXMLPubDate.Text = Now()
- objXMLchannel.AppendChild(objXMLPubDate)
- set objXMLgenerator = objXMLdoc.createNode("element", "generator", "")
- objXMLgenerator.Text = "SXNA(www.sxna.cn)(www.dc9.cn)"
- objXMLchannel.AppendChild(objXMLgenerator)
- set objXMLcopyright = objXMLdoc.createNode("element", "copyright", "")
- objXMLcopyright.Text = "Copyright 2005 sxna.cn, All rights reserved."
- objXMLchannel.AppendChild(objXMLcopyright)
- If ubound(FeedRows,2)=0 then
- set objXMLItem = objXMLdoc.createNode("element", "item", "")
- objXMLchannel.AppendChild(objXMLItem)
- Else
- for i=0 to ubound(FeedRows,2)
- set objXMLItem = objXMLdoc.createNode("element", "item", "")
- objXMLchannel.AppendChild(objXMLItem)
- set objXMLTitle = objXMLdoc.createNode("element", "title", "")
- objXMLTitle.Text = FeedRows(0,i)
- objXMLItem.AppendChild(objXMLTitle)
- set objXMLAuthor = objXMLdoc.createNode("element", "author", "")
- objXMLAuthor.Text = FeedRows(1,i)
- objXMLItem.AppendChild(objXMLAuthor)
- set objXMLPubDate = objXMLdoc.createNode("element", "pubDate", "")
- objXMLPubDate.Text = DateToStr(FeedRows(3,i),"w,d m y H:I:S")
- objXMLItem.AppendChild(objXMLPubDate)
- set objXMLink = objXMLdoc.createNode("element", "link", "")
- objXMLink.Text = FeedRows(2,i)
- objXMLItem.AppendChild(objXMLink)
- set objXMLDescription = objXMLdoc.createNode("element", "description", "")
- objXMLDescription.Text = FeedRows(4,i)
- objXMLItem.AppendChild(objXMLDescription)
- next
- End If
- response.write objXMLDoc.xml
- %>