feed.asp
上传用户:rblchem
上传日期:2022-04-27
资源大小:1941k
文件大小:7k
源码类别:

编辑器/阅读器

开发平台:

C#

  1. <!-- #include file="INCLUDE/head.ASP" -->
  2. <%
  3. Response.ContentType="text/xml"
  4. Response.Expires=60
  5. dbcate="/"%>
  6. <!--#include file="INCLUDE/conn.asp" -->
  7. <!--#include file="INCLUDE/RegExpFunction.asp" -->
  8. <%
  9. Function IsInteger(Para) 
  10. IsInteger=False
  11. If Not (IsNull(Para) Or Trim(Para)="" Or Not IsNumeric(Para)) Then
  12. IsInteger=True
  13. End If
  14. End Function
  15. Function DateToStr(DateTime,ShowType)  
  16. Dim DateMonth,DateDay,DateHour,DateMinute,DateWeek,DateSecond
  17. Dim FullWeekday,shortWeekday,Fullmonth,Shortmonth,TimeZone1,TimeZone2
  18. TimeZone1="+0800"
  19. TimeZone2="+08:00"
  20. FullWeekday=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
  21. shortWeekday=Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
  22.     Fullmonth=Array("January","February","March","April","May","June","July","August","September","October","November","December")
  23.     Shortmonth=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
  24. DateMonth=Month(DateTime)
  25. DateDay=Day(DateTime)
  26. DateHour=Hour(DateTime)
  27. DateMinute=Minute(DateTime)
  28. DateWeek=weekday(DateTime)
  29. DateSecond=Second(DateTime)
  30. If Len(DateMonth)<2 Then DateMonth="0"&DateMonth
  31. If Len(DateDay)<2 Then DateDay="0"&DateDay
  32. If Len(DateMinute)<2 Then DateMinute="0"&DateMinute
  33. Select Case ShowType
  34. Case "Y-m-d"  
  35. DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay
  36. Case "Y-m-d H:I A"
  37. Dim DateAMPM
  38. If DateHour>12 Then 
  39. DateHour=DateHour-12
  40. DateAMPM="PM"
  41. Else
  42. DateHour=DateHour
  43. DateAMPM="AM"
  44. End If
  45. If Len(DateHour)<2 Then DateHour="0"&DateHour
  46. DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&" "&DateAMPM
  47. Case "Y-m-d H:I:S"
  48. If Len(DateHour)<2 Then DateHour="0"&DateHour
  49. If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
  50. DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&":"&DateSecond
  51. Case "YmdHIS"
  52. DateSecond=Second(DateTime)
  53. If Len(DateHour)<2 Then DateHour="0"&DateHour
  54. If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
  55. DateToStr=Year(DateTime)&DateMonth&DateDay&DateHour&DateMinute&DateSecond
  56. Case "ym"
  57. DateToStr=Right(Year(DateTime),2)&DateMonth
  58. Case "d"
  59. DateToStr=DateDay
  60.     Case "ymd"
  61.         DateToStr=Right(Year(DateTime),4)&DateMonth&DateDay
  62.     Case "mdy" 
  63.         Dim DayEnd
  64.         select Case DateDay
  65.          Case 1 
  66.           DayEnd="st"
  67.          Case 2
  68.           DayEnd="nd"
  69.          Case 3
  70.           DayEnd="rd"
  71.          Case Else
  72.           DayEnd="th"
  73.         End Select 
  74.         DateToStr=Fullmonth(DateMonth-1)&" "&DateDay&DayEnd&" "&Right(Year(DateTime),4)
  75.     Case "w,d m y H:I:S" 
  76. DateSecond=Second(DateTime)
  77. If Len(DateHour)<2 Then DateHour="0"&DateHour
  78. If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
  79.         DateToStr=shortWeekday(DateWeek-1)&","&DateDay&" "& Left(Fullmonth(DateMonth-1),3) &" "&Right(Year(DateTime),4)&" "&DateHour&":"&DateMinute&":"&DateSecond&" "&TimeZone1
  80.     Case "y-m-dTH:I:S"
  81. If Len(DateHour)<2 Then DateHour="0"&DateHour
  82. If Len(DateSecond)<2 Then DateSecond="0"&DateSecond
  83. DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&"T"&DateHour&":"&DateMinute&":"&DateSecond&TimeZone2
  84. Case Else
  85. If Len(DateHour)<2 Then DateHour="0"&DateHour
  86. DateToStr=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute
  87. End Select
  88. End Function
  89. %>
  90. <%
  91. Set conn=ConnectDB()
  92. Dim cate_ID,FeedCate,FeedTitle,memName,FeedRows
  93. cate_ID=Request.QueryString("cateID")
  94. call CheckParameter(cate_ID,"int",empty)
  95. FeedCate=False
  96. FeedTitle=XNA_Title
  97. IF IsInteger(cate_ID) = False Then
  98. SQL="SELECT TOP "&XML_NUM&" * from Article order by pubDate desc"
  99. Else
  100. 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"
  101.     FeedCate=True
  102. End IF
  103. Set RS=Conn.ExeCute(SQL)
  104. if RS.EOF or RS.BOF then
  105. ReDim FeedRows(0,0)
  106.  else
  107.    if FeedCate then FeedTitle=XNA_Title & " - " & RS("Category_Name")
  108. FeedRows=RS.getrows()
  109. end if
  110. RS.close
  111. set RS=nothing
  112. CloseDB(conn)
  113. Set objXMLdoc = CreateObject("Microsoft.XMLDOM")
  114. objXMLdoc.preserveWhiteSpace = True
  115. Set objPI = objXMLdoc.createProcessingInstruction ("xml","version='1.0' encoding='utf-8'")
  116. objXMLdoc.insertBefore objPI, objXMLdoc.childNodes(0)
  117. Set objXMLroot = objXMLdoc.createNode("element", "rss", "")
  118. objXMLroot.SetAttribute "version", "2.0"
  119. objXMLdoc.AppendChild(objXMLroot)
  120. set objXMLchannel = objXMLdoc.createNode("element", "channel", "")
  121. objXMLroot.AppendChild(objXMLchannel)
  122. set objXMLTitle = objXMLdoc.createNode("element", "title", "")
  123. objXMLTitle.Text = FeedTitle
  124. objXMLchannel.AppendChild(objXMLTitle)
  125. set objXMLink = objXMLdoc.createNode("element", "link", "")
  126. objXMLink.Text = XNA_URL
  127. objXMLchannel.AppendChild(objXMLink)
  128. set objXMLDescription = objXMLdoc.createNode("element", "description", "")
  129. objXMLDescription.Text = XNA_description
  130. objXMLchannel.AppendChild(objXMLDescription)
  131. set objXMLanguage = objXMLdoc.createNode("element", "language", "")
  132. objXMLanguage.Text = "zh-cn"
  133. objXMLchannel.AppendChild(objXMLanguage)
  134. set objXMLPubDate = objXMLdoc.createNode("element", "pubDate", "")
  135. objXMLPubDate.Text = Now()
  136. objXMLchannel.AppendChild(objXMLPubDate)
  137. set objXMLgenerator = objXMLdoc.createNode("element", "generator", "")
  138. objXMLgenerator.Text = "SXNA(www.sxna.cn)(www.dc9.cn)"
  139. objXMLchannel.AppendChild(objXMLgenerator)
  140. set objXMLcopyright = objXMLdoc.createNode("element", "copyright", "")
  141. objXMLcopyright.Text = "Copyright 2005 sxna.cn, All rights reserved."
  142. objXMLchannel.AppendChild(objXMLcopyright)
  143. If ubound(FeedRows,2)=0 then
  144. set objXMLItem = objXMLdoc.createNode("element", "item", "")
  145. objXMLchannel.AppendChild(objXMLItem)
  146. Else
  147. for i=0 to ubound(FeedRows,2)
  148. set objXMLItem = objXMLdoc.createNode("element", "item", "")
  149. objXMLchannel.AppendChild(objXMLItem)
  150. set objXMLTitle = objXMLdoc.createNode("element", "title", "")
  151. objXMLTitle.Text = FeedRows(0,i)
  152. objXMLItem.AppendChild(objXMLTitle)
  153. set objXMLAuthor = objXMLdoc.createNode("element", "author", "")
  154. objXMLAuthor.Text = FeedRows(1,i)
  155. objXMLItem.AppendChild(objXMLAuthor)
  156. set objXMLPubDate = objXMLdoc.createNode("element", "pubDate", "")
  157. objXMLPubDate.Text = DateToStr(FeedRows(3,i),"w,d m y H:I:S")
  158. objXMLItem.AppendChild(objXMLPubDate)
  159. set objXMLink = objXMLdoc.createNode("element", "link", "")
  160. objXMLink.Text = FeedRows(2,i)
  161. objXMLItem.AppendChild(objXMLink)
  162. set objXMLDescription = objXMLdoc.createNode("element", "description", "")
  163. objXMLDescription.Text = FeedRows(4,i)
  164. objXMLItem.AppendChild(objXMLDescription)
  165. next
  166. End If
  167. response.write objXMLDoc.xml
  168. %>