rss_lib.asp
上传用户:saigedz
上传日期:2019-10-14
资源大小:997k
文件大小:7k
源码类别:

中间件编程

开发平台:

HTML/CSS

  1. <%
  2. '///////////////////////////////////////////////////////////////////////////////
  3. '//              RainbowSoft RSS Export
  4. '// 作    者:    朱煊(zx.asd)
  5. '// 版权所有:    RainbowSoft Studio
  6. '// 技术支持:    rainbowsoft@163.com
  7. '// 程序名称:    
  8. '// 程序版本:    
  9. '// 单元名称:    rss_lib.asp
  10. '// 开始时间:    2004.07.03
  11. '// 最后修改:    
  12. '// 备    注:    RSS输出
  13. '///////////////////////////////////////////////////////////////////////////////
  14. '*********************************************************
  15. ' 目的:    定义TRss2Export类
  16. ' 输入:    无
  17. ' 返回:    无
  18. '*********************************************************
  19. Class TRss2Export
  20. Public TimeZone
  21. Public Property Get xml
  22. xml = objXMLdoc.xml
  23. End Property
  24. public FstrWebLink
  25. public FstrAuthor
  26. Public Property Get WebLink
  27. WebLink = FstrWebLink
  28. End Property
  29. Public Property Let WebLink(strWebLink)
  30. FstrWebLink = strWebLink
  31. End Property
  32. Public Property Get Author
  33. Author = FstrAuthor
  34. End Property
  35. Public Property Let Author(strAuthor)
  36. FstrAuthor = strAuthor
  37. End Property
  38. Private objXMLdoc
  39. Private objXMLrss
  40. Private objXMLchannel
  41. Public Function AddChannelAttribute(title,value)
  42. Dim objXMLitem
  43. Set objXMLitem = objXMLdoc.createElement(title)
  44. If title="pubDate" Then value=ParseDateForRFC822(value)
  45. objXMLitem.text=value
  46. objXMLchannel.AppendChild(objXMLitem)
  47. AddChannelAttribute=True
  48. End Function
  49. Public Function AddItem(title,author,link,pubDate,guid,description,category,comments,wfw_comment,wfw_commentRss,trackback_ping)
  50. Dim objXMLitem
  51. Set objXMLitem = objXMLdoc.createElement("item")
  52. Dim objXMLcdata
  53. If(Len(title)>0) Then
  54. objXMLitem.AppendChild(objXMLdoc.createElement("title"))
  55. objXMLitem.selectSingleNode("title").text=title
  56. End If
  57. If(Len(author)>0) Then
  58. objXMLitem.AppendChild(objXMLdoc.createElement("author"))
  59. objXMLitem.selectSingleNode("author").text=author
  60. End If
  61. If(Len(link)>0) Then
  62. objXMLitem.AppendChild(objXMLdoc.createElement("link"))
  63. objXMLitem.selectSingleNode("link").text=link
  64. End If
  65. If(Len(pubDate)>0) Then
  66. objXMLitem.AppendChild(objXMLdoc.createElement("pubDate"))
  67. objXMLitem.selectSingleNode("pubDate").text=ParseDateForRFC822(pubDate)
  68. End If
  69. If(Len(guid)>0) Then
  70. objXMLitem.AppendChild(objXMLdoc.createElement("guid"))
  71. objXMLitem.selectSingleNode("guid").text=guid
  72. End If
  73. If(Len(description)>0) Then
  74. objXMLitem.AppendChild(objXMLdoc.createElement("description"))
  75. Set objXMLcdata = objXMLdoc.createNode("cdatasection", "","")
  76. objXMLcdata.NodeValue=description
  77. objXMLitem.selectSingleNode("description").AppendChild(objXMLcdata)
  78. Set objXMLcdata = Nothing
  79. End If
  80. If(Len(category)>0) Then
  81. objXMLitem.AppendChild(objXMLdoc.createElement("category"))
  82. objXMLitem.selectSingleNode("category").text=category
  83. End If
  84. If(Len(comments)>0) Then
  85. objXMLitem.AppendChild(objXMLdoc.createElement("comments"))
  86. objXMLitem.selectSingleNode("comments").text=comments
  87. End If
  88. If(Len(wfw_comment)>0) Then
  89. objXMLitem.AppendChild(objXMLdoc.createElement("wfw:comment"))
  90. objXMLitem.selectSingleNode("wfw:comment").text=wfw_comment
  91. End If
  92. If(Len(wfw_commentRss)>0) Then
  93. objXMLitem.AppendChild(objXMLdoc.createElement("wfw:commentRss"))
  94. objXMLitem.selectSingleNode("wfw:commentRss").text=wfw_commentRss
  95. End If
  96. If(Len(trackback_ping)>0) Then
  97. objXMLitem.AppendChild(objXMLdoc.createElement("trackback:ping"))
  98. objXMLitem.selectSingleNode("trackback:ping").text=trackback_ping
  99. End If
  100. objXMLchannel.AppendChild(objXMLitem)
  101. AddItem=True
  102. End Function
  103. Public Function Execute()
  104. 'Response.ContentType = "text/html"
  105. Response.ContentType = "text/xml"
  106. Response.Clear
  107. Response.Write xml
  108. Execute=True
  109. End Function
  110. Public Function SaveToFile(strFileName)
  111. objXMLdoc.save(strFileName)
  112. SaveToFile=True
  113. End Function
  114. Function ParseDateForRFC822(dtmDate)
  115. Dim dtmDay, dtmWeekDay, dtmMonth, dtmYear
  116. Dim dtmHours, dtmMinutes, dtmSeconds
  117. Select Case WeekDay(dtmDate)
  118. Case 1:dtmWeekDay="Sun"
  119. Case 2:dtmWeekDay="Mon"
  120. Case 3:dtmWeekDay="Tue"
  121. Case 4:dtmWeekDay="Wed"
  122. Case 5:dtmWeekDay="Thu"
  123. Case 6:dtmWeekDay="Fri"
  124. Case 7:dtmWeekDay="Sat"
  125. End Select
  126. Select Case Month(dtmDate)
  127. Case 1:dtmMonth="Jan"
  128. Case 2:dtmMonth="Feb"
  129. Case 3:dtmMonth="Mar"
  130. Case 4:dtmMonth="Apr"
  131. Case 5:dtmMonth="May"
  132. Case 6:dtmMonth="Jun"
  133. Case 7:dtmMonth="Jul"
  134. Case 8:dtmMonth="Aug"
  135. Case 9:dtmMonth="Sep"
  136. Case 10:dtmMonth="Oct"
  137. Case 11:dtmMonth="Nov"
  138. Case 12:dtmMonth="Dec"
  139. End Select
  140. dtmYear = Year(dtmDate)
  141. dtmDay = Right("00" & Day(dtmDate),2)
  142. dtmHours = Right("00" & Hour(dtmDate),2)
  143. dtmMinutes = Right("00" & Minute(dtmDate),2)
  144. dtmSeconds = Right("00" & Second(dtmDate),2)
  145. ParseDateForRFC822 = dtmWeekDay & ", " & dtmDay &" " & dtmMonth & " " & dtmYear & " " & dtmHours & ":" & dtmMinutes & ":" & dtmSeconds & " " & TimeZone
  146. End Function 
  147. ' 类初始化
  148. Private Sub Class_Initialize()
  149. On Error Resume Next
  150. '对objXMLdoc进行初始化,如不能建对象则报错
  151. Set objXMLdoc =Server.CreateObject("Microsoft.XMLDOM")
  152. If Err.Number<>0 Then
  153. End If
  154. Dim objPI
  155. 'Set objPI = objXMLdoc.createProcessingInstruction("xml-stylesheet","type=""text/css"" href=""css/rss.css""")
  156. 'objXMLdoc.insertBefore objPI, objXMLdoc.childNodes(0)
  157. 'Set objPI = Nothing
  158. Set objPI = objXMLdoc.createProcessingInstruction("xml-stylesheet","type=""text/xsl"" href=""css/rss.xslt""")
  159. objXMLdoc.insertBefore objPI, objXMLdoc.childNodes(0)
  160. Set objPI = Nothing
  161. Set objPI = objXMLdoc.createProcessingInstruction("xml","version=""1.0"" encoding=""UTF-8"" standalone=""yes""")
  162. objXMLdoc.insertBefore objPI, objXMLdoc.childNodes(0)
  163. Set objPI = Nothing
  164. Set objXMLrss = objXMLdoc.createElement("rss")
  165. Set objXMLchannel = objXMLdoc.createElement("channel")
  166. objXMLrss.AppendChild(objXMLchannel)
  167. objXMLdoc.AppendChild(objXMLrss)
  168. objXMLrss.setAttribute "version","2.0"
  169. objXMLrss.setAttribute "xmlns:dc","http://purl.org/dc/elements/1.1/"
  170. objXMLrss.setAttribute "xmlns:trackback","http://madskills.com/public/xml/rss/module/trackback/"
  171. objXMLrss.setAttribute "xmlns:wfw","http://wellformedweb.org/CommentAPI/"
  172. objXMLrss.setAttribute "xmlns:slash","http://purl.org/rss/1.0/modules/slash/"
  173. End Sub
  174. ' 类释放
  175. Private Sub Class_Terminate()
  176. Set objXMLrss = Nothing
  177. Set objXMLdoc  = Nothing
  178. End Sub
  179. End Class
  180. '*********************************************************
  181. %>