
如果一个Z-Blog博客已经停止更新了,但是需要将博客的RSS Feed能将老文章按照指定的频率更新给读者看,那么可以使用本文介绍的方法来修改程序。
这个程序还可用于各种支持RSS的社交平台或工具进行内容的自动更新,使用FeedBurner烧制这个RSS Feed后,会自动将Blog的文章更新到各个社交平台,使其无人维护的时候也能更新。
程序开通几个变量,startDate为开始时间,格式为日期格式,interval为间隔分钟数,用于设置更新频率,系统会自动在间隔interval分钟后更新一篇文章。默认更新频率为每天更新一次。
将Z-Blog根目录下的feed.asp文件复制为一个新文件名,例如rss.asp,对文件进行如下修改:
修改第60行,将 Response.Write LoadFromFile(BlogPath & "zb_users\cache\rss.xml" ,"utf-8") 修改为 Call ExportRSSbyStartID
在后面增加如下代码,之后在外部通过rss.asp调用即可。
Function HtmlEncode(strIn)
strIn = Replace(strIn, "“", "“")
strIn = Replace(strIn, "”", "”")
strIn = Replace(strIn, """, "“")
strIn = Replace(strIn, ">", ">")
strIn = Replace(strIn, "<", "<")
strIn = Replace(strIn, "·", "·")
strIn = Replace(strIn, " ", "")
strIn = Replace(strIn, " ", "")
strIn = Replace(strIn, "<p>", "")
strIn = Replace(strIn, "</p>", "")
strIn = Replace(strIn, "<p style=""text-align: center"">", "..")
HtmlEncode = strIn
End Function
Function ExportRSSbyStartID()
Dim Rss2Export
Dim objArticle
dim startDate
dim startID
dim strIntro
dim strPos
startDate = "2023-6-3 10:10:00"
startID = DateDiff("d", startDate, Now())
Set Rss2Export = New TNewRss2Export
With Rss2Export
Call CheckParameter(CateID,"int",0)
Dim objRS,CateName,CateIntro
.TimeZone=ZC_TIME_ZONE
'Call GetCategory()
Call GetUser
.AddChannelAttribute "title",TransferHTML(ZC_BLOG_TITLE,"[html-format]")
.AddChannelAttribute "link",TransferHTML(BlogHost,"[html-format]")
.AddChannelAttribute "description",TransferHTML(ZC_BLOG_SUBTITLE,"[html-format]")
.AddChannelAttribute "generator","RainbowSoft Studio Z-Blog " & ZC_BLOG_VERSION
.AddChannelAttribute "language",ZC_BLOG_LANGUAGE
.AddChannelAttribute "copyright",TransferHTML(ZC_BLOG_COPYRIGHT,"[nohtml][html-format]")
.AddChannelAttribute "pubDate",Now
Dim i
Dim logid
Set objRS=objConn.Execute("SELECT [log_ID],[log_Tag],[log_CateID],[log_Title],[log_Intro],[log_Content],[log_Level],[log_AuthorID],[log_PostTime],[log_CommNums],[log_ViewNums],[log_TrackBackNums],[log_Url],[log_Istop],[log_Template],[log_FullUrl],[log_Type],[log_Meta] FROM [blog_Article] WHERE ([log_ID]>0) AND ([log_Level]>2) AND ([log_ID]<"&cstr(startID)&") ORDER BY [log_PostTime] DESC")
If (Not objRS.bof) And (Not objRS.eof) Then
For i=1 to ZC_RSS2_COUNT
Set objArticle=New TArticle
If objArticle.LoadInfoByArray(Array(objRS(0),objRS(1),objRS(2),objRS(3),objRS(4),objRS(5),objRS(6),objRS(7),objRS(8),objRS(9),objRS(10),objRS(11),objRS(12),objRS(13),objRS(14),objRS(15),objRS(16),objRS(17))) Then
strIntro = HtmlEncode(objArticle.HtmlIntro)
strPos = inStr(strIntro,"<img")
if strPos + len(objArticle.HtmlTitle) >= 134 then
strIntro = Left(strIntro,134-len(objArticle.HtmlTitle)) + ".." + Right(strIntro,len(strIntro)-strPos+1)
end if
If ZC_RSS_EXPORT_WHOLE Then
.AddItem objArticle.HtmlTitle,Users(objArticle.AuthorID).Email & " (" & Users(objArticle.AuthorID).FirstName & ")",objArticle.HtmlUrl,DateAdd("d", - i, Now),objArticle.HtmlUrl,strIntro ,Categorys(objArticle.CateID).HtmlName,objArticle.CommentUrl,objArticle.WfwComment,objArticle.WfwCommentRss,objArticle.TrackBackUrl
Else
.AddItem objArticle.HtmlTitle,Users(objArticle.AuthorID).Email & " (" & Users(objArticle.AuthorID).FirstName & ")",objArticle.HtmlUrl,DateAdd("d", - i, Now),objArticle.HtmlUrl,HtmlEncode(objArticle.HtmlIntro),Categorys(objArticle.CateID).HtmlName,objArticle.CommentUrl,objArticle.WfwComment,objArticle.WfwCommentRss,objArticle.TrackBackUrl
End If
End If
objRS.MoveNext
If objRS.eof Then Exit For
Set objArticle=Nothing
Next
End If
End With
objRS.close
Set objRS=Nothing
Rss2Export.Execute
Set Rss2Export = Nothing
End Function