Пример #1
0
        /// <summary>
        /// 初始化
        /// </summary>
        void BlogInit(string action)
        {
            if (action == "feed")
            {
                templatePath = HttpContext.Current.Server.MapPath(ConfigHelper.SitePath + "common/config/");
            }
            else
            {
                templatePath = HttpContext.Current.Server.MapPath(string.Format("{0}/themes/default/template/", ConfigHelper.SitePath));
            }
            if (BlogConfig.GetSetting().SiteStatus == 0)
            {
                ResponseError("网站已关闭", "网站已关闭,请与站长联系!");
            }

            pageindex = Framework.Web.PressRequest.GetQueryInt("page", 1);
            slug      = Framework.Web.PressRequest.GetQueryString("slug");

            UpdateViewCount();//更新访问量
            //主题处理
            _themeName = BlogConfig.GetSetting().Theme;
            string previewThemeName = Jqpress.Framework.Web.PressRequest.GetQueryString("theme", true);

            //if (Jqpress.Framework.Web.PressRequest.IsMobile)
            //{
            //    _themeName = BlogConfig.GetSetting().MobileTheme;
            //}
            if (!string.IsNullOrEmpty(previewThemeName))
            {
                _themeName = previewThemeName;
            }
            //非预览时
            if (!System.IO.Directory.Exists(templatePath) && string.IsNullOrEmpty(previewThemeName))
            {
                BlogConfigInfo s = BlogConfig.GetSetting();
                if (Jqpress.Framework.Web.PressRequest.IsMobile)
                {
                    s.MobileTheme = "default";
                }
                else
                {
                    s.Theme = "default";
                }
                _themeName = "default";

                // BlogConfig.UpdateSetting();

                templatePath = Server.MapPath(string.Format("{0}/themes/{1}/template/", ConfigHelper.SitePath, _themeName));
            }
            if (action != "feed")
            {
                templatePath = Server.MapPath(string.Format("{0}/themes/{1}/template/", ConfigHelper.SitePath, _themeName));
            }
            th = new NVelocityHelper(templatePath);
        }
Пример #2
0
        /// <summary>
        /// 单例初始化
        /// </summary>
        public static void LoadSetting()
        {
            if (_setting == null)
            {
                lock (lockHelper)
                {
                    if (_setting == null)
                    {
                        object obj = Jqpress.Framework.Xml.SerializationHelper.Load(typeof(BlogConfigInfo), BlogConfigPath);
                        if (obj == null)
                        {
                            _setting = new BlogConfigInfo();
                        }

                        _setting = (BlogConfigInfo)obj;
                    }
                }
            }
        }
Пример #3
0
 public AdminPage()
 {
     CheckLoginAndPermission();
     setting = Jqpress.Blog.Configuration.BlogConfig.GetSetting();
 }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetPageTitle("主题管理");

            string[] filelist = Directory.GetFileSystemEntries(Server.MapPath("../../themes/default"));
            foreach (string str in filelist)
            {
                //   Response.Write(str+"<br>");
            }
            //   System.IO.Directory.Delete(Server.MapPath("../themes/test"),true);

            string type = PressRequest.GetQueryString("type", true);

            if (Operate == OperateType.Update)
            {
                BlogConfigInfo s = BlogConfig.GetSetting();

                switch (type)
                {
                case "mobile":
                    s.MobileTheme = themename;
                    break;

                case "pc":
                default:
                    s.Theme = themename;
                    break;
                }
                BlogConfig.UpdateSetting();

                Response.Redirect("theme_list.aspx?result=2");
            }
            else if (Operate == OperateType.Insert)
            {
                string srcPath = Server.MapPath("../themes/" + themename);

                if (!string.IsNullOrEmpty(themename) && System.IO.Directory.Exists(srcPath))
                {
                    string aimPath = string.Empty;
                    int    count   = 1;
                    while (true)
                    {
                        count++;
                        aimPath = Server.MapPath("../themes/" + themename + "-" + count);
                        if (!System.IO.Directory.Exists(aimPath))
                        {
                            break;
                        }
                    }
                    CopyDir(srcPath, aimPath);
                    Response.Redirect("theme_list.aspx?result=1");
                }
            }
            else if (Operate == OperateType.Delete)
            {
                if (themename == "default")
                {
                    Response.Redirect("theme_list.aspx?result=5");
                }
                else
                {
                    string path = Server.MapPath("../themes/" + themename);
                    if (System.IO.Directory.Exists(path))
                    {
                        System.IO.Directory.Delete(path, true);
                        Response.Redirect("theme_list.aspx?result=3");
                    }
                }
            }

            ShowResult();
        }
Пример #5
0
        /// <summary>
        /// 绑定
        /// </summary>
        protected void BindSetting()
        {
            LoadDefaultData();

            BlogConfigInfo s = BlogConfig.GetSetting();

            if (s != null)
            {
                txtSiteName.Text        = HttpHelper.HtmlDecode(s.SiteName);
                txtSiteDescription.Text = HttpHelper.HtmlDecode(s.SiteDescription);
                txtMetaKeywords.Text    = HttpHelper.HtmlDecode(s.MetaKeywords);
                txtMetaDescription.Text = HttpHelper.HtmlDecode(s.MetaDescription);

                chkSiteStatus.Checked = s.SiteStatus == 1 ? true : false;


                chkEnableVerifyCode.Checked = s.EnableVerifyCode == 1 ? true : false;


                txtSidebarPostCount.Text    = s.SidebarPostCount.ToString();
                txtSidebarCommentCount.Text = s.SidebarCommentCount.ToString();
                txtSidebarTagCount.Text     = s.SidebarTagCount.ToString();

                txtPageSizeCommentCount.Text = s.PageSizeCommentCount.ToString();
                txtPageSizePostCount.Text    = s.PageSizePostCount.ToString();
                //    txtPageSizeTagCount.Text = s.PageSizeTagCount.ToString();

                txtPostRelatedCount.Text = s.PostRelatedCount.ToString();

                txtFooterHtml.Text = s.FooterHtml;

                // ddlRewriteExtension.SelectedValue = s.RewriteExtension;

                //chkCommentApproved.Checked = s.CommentApproved == 1 ? true : false;

                //水印
                ddlWatermarkType.SelectedValue         = s.WatermarkType.ToString();
                txtWatermarkText.Text                  = s.WatermarkText;
                ddlWatermarkFontName.SelectedValue     = s.WatermarkFontName;
                ddlWatermarkFontSize.SelectedValue     = s.WatermarkFontSize.ToString();
                txtWatermarkImage.Text                 = s.WatermarkImage;
                ddlWatermarkTransparency.SelectedValue = s.WatermarkTransparency.ToString();
                ddlWatermarkPosition.SelectedValue     = s.WatermarkPosition.ToString();
                ddlWatermarkQuality.SelectedValue      = s.WatermarkQuality.ToString();

                //评论
                chkCommentStatus.Checked         = s.CommentStatus == 1 ? true : false;
                ddlCommentOrder.SelectedValue    = s.CommentOrder.ToString();
                ddlCommentApproved.SelectedValue = s.CommentApproved.ToString();
                txtCommentSpamwords.Text         = s.CommentSpamwords;

                //rss
                chkRssStatus.Checked         = s.RssStatus == 1 ? true : false;
                txtRssRowCount.Text          = s.RssRowCount.ToString();
                ddlRssShowType.SelectedValue = s.RssShowType.ToString();

                //rewrite
                ddlUrlType.Items.Clear();
                ddlUrlType.Items.Add(new ListItem(Jqpress.Framework.Configuration.ConfigHelper.SiteUrl + "post/" + DateTime.Now.ToString(@"yyyy\/MM\/dd") + "/slug" + setting.RewriteExtension, "1"));
                ddlUrlType.Items.Add(new ListItem(Jqpress.Framework.Configuration.ConfigHelper.SiteUrl + "post/slug" + setting.RewriteExtension, "2"));
                ddlUrlType.SelectedValue          = s.UrlFormatType.ToString();
                ddlRewriteExtension.SelectedValue = s.RewriteExtension;

                //total
                ddlTotalType.SelectedValue = s.SiteTotalType.ToString();

                ddlPostShowType.SelectedValue = s.PostShowType.ToString();

                //邮件
                txtSmtpEmail.Text        = s.SmtpEmail;
                txtSmtpServer.Text       = s.SmtpServer;
                txtSmtpServerPort.Text   = s.SmtpServerPost.ToString();
                txtSmtpUserName.Text     = s.SmtpUserName;
                txtSmtpPassword.Text     = s.SmtpPassword;
                chkSmtpEnableSsl.Checked = s.SmtpEnableSsl == 1 ? true : false;

                //发送邮件设置
                chkSendMailAuthorByPost.Checked    = s.SendMailAuthorByPost == 1 ? true : false;
                chkSendMailAuthorByComment.Checked = s.SendMailAuthorByComment == 1 ? true : false;
                chkSendMailNotifyByComment.Checked = s.SendMailNotifyByComment == 1 ? true : false;
            }
        }
Пример #6
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            BlogConfigInfo s = BlogConfig.GetSetting();

            if (s != null)
            {
                s.SiteName        = HttpHelper.HtmlEncode(txtSiteName.Text);
                s.SiteDescription = HttpHelper.HtmlEncode(txtSiteDescription.Text);
                s.MetaKeywords    = HttpHelper.HtmlEncode(txtMetaKeywords.Text);
                s.MetaDescription = HttpHelper.HtmlEncode(txtMetaDescription.Text);

                //   s.RewriteExtension = ddlRewriteExtension.SelectedValue;
                s.SiteStatus = chkSiteStatus.Checked ? 1 : 0;

                //  s.CommentApproved = chkCommentApproved.Checked ? 1 : 0;
                //    //c.GuestBookVerifyStatus = chkGuestBookVerifyStatus.Checked ? 1 : 0;
                s.EnableVerifyCode = chkEnableVerifyCode.Checked ? 1 : 0;



                //  s.PageSizeTagCount = TypeConverter.StrToInt(txtPageSizeTagCount.Text, 10);
                s.PageSizePostCount    = TypeConverter.StrToInt(txtPageSizePostCount.Text, 10);
                s.PageSizeCommentCount = TypeConverter.StrToInt(txtPageSizeCommentCount.Text, 50);

                s.SidebarPostCount    = TypeConverter.StrToInt(txtSidebarPostCount.Text, 10);
                s.SidebarTagCount     = TypeConverter.StrToInt(txtSidebarTagCount.Text, 10);
                s.SidebarCommentCount = TypeConverter.StrToInt(txtSidebarCommentCount.Text, 10);

                //    //c.TagArticleNum = TypeConverter.StrToInt(txtTagArticleNum.Text, 10);

                s.FooterHtml = txtFooterHtml.Text;

                //    //c.ArticleShowType = TypeConverter.StrToInt(ddlArticleShowType.SelectedValue, 0);


                //水印

                s.WatermarkType         = TypeConverter.StrToInt(ddlWatermarkType.SelectedValue, 1);
                s.WatermarkText         = txtWatermarkText.Text;
                s.WatermarkFontName     = ddlWatermarkFontName.SelectedValue;
                s.WatermarkFontSize     = TypeConverter.StrToInt(ddlWatermarkFontSize.SelectedValue, 14);
                s.WatermarkImage        = txtWatermarkImage.Text;
                s.WatermarkTransparency = TypeConverter.StrToInt(ddlWatermarkTransparency.SelectedValue, 10);
                s.WatermarkPosition     = TypeConverter.StrToInt(ddlWatermarkPosition.SelectedValue, 1);
                s.WatermarkQuality      = TypeConverter.StrToInt(ddlWatermarkQuality.SelectedValue, 100);


                //评论
                s.CommentStatus    = chkCommentStatus.Checked ? 1 : 0;
                s.CommentOrder     = TypeConverter.StrToInt(ddlCommentOrder.SelectedValue, 1);
                s.CommentApproved  = TypeConverter.StrToInt(ddlCommentApproved.SelectedValue, 1);
                s.CommentSpamwords = txtCommentSpamwords.Text;

                //rss
                s.RssStatus   = chkRssStatus.Checked ? 1 : 0;
                s.RssRowCount = TypeConverter.StrToInt(txtRssRowCount.Text, 20);
                s.RssShowType = TypeConverter.StrToInt(ddlRssShowType.SelectedValue, 2);

                //rewrite
                s.RewriteExtension = ddlRewriteExtension.SelectedValue;
                s.UrlFormatType    = TypeConverter.StrToInt(ddlUrlType.SelectedValue, 1);

                //total
                s.SiteTotalType = TypeConverter.StrToInt(ddlTotalType.SelectedValue, 1);

                s.PostShowType = TypeConverter.StrToInt(ddlPostShowType.SelectedValue, 2);


                //邮件
                s.SmtpEmail      = txtSmtpEmail.Text.Trim();
                s.SmtpServer     = txtSmtpServer.Text.Trim();
                s.SmtpServerPost = TypeConverter.StrToInt(txtSmtpServerPort.Text, 25);
                s.SmtpUserName   = txtSmtpUserName.Text.Trim();
                s.SmtpPassword   = txtSmtpPassword.Text.Trim();
                s.SmtpEnableSsl  = chkSmtpEnableSsl.Checked == true ? 1 : 0;

                //发送邮件设置
                s.SendMailAuthorByPost    = chkSendMailAuthorByPost.Checked == true ? 1 : 0;
                s.SendMailAuthorByComment = chkSendMailAuthorByComment.Checked == true ? 1 : 0;
                s.SendMailNotifyByComment = chkSendMailNotifyByComment.Checked == true ? 1 : 0;

                if (BlogConfig.UpdateSetting())
                {
                    Response.Redirect("blog_set.aspx?result=2");
                }
            }
        }