Ejemplo n.º 1
0
        /// <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();
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        /// <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();
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 加载文章列表
        /// </summary>
        protected void LoadPostList()
        {
            int    categoryId = -1;
            int    tagId      = -1;
            int    userId     = -1;
            string keyword    = string.Empty;
            string data       = string.Empty;
            string begindate  = string.Empty;
            string enddate    = string.Empty;

            int pageindex = RequestHelper.QueryInt("page", 1);

            string messageinfo = string.Empty;

            string url = MakeUrl(string.Empty, string.Empty, string.Empty);

            if (pageType == "category")
            {
                string       slug = RequestHelper.QueryString("slug");
                CategoryInfo cate = CategoryManager.GetCategory(slug);
                if (cate != null)
                {
                    categoryId = cate.CategoryId;
                    th.Put(TagFields.META_KEYWORDS, cate.Name);
                    th.Put(TagFields.META_DESCRIPTION, cate.Description);
                    th.Put(TagFields.PAGE_TITLE, cate.Name);
                    messageinfo = string.Format("<h2 class=\"post-message\">分类:{0}</h2>", cate.Name);

                    url = MakeUrl("category", "slug", Server.UrlEncode(slug));
                }
            }
            else if (pageType == "tag")
            {
                string  slug = RequestHelper.QueryString("slug");
                TagInfo tag  = TagManager.GetTagBySlug(slug);
                if (tag != null)
                {
                    tagId = tag.TagId;
                    th.Put(TagFields.META_KEYWORDS, tag.Name);
                    th.Put(TagFields.META_DESCRIPTION, tag.Description);
                    th.Put(TagFields.PAGE_TITLE, tag.Name);
                    messageinfo = string.Format("<h2 class=\"post-message\">标签:{0}</h2>", tag.Name);

                    url = MakeUrl("tag", "slug", Server.UrlEncode(slug));
                }
            }
            else if (pageType == "author")
            {
                string   userName = RequestHelper.QueryString("username");
                UserInfo user     = UserManager.GetUser(userName);
                if (user != null)
                {
                    userId = user.UserId;
                    th.Put(TagFields.META_KEYWORDS, user.Name);
                    th.Put(TagFields.META_DESCRIPTION, user.Description);
                    th.Put(TagFields.PAGE_TITLE, user.Name);
                    messageinfo = string.Format("<h2 class=\"post-message\">作者:{0}</h2>", user.Name);

                    url = MakeUrl("author", "username", Server.UrlEncode(userName));
                }
            }
            else if (pageType == "search")
            {
                keyword = StringHelper.CutString(StringHelper.SqlEncode(RequestHelper.QueryString("keyword")), 15);
                th.Put(TagFields.META_KEYWORDS, keyword);
                th.Put(TagFields.META_DESCRIPTION, keyword);
                th.Put(TagFields.PAGE_TITLE, keyword);
                th.Put(TagFields.SEARCH_KEYWORD, keyword);
                messageinfo = string.Format("<h2 class=\"post-message\">搜索:{0}</h2>", keyword);

                url = MakeUrl("search", "keyword", Server.UrlEncode(keyword));
            }
            else if (pageType == "archive")     //先按月归档
            {
                string datestr = RequestHelper.QueryString("date");

                string   year  = datestr.Substring(0, 4);
                string   month = datestr.Substring(4, 2);
                DateTime date  = Convert.ToDateTime(year + "-" + month);
                begindate = date.ToString("yyy-MM-dd");
                enddate   = date.AddMonths(1).ToString("yyy-MM-dd");
                th.Put(TagFields.META_KEYWORDS, "归档");
                th.Put(TagFields.META_DESCRIPTION, SettingManager.GetSetting().SiteName + date.ToString("yyyy-MM") + "的归档");
                th.Put(TagFields.PAGE_TITLE, "归档:" + date.ToString("yyyy-MM"));
                messageinfo = string.Format("<h2 class=\"post-message\">归档:{0}</h2>", date.ToString("yyyy-MM"));

                url = MakeUrl("archive", "date", datestr);
            }

            else    //首页
            {
                if (pageindex == 1)
                {
                    th.Put(TagFields.IS_DEFAULT, "1");
                }
            }

            th.Put(TagFields.POST_MESSAGE, messageinfo);
            //     th.Put(TagFields.PAGER_INDEX, pageindex);

            int recordCount = 0;

            th.Put(TagFields.POSTS, PostManager.GetPostList(SettingManager.GetSetting().PageSizePostCount, pageindex, out recordCount, categoryId, tagId, userId, -1, 1, -1, 0, begindate, enddate, keyword));
            th.Put(TagFields.PAGER, Pager.CreateHtml(SettingManager.GetSetting().PageSizePostCount, recordCount, url));

            Display("default.html");
        }