/// <summary> /// 加载feed /// </summary> protected void LoadFeed() { int categoryId = RequestHelper.QueryInt("categoryid", -1); int postId = RequestHelper.QueryInt("postid", -1); string action = RequestHelper.QueryString("action", true); // Response.Clear(); Response.ContentType = "text/xml"; if (SettingManager.GetSetting().RssStatus == 1) { switch (action) { case "comment": List<CommentInfo> commentList = CommentManager.GetCommentList(SettingManager.GetSetting().RssRowCount, 1, -1, postId, 0, 1, -1, null); PostInfo commentPost = PostManager.GetPost(postId); Response.Write("<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\" xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\">\r\n"); Response.Write(" <channel>\r\n"); Response.Write(" <title><![CDATA[" + (commentPost == null ? SettingManager.GetSetting().SiteName : commentPost.Title) + "的评论]]></title>\r\n"); Response.Write(" <link><![CDATA[" + (commentPost == null ? ConfigHelper.SiteUrl : commentPost.Url) + "]]></link>\r\n"); Response.Write(" <description><![CDATA[" + SettingManager.GetSetting().SiteDescription + "]]></description>\r\n"); Response.Write(" <pubDate>" + DateTime.Now.ToString("r") + "</pubDate>\r\n"); Response.Write(" <generator>Loachs</generator>\r\n"); Response.Write(" <language>zh-cn</language>\r\n"); foreach (CommentInfo comment in commentList) { Response.Write(" <item>\r\n"); Response.Write(" <title><![CDATA[" + comment.Name + "对" + comment.Post.Title + "的评论]]></title>\r\n"); Response.Write(" <link><![CDATA[" + comment.Url + "]]></link>\r\n"); Response.Write(" <guid><![CDATA[" + comment.Url + "]]></guid>\r\n"); Response.Write(" <author><![CDATA[" + comment.Name + "]]></author>\r\n"); Response.Write(string.Format(" <description><![CDATA[{0}]]></description>\r\n", comment.Content)); Response.Write(" <pubDate>" + comment.CreateDate.ToString("r") + "</pubDate>\r\n"); Response.Write(" </item>\r\n"); } Response.Write(" </channel>\r\n"); Response.Write("</rss>\r\n"); break; default: List<PostInfo> list = PostManager.GetPostList(SettingManager.GetSetting().RssRowCount, categoryId, -1, -1, 1, -1, 0); templatePath = Server.MapPath(ConfigHelper.SitePath + "common/config/"); th = new TemplateHelper(templatePath); LoadDefault(); th.Put(TagFields.FEED_POSTS, list); Display("feed.config"); break; } } else { Response.Write("<rss>error</rss>\r\n"); } // Response.End(); }
protected void Page_Load(object sender, EventArgs e) { // Response.Write(Server.UrlDecode(Request.Url.ToString())); if (pageType == "checkurlrewriter") { Response.Clear(); Response.Write("支持当前设置的URL重写规则"); Response.End(); } UpdateViewCount(); if (SettingManager.GetSetting().SiteStatus == 0) { ResponseError("网站已关闭", "网站已关闭,请与站长联系!"); } themeName = SettingManager.GetSetting().Theme; if (RequestHelper.IsMobile) { themeName = SettingManager.GetSetting().MobileTheme; } if (!string.IsNullOrEmpty(previewThemeName)) { themeName = previewThemeName; } // Response.Write("ismobile:" + RequestHelper.IsMobile + ",IsMobileDevice:" + Request.Browser.IsMobileDevice + ",BrowserType:" + Request.Browser.Type + ",UserAgent:" + Request.UserAgent + ",HTTP_ACCEPT:" + Request.ServerVariables["HTTP_ACCEPT"]); templatePath = Server.MapPath(string.Format("{0}/themes/{1}/template/", ConfigHelper.SitePath, themeName)); //if (!System.IO.Directory.Exists(templatePath) && !string.IsNullOrEmpty(previewThemeName)) //{ // ResponseError("预览主题不存在", "预览的主题不存在,是否修改了URL地址?"); //} //非预览时 if (!System.IO.Directory.Exists(templatePath) && string.IsNullOrEmpty(previewThemeName)) { SettingInfo s = SettingManager.GetSetting(); if (RequestHelper.IsMobile) { s.MobileTheme = "default"; } else { s.Theme = "default"; } themeName = "default"; SettingManager.UpdateSetting(); templatePath = Server.MapPath(string.Format("{0}/themes/default/template/", ConfigHelper.SitePath)); } th = new TemplateHelper(templatePath); LoadDefault(); LoachsDataManager loachs = new LoachsDataManager(); th.Put("loachs", loachs); switch (pageType) { case "feed": LoadFeed(); break; case "post": LoadPost(); break; case "rsd": LoadRsd(); break; case "wlwmanifest": LoadWlwmanifest(); break; case "metaweblog": LoadMetaweblog(); break; default: //if (IsXmlrpcPost() == true) //{ // LoadMetaweblog(); //} //else //{ LoadPostList(); // } break; } }