コード例 #1
0
        /// <summary>
        /// 归档
        /// </summary>
        public void Archive()
        {
            var      model = new PostListModel();
            string   year  = Jqpress.Framework.Web.PressRequest.GetQueryString("year");
            string   month = Jqpress.Framework.Web.PressRequest.GetQueryString("month");
            DateTime date  = Convert.ToDateTime(year + "-" + month);

            begindate = date.ToString();
            enddate   = date.AddMonths(1).ToString();

            model.MetaKeywords    = "归档";
            model.MetaDescription = BlogConfig.GetSetting().SiteName + date.ToString("yyyy-MM") + "的归档";
            model.PageTitle       = "归档:" + date.ToString("yyyy-MM");
            model.PostMessage     = string.Format("<h2 class=\"post-message\">归档:{0}</h2>", date.ToString("yyyy-MM"));
            model.Url             = ConfigHelper.SiteUrl + "archive/" + date.ToString("yyyyMM") + "/page/{0}" + BlogConfig.GetSetting().RewriteExtension;
            int recordCount = 0;

            model.PostList = PostService.GetPostList(BlogConfig.GetSetting().PageSizePostCount, pageindex,
                                                     out recordCount, categoryId, tagId, userId, -1, 1, -1, 0,
                                                     begindate, enddate, keyword);
            model.Pager = Pager.CreateHtml(BlogConfig.GetSetting().PageSizePostCount, recordCount, model.Url);

            model.IsDefault = 0;
            model.ThemeName = _themeName;
            th.Put("Model", model);

            Display(th, _listTemplate);
        }
コード例 #2
0
        /// <summary>
        /// 作者
        /// </summary>
        public void Author()
        {
            var model = new PostListModel();

            string   userName = Jqpress.Framework.Web.PressRequest.GetQueryString("username");
            UserInfo user     = UserService.GetUser(userName);

            if (user != null)
            {
                userId                = user.UserId;
                model.MetaKeywords    = user.NickName;
                model.MetaDescription = user.Description;
                model.PageTitle       = user.NickName;

                model.PostMessage = string.Format("<h2 class=\"post-message\">作者:{0}</h2>", user.NickName);
                model.Url         = ConfigHelper.SiteUrl + "author/" + HttpContext.Current.Server.UrlEncode(userName) + "/page/{0}" + BlogConfig.GetSetting().RewriteExtension;
                int recordCount = 0;
                model.PostList = PostService.GetPostList(BlogConfig.GetSetting().PageSizePostCount, pageindex,
                                                         out recordCount, categoryId, tagId, userId, -1, 1, -1, 0,
                                                         begindate, enddate, keyword);
                model.Pager = Pager.CreateHtml(BlogConfig.GetSetting().PageSizePostCount, recordCount, model.Url);
            }

            model.IsDefault = 0;
            model.ThemeName = _themeName;
            th.Put("Model", model);

            Display(th, _listTemplate);
        }
コード例 #3
0
        /// <summary>
        /// 标签
        /// </summary>
        public void Tag()
        {
            var model = new PostListModel();

            TagInfo tag = TagService.GetTagBySlug(slug);

            if (tag != null)
            {
                tagId = tag.TagId;
                model.MetaKeywords    = tag.CateName;
                model.MetaDescription = tag.Description;
                model.PageTitle       = tag.CateName;
                model.PostMessage     = string.Format("<h2 class=\"post-message\">标签:{0}</h2>", tag.CateName);
                model.Url             = ConfigHelper.SiteUrl + "tag/" + HttpContext.Current.Server.UrlEncode(slug) + "/page/{0}" + BlogConfig.GetSetting().RewriteExtension;
                int recordCount = 0;
                model.PostList = PostService.GetPostList(BlogConfig.GetSetting().PageSizePostCount, pageindex,
                                                         out recordCount, categoryId, tagId, userId, -1, 1, -1, 0,
                                                         begindate, enddate, keyword);
                model.Pager = Pager.CreateHtml(BlogConfig.GetSetting().PageSizePostCount, recordCount, model.Url);
            }
            model.IsDefault = 0;
            model.ThemeName = _themeName;
            th.Put("Model", model);

            Display(th, _listTemplate);
        }
コード例 #4
0
        /// <summary>
        /// Rsd
        /// from BlogEngine Source
        /// </summary>
        public void Rsd()
        {
            HttpContext.Current.Response.ContentType = "text/xml";
            using (XmlTextWriter rsd = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8))
            {
                rsd.Formatting = Formatting.Indented;
                rsd.WriteStartDocument();

                // Rsd tag
                rsd.WriteStartElement("rsd");
                rsd.WriteAttributeString("version", "1.0");

                // Service
                rsd.WriteStartElement("service");
                rsd.WriteElementString("engineName", "jqpress" + BlogConfig.GetSetting().Version);
                rsd.WriteElementString("engineLink", "http://www.jqpress.com");
                rsd.WriteElementString("homePageLink", ConfigHelper.SiteUrl);

                // APIs
                rsd.WriteStartElement("apis");

                // MetaWeblog
                rsd.WriteStartElement("api");
                rsd.WriteAttributeString("name", "MetaWeblog");
                rsd.WriteAttributeString("preferred", "true");
                rsd.WriteAttributeString("apiLink", ConfigHelper.SiteUrl + "xmlrpc/metaweblog.aspx");
                rsd.WriteAttributeString("blogID", "1");
                rsd.WriteEndElement();

                // WordPress
                rsd.WriteStartElement("api");
                rsd.WriteAttributeString("name", "WordPress");
                rsd.WriteAttributeString("preferred", "false");
                rsd.WriteAttributeString("apiLink", ConfigHelper.SiteUrl + "xmlrpc/metaweblog.aspx");
                rsd.WriteAttributeString("blogID", "1");
                rsd.WriteEndElement();

                // BlogML
                //rsd.WriteStartElement("api");
                //rsd.WriteAttributeString("name", "BlogML");
                //rsd.WriteAttributeString("preferred", "false");
                //rsd.WriteAttributeString("apiLink", Utils.AbsoluteWebRoot + "api/BlogImporter.asmx");
                //rsd.WriteAttributeString("blogID", Utils.AbsoluteWebRoot.ToString());
                //rsd.WriteEndElement();

                // End APIs
                rsd.WriteEndElement();

                // End Service
                rsd.WriteEndElement();

                // End Rsd
                rsd.WriteEndElement();

                rsd.WriteEndDocument();
            }
        }
コード例 #5
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);
        }
コード例 #6
0
        /// <summary>
        /// 加载feed
        /// </summary>
        public void Feed()
        {
            int    categoryId = Jqpress.Framework.Web.PressRequest.GetQueryInt("categoryid", -1);
            int    postId     = Jqpress.Framework.Web.PressRequest.GetQueryInt("postid", -1);
            string action     = Jqpress.Framework.Web.PressRequest.GetQueryString("action", true);

            //   HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ContentType = "text/xml";
            if (BlogConfig.GetSetting().RssStatus == 1)
            {
                switch (action)
                {
                case "comment":
                    List <CommentInfo> commentList = CommentService.GetCommentList(BlogConfig.GetSetting().RssRowCount, 1, -1, postId, 0, 1, -1, null);
                    PostInfo           commentPost = PostService.GetPost(postId);
                    HttpContext.Current.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");
                    HttpContext.Current.Response.Write("    <channel>\r\n");
                    HttpContext.Current.Response.Write("        <title><![CDATA[" + (commentPost == null ? BlogConfig.GetSetting().SiteName : commentPost.Title) + "的评论]]></title>\r\n");
                    HttpContext.Current.Response.Write("        <link>" + (commentPost == null ? ConfigHelper.SiteUrl : commentPost.Url) + "</link>\r\n");
                    HttpContext.Current.Response.Write("        <description><![CDATA[" + BlogConfig.GetSetting().SiteDescription + "]]></description>\r\n");
                    HttpContext.Current.Response.Write("        <pubDate>" + DateTime.Now.ToString("r") + "</pubDate>\r\n");
                    HttpContext.Current.Response.Write("        <generator>jqpress</generator>\r\n");
                    HttpContext.Current.Response.Write("        <language>zh-cn</language>\r\n");
                    foreach (CommentInfo comment in commentList)
                    {
                        HttpContext.Current.Response.Write("        <item>\r\n");
                        HttpContext.Current.Response.Write("            <title><![CDATA[" + comment.Author + "对" + comment.Post.Title + "的评论]]></title>\r\n");
                        HttpContext.Current.Response.Write("            <link>" + comment.Url + "</link>\r\n");
                        HttpContext.Current.Response.Write("            <guid>" + comment.Url + "</guid>\r\n");
                        HttpContext.Current.Response.Write("            <author><![CDATA[" + comment.Author + "]]></author>\r\n");

                        HttpContext.Current.Response.Write(string.Format("          <description><![CDATA[{0}]]></description>\r\n", comment.Contents));
                        HttpContext.Current.Response.Write("            <pubDate>" + comment.CreateTime.ToString("r") + "</pubDate>\r\n");
                        HttpContext.Current.Response.Write("        </item>\r\n");
                    }
                    HttpContext.Current.Response.Write("    </channel>\r\n");
                    HttpContext.Current.Response.Write("</rss>\r\n");
                    break;

                default:
                    var model = new PostListModel();
                    model.PostList = PostService.GetPostList(BlogConfig.GetSetting().RssRowCount, categoryId, -1, -1, 1, -1, 0);
                    th.Put("Model", model);
                    Display(th, "feed.config");
                    break;
                }
            }
            else
            {
                HttpContext.Current.Response.Write("<rss>error</rss>\r\n");
            }
            //  HttpContext.Current.Response.End();
        }
コード例 #7
0
        public static void ResponseError(string title, string msg, int statusCode)
        {
            string str = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><header><title>{0} - {1}</title><style>a {{ color:gray;}}</style></header><body><div  style=\"border:1px solid #94a2a3; background-color:#F1F8FE; width:500px;   padding:8px 25px; margin:100px auto 0 auto;\" ><h5>提示:</h5><h2>{2}</h2><h4><a href=\"{3}\">返回首页</a></h4></div><div  style=\"  text-align:center; padding:5px 0;color:gray;font-size:12px;\" >Powered by <a href=\"http://www.jqpress.com\" target=\"_blank\">jqpress</a> </div></body></html>";

            str = string.Format(str, title, BlogConfig.GetSetting().SiteName, msg, ConfigHelper.SiteUrl);

            HttpContext.Current.Response.Clear();
            //  HttpContext.Current.Response.Status = "200 Internal Server Error";
            HttpContext.Current.Response.StatusCode = statusCode;
            HttpContext.Current.Response.Write(str);
            HttpContext.Current.Response.End();
        }
コード例 #8
0
        /// <summary>
        /// blogger.getUsersBlogs
        /// </summary>
        /// <param name="appKey">Key from application.  Outdated methodology that has no use here.</param>
        /// <param name="userName">login username</param>
        /// <param name="password">login password</param>
        /// <param name="rootUrl">The root URL.</param>
        /// <returns>array of blog structs</returns>
        internal List <MWABlogInfo> GetUserBlogs(string appKey, string userName, string password, string rootUrl)
        {
            ValidateRequest(userName, password);

            List <MWABlogInfo> blogs = new List <MWABlogInfo>();

            MWABlogInfo temp = new MWABlogInfo();

            temp.url      = rootUrl;
            temp.blogID   = "1000";
            temp.blogName = BlogConfig.GetSetting().SiteName;
            blogs.Add(temp);

            return(blogs);
        }
コード例 #9
0
        /// <summary>
        /// 首页
        /// </summary>
        public void Home()
        {
            var model = new PostListModel();

            model.IsDefault   = 1;
            model.ThemeName   = _themeName;
            model.PostMessage = string.Empty;
            model.Url         = ConfigHelper.SiteUrl + "page/{0}" + BlogConfig.GetSetting().RewriteExtension;;
            int recordCount = 0;

            model.PostList = PostService.GetPostList(BlogConfig.GetSetting().PageSizePostCount, pageindex,
                                                     out recordCount, categoryId, tagId, userId, -1, 1, -1, 0,
                                                     begindate, enddate, keyword);
            model.Pager = Pager.CreateHtml(BlogConfig.GetSetting().PageSizePostCount, recordCount, model.Url);
            th.Put("Model", model);

            Display(th, _listTemplate);
        }
コード例 #10
0
        /// <summary>
        /// 发邮件
        /// </summary>
        /// <param name="post"></param>
        private void SendEmail(PostInfo post)
        {
            if (BlogConfig.GetSetting().SendMailAuthorByPost == 1)
            {
                List <UserInfo> list      = UserService.GetUserList();
                List <string>   emailList = new List <string>();

                foreach (UserInfo user in list)
                {
                    if (!Jqpress.Framework.Utils.Validate.IsEmail(user.Email))
                    {
                        continue;
                    }
                    //自己不用发
                    if (CurrentUser.Email == user.Email)
                    {
                        continue;
                    }
                    //不重复发送
                    if (emailList.Contains(user.Email))
                    {
                        continue;
                    }
                    emailList.Add(user.Email);

                    string subject = string.Empty;
                    string body    = string.Empty;

                    subject = string.Format("[新文章通知]{0}", post.Title);
                    body   += string.Format("{0}有新文章了:<br/>", BlogConfig.GetSetting().SiteName);
                    body   += "<hr/>";
                    body   += "<br />标题: " + post.Link;
                    body   += post.Detail;
                    body   += "<hr/>";
                    body   += "<br />作者: " + CurrentUser.Link;
                    body   += "<br />时间: " + post.PostTime;
                    body   += "<br />文章连接: " + post.Link;
                    body   += "<br />注:系统自动通知邮件,不要回复。";

                    EmailHelper.SendAsync(user.Email, subject, body);
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// 更新访问次数
        /// </summary>
        public static void UpdateViewCount()
        {
            string cookie = "isview";
            int    isview = Jqpress.Framework.Utils.TypeConverter.StrToInt(Jqpress.Framework.Web.PressRequest.GetCookie(cookie), 0);

            //未访问或按刷新统计
            if (isview == 0 || BlogConfig.GetSetting().SiteTotalType == 1)
            {
                if (StatisticsService.GetStatistics() != null)
                {
                    StatisticsInfo stat = StatisticsService.GetStatistics();
                    stat.VisitCount += 1;
                    StatisticsService.UpdateStatistics();
                }
            }
            //未访问
            if (isview == 0 && BlogConfig.GetSetting().SiteTotalType == 2)
            {
                Jqpress.Framework.Web.PressRequest.WriteCookie(cookie, "1", 1440);
            }
        }
コード例 #12
0
ファイル: EmailHelper.cs プロジェクト: wanglong/jqpress-aspx
        /// <summary>
        ///  发邮件
        /// </summary>
        /// <param name="recipients"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        public static void Send(string recipients, string subject, string body)
        {
            try
            {
                MailAddress from = new MailAddress(BlogConfig.GetSetting().SmtpEmail, BlogConfig.GetSetting().SiteName);
                MailMessage m    = new MailMessage();
                m.From = from;
                //   m.ReplyTo = new MailAddress(recipients);

                m.To.Add(recipients);   //收件人处会显示所有人的邮箱

                //if (recipients.IndexOf(',') == -1)
                //{
                //    m.To.Add(recipients);   //收件人处会显示所有人的邮箱
                //}
                //else
                //{
                //    m.Bcc.Add(recipients);  //不会显示收件人

                //    //  m.CC.Add(recipients);  //抄送人处会显示所有人邮箱
                //}

                m.Subject      = subject;
                m.Body         = body;
                m.IsBodyHtml   = true;
                m.Priority     = MailPriority.Normal;
                m.BodyEncoding = Encoding.GetEncoding("utf-8");

                SmtpClient smtp = new SmtpClient();
                smtp.Host        = BlogConfig.GetSetting().SmtpServer;
                smtp.Credentials = new System.Net.NetworkCredential(BlogConfig.GetSetting().SmtpUserName, BlogConfig.GetSetting().SmtpPassword);
                smtp.EnableSsl   = Convert.ToBoolean(BlogConfig.GetSetting().SmtpEnableSsl);
                smtp.Port        = BlogConfig.GetSetting().SmtpServerPost;
                smtp.Send(m);
            }
            catch
            { }
        }
コード例 #13
0
        /// <summary>
        /// 搜索
        /// </summary>
        public void Search()
        {
            var model = new PostListModel();

            keyword               = StringHelper.CutString(StringHelper.SqlEncode(Jqpress.Framework.Web.PressRequest.GetQueryString("keyword")), 0, 50);
            model.MetaKeywords    = keyword;
            model.MetaDescription = keyword;
            model.PageTitle       = keyword;
            model.PostMessage     = string.Format("<h2 class=\"post-message\">搜索:{0}</h2>", keyword);
            model.Url             = ConfigHelper.SiteUrl + "search" + BlogConfig.GetSetting().RewriteExtension + "?keyword=" + HttpContext.Current.Server.UrlEncode(keyword) + "&page={0}";
            int recordCount = 0;

            model.PostList = PostService.GetPostList(BlogConfig.GetSetting().PageSizePostCount, pageindex,
                                                     out recordCount, categoryId, tagId, userId, -1, 1, -1, 0,
                                                     begindate, enddate, keyword);
            model.Pager = Pager.CreateHtml(BlogConfig.GetSetting().PageSizePostCount, recordCount, model.Url);

            model.IsDefault = 0;
            model.ThemeName = _themeName;
            th.Put("Model", model);

            Display(th, _listTemplate);
        }
コード例 #14
0
ファイル: comment.ashx.cs プロジェクト: yuyu2you/jqpress.cms
        /// <summary>
        /// 保存评论
        /// </summary>
        public void SaveComment()
        {
            int contentMaxLength = 1000;    //内容最长长度

            int    postid      = Jqpress.Framework.Web.PressRequest.GetFormInt("postid", 0);
            string author      = StringHelper.CutString(Jqpress.Framework.Web.PressRequest.GetFormString("commentauthor"), 0, 20);
            string email       = StringHelper.CutString(Jqpress.Framework.Web.PressRequest.GetFormString("commentemail"), 0, 50);
            string siteurl     = StringHelper.CutString(Jqpress.Framework.Web.PressRequest.GetFormString("commentsiteurl"), 0, 100);
            int    parentid    = Jqpress.Framework.Web.PressRequest.GetFormInt("ReplyToCommentId", 0);
            string content     = Jqpress.Framework.Web.PressRequest.GetFormString("commentcontent");
            int    remeber     = Jqpress.Framework.Web.PressRequest.GetFormInt("commentremember", 0);
            int    emailnotify = Jqpress.Framework.Web.PressRequest.GetFormInt("commentemail", 0);
            string verifycode  = Jqpress.Framework.Web.PressRequest.GetFormString("commentverifycode");

            CommentInfo c = new CommentInfo();

            c.ParentId    = parentid;
            c.Contents    = StringHelper.TextToHtml(StringHelper.CutString(content, 0, contentMaxLength));
            c.CreateTime  = DateTime.Now;
            c.Email       = Jqpress.Framework.Web.HttpHelper.HtmlEncode(email);
            c.EmailNotify = emailnotify;
            c.IpAddress   = Jqpress.Framework.Web.PressRequest.GetIP();
            c.ParentId    = 0;
            c.PostId      = postid;
            c.UserId      = 0;
            c.Author      = author;
            c.AuthorUrl   = siteurl;

            PostInfo post = PostService.GetPost(postid);

            switch (BlogConfig.GetSetting().CommentApproved)
            {
            case 1:
                c.Approved = (int)ApprovedStatus.Success;
                break;

            case 2:
                string[] blackwords   = BlogConfig.GetSetting().CommentSpamwords.Split(',');
                bool     hasBlackword = false;
                foreach (string word in blackwords)
                {
                    if (c.Contents.IndexOf(word) != -1)
                    {
                        hasBlackword = true;
                        break;
                    }
                }
                c.Approved = hasBlackword ? (int)ApprovedStatus.Wait : (int)ApprovedStatus.Success;
                break;

            case 3:
            default:
                c.Approved = (int)ApprovedStatus.Wait;
                break;
            }


            int    newID    = CommentService.InsertComment(c);
            string response = "<li id=\"comment-comment-" + newID + "\" class=\"comment even thread-even depth-1\">";

            response += "<div class=\"comment-body\" id=\"div-comment-" + newID + "\">";
            response += "<div class=\"comment-author vcard\">";
            response += "<img width=\"26\" height=\"26\" class=\"avatar avatar-26 photo avatar-default\" ";
            response += "src=\"http://www.gravatar.com/avatar/" + c.GravatarCode + "?size=26\" \">";
            response += "<cite class=\"fn\">" + c.Author + "</cite> ";
            response += "<span class=\"says\">说:</span></div>";
            response += " <p> ";
            response += c.Contents;
            response += "</p>";
            response += "</li>";
            HttpContext.Current.Response.Write(response);
            SendMail(postid, email, post, content, author, siteurl, c, parentid);
            HttpContext.Current.Response.End();


            /*
             * <li id="comment-comment-${item.commentid}" class="comment even thread-even depth-1">
             * <div class="comment-author vcard">
             * <img width="26" height="26" class="avatar avatar-26 photo avatar-default"
             * src="http://www.gravatar.com/avatar/${item.gravatarcode}?size=26" alt="${item.nickname}">
             *
             * <cite class="fn">${item.authorlink}</cite> <span class="says">说:</span></div>
             */
        }
コード例 #15
0
ファイル: comment.ashx.cs プロジェクト: yuyu2you/jqpress.cms
        public void SendMail(int postid, string email, PostInfo post, string content, string author, string siteurl, CommentInfo c, int parentid)
        {
            #region 发邮件
            try
            {
                if (BlogConfig.GetSetting().SendMailNotifyByComment == 1) //给订阅者发邮件
                {
                    //先不考虑审核的问题
                    List <CommentInfo> list = CommentService.GetCommentList(int.MaxValue, 1, -1, postid, 0, -1, 1, string.Empty);

                    List <string> emailList = new List <string>();

                    foreach (CommentInfo cmt in list)
                    {
                        if (!Jqpress.Framework.Utils.Validate.IsValidEmail(cmt.Email))
                        {
                            continue;
                        }
                        //自己不用发
                        if (email == cmt.Email)
                        {
                            continue;
                        }
                        //不重复发送
                        if (emailList.Contains(cmt.Email))
                        {
                            continue;
                        }
                        emailList.Add(cmt.Email);

                        string subject = string.Empty;
                        string body    = string.Empty;

                        subject = string.Format("[评论订阅通知]{0}", post.Title);
                        body   += string.Format("您订阅的{0}有新评论了:<br/>", post.Title);
                        body   += "<hr/>";
                        body   += content;
                        body   += "<hr/>";
                        body   += "<br />评论作者: " + author;

                        if (!string.IsNullOrEmpty(siteurl))
                        {
                            body += string.Format(" (<a href=\"{0}\">{0}</a>)", siteurl);
                        }

                        body += "<br />评论时间: " + DateTime.Now;
                        body += string.Format("<br />原文连接: <a href=\"{0}\" title=\"{1}\" >{1}</a>", post.Url, post.Title);

                        body += "<br />注:系统自动通知邮件,不要回复。";

                        EmailHelper.SendAsync(cmt.Email, subject, body);
                    }
                }

                if (BlogConfig.GetSetting().SendMailAuthorByComment == 1 && c.ParentId <= 0)       //给文章作者发邮件 回复时不发邮件
                {
                    string subject = string.Empty;
                    string body    = string.Empty;

                    subject = string.Format("[新评论通知]{0}", post.Title);
                    body   += string.Format("您发表的{0}有新评论了:<br/>", post.Title);
                    body   += "<hr/>";
                    body   += content;
                    body   += "<hr/>";
                    body   += "<br />评论作者: " + author;

                    if (!string.IsNullOrEmpty(siteurl))
                    {
                        body += string.Format(" (<a href=\"{0}\">{0}</a>)", siteurl);
                    }

                    body += "<br />评论时间: " + DateTime.Now;
                    body += string.Format("<br />原文连接: <a href=\"{0}\" title=\"{1}\" >{1}</a>", post.Url, post.Title);

                    body += "<br />注:系统自动通知邮件,不要回复。";

                    UserInfo user = UserService.GetUser(post.UserId);
                    if (user != null && Jqpress.Framework.Utils.Validate.IsValidEmail(user.Email))
                    {
                        EmailHelper.SendAsync(user.Email, subject, body);
                    }
                }
                if (BlogConfig.GetSetting().SendMailNotifyByComment == 1)//回复时发邮件
                {
                    //获取原品论者的邮箱
                    string replyemail = CommentService.GetComment(parentid).Email;
                    string subject    = string.Empty;
                    string body       = string.Empty;

                    subject = string.Format("[评论回复通知]{0}", post.Title);
                    body   += string.Format("您对 {0} 发表的评论有回复了:<br/>", post.Title);
                    body   += "<hr/>";
                    body   += content;
                    body   += "<hr/>";
                    body   += "<br />评论作者: " + author;

                    if (!string.IsNullOrEmpty(siteurl))
                    {
                        body += string.Format(" (<a href=\"{0}\">{0}</a>)", siteurl);
                    }

                    body += "<br />回复时间: " + DateTime.Now;
                    body += string.Format("<br />原文连接: <a href=\"{0}\" title=\"{1}\" >{1}</a>", post.Url, post.Title);

                    body += "<br />注:系统自动通知邮件,不要回复。";

                    if (email != "" && Jqpress.Framework.Utils.Validate.IsValidEmail(replyemail))
                    {
                        EmailHelper.SendAsync(email, subject, body);
                    }
                }
            }catch (Exception e) {
            }
            #endregion
        }
コード例 #16
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();
        }
コード例 #17
0
        /// <summary>
        /// 文章
        /// </summary>
        public void Post()
        {
            var model = new PostModel();

            model.IsPost = 1;
            PostInfo post = null;

            int    postId = -1;
            string name   = Jqpress.Framework.Web.PressRequest.GetQueryString("name");

            if (Jqpress.Framework.Utils.Validate.IsInt(name))
            {
                post = PostService.GetPost(Jqpress.Framework.Utils.TypeConverter.StrToInt(name, 0));
            }
            else
            {
                post = PostService.GetPost(StringHelper.SqlEncode(name));
            }

            if (post == null)
            {
                BasePage.ResponseError("文章未找到", "囧!没有找到此文章!", 404);
            }

            if (post.Status == (int)PostStatus.Draft)
            {
                BasePage.ResponseError("文章未发布", "囧!此文章未发布!");
            }

            string cookie = "isviewpost" + post.PostId;
            int    isview = Jqpress.Framework.Utils.TypeConverter.StrToInt(Jqpress.Framework.Web.PressRequest.GetCookie(cookie), 0);

            //未访问或按刷新统计
            if (isview == 0 || BlogConfig.GetSetting().SiteTotalType == 1)
            {
                PostService.UpdatePostViewCount(post.PostId, 1);
            }
            //未访问
            if (isview == 0 && BlogConfig.GetSetting().SiteTotalType == 2)
            {
                Jqpress.Framework.Web.PressRequest.WriteCookie(cookie, "1", 1440);
            }

            model.Post      = post;
            model.PageTitle = post.Title;

            string metaKeywords = string.Empty;

            foreach (TagInfo tag in post.Tags)
            {
                metaKeywords += tag.CateName + ",";
            }
            if (metaKeywords.Length > 0)
            {
                metaKeywords = metaKeywords.TrimEnd(',');
            }
            model.MetaKeywords = metaKeywords;

            string metaDescription = post.Summary;

            if (string.IsNullOrEmpty(post.Summary))
            {
                metaDescription = post.PostContent;
            }
            model.MetaDescription = StringHelper.CutString(StringHelper.RemoveHtml(metaDescription), 50).Replace("\n", "");

            int recordCount = 0;

            model.Comments = CommentService.GetCommentList(BlogConfig.GetSetting().PageSizeCommentCount, Pager.PageIndex, out recordCount, BlogConfig.GetSetting().CommentOrder, -1, post.PostId, 0, -1, -1, null);
            model.Pager    = Pager.CreateHtml(BlogConfig.GetSetting().PageSizeCommentCount, recordCount, post.PageUrl + "#comments");

            //同时判断评论数是否一致
            if (recordCount != post.CommentCount)
            {
                post.CommentCount = recordCount;
                PostService.UpdatePost(post);
            }
            model.IsDefault        = 0;
            model.ThemeName        = _themeName;
            model.EnableVerifyCode = BlogConfig.GetSetting().EnableVerifyCode;
            th.Put("Model", model);
            if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(string.Format("{0}/themes/{1}/template/{2}", ConfigHelper.SitePath, _themeName, post.Template))))
            {
                Display(th, post.Template);
            }
            else
            {
                Display(th, _postTemplate);
            }
        }
コード例 #18
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;
            }
        }
コード例 #19
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");
                }
            }
        }
コード例 #20
0
        /// <summary>
        /// 上传附件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            HttpPostedFile postedFile = FileUpload1.PostedFile;

            string uploadPath    = ConfigHelper.SitePath + "upfiles/" + DateTime.Now.ToString("yyyyMM") + "/";  //文件保存相对路径
            string saveDirectory = Server.MapPath(uploadPath);                                                  //文件保存绝对文件夹
            //  string waterPath = Server.MapPath("../common/images/watermark.gif");//待改

            string fileName = Path.GetFileName(postedFile.FileName);                                            //文件名

            fileName = fileName.Replace(" ", "");
            fileName = fileName.Replace("%", "");
            fileName = fileName.Replace("&", "");
            fileName = fileName.Replace("#", "");
            fileName = fileName.Replace("'", "");
            fileName = fileName.Replace("+", "");


            string fileExtension = Path.GetExtension(postedFile.FileName);                                      //文件后缀

            string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);                       //没有后缀的文件名



            int type = TypeConverter.StrToInt(rblistType.SelectedValue, 1);

            if (postedFile.ContentLength == 0)
            {
                ShowError("请选择要上传的文件!");

                return;
            }

            string[] fileExts = AllowFileExtension.Split(',');
            bool     allow    = false;

            foreach (string str in fileExts)
            {
                if (("." + str) == fileExtension)
                {
                    allow = true;
                    break;
                }
            }
            if (allow == false)
            {
                ShowError("您上传的文件格式不被允许!");
                return;
            }

            if (!Directory.Exists(saveDirectory))
            {
                Directory.CreateDirectory(saveDirectory);
            }

            int iCounter = 0;

            int result = 1;

            while (true)
            {
                string fileSavePath  = saveDirectory + fileName;
                string fileSavePath2 = saveDirectory + "da563457-1c3c-4b28-bf73-92f87f930896" + fileName;
                if (File.Exists(fileSavePath))
                {
                    if (type == 1)//跳过
                    {
                        result = 1;
                        break;
                    }
                    else if (type == 2)//重命名
                    {
                        iCounter++;
                        fileName = fileNameWithoutExtension + "(" + iCounter + ")" + fileExtension;
                    }
                    else if (type == 3)//覆盖
                    {
                        File.Delete(fileSavePath);
                    }
                }
                else
                {
                    if ((fileExtension == ".gif" || fileExtension == ".jpg" || fileExtension == ".jpeg" || fileExtension == ".bmp" || fileExtension == ".png") && chkWatermark.Checked)
                    {
                        postedFile.SaveAs(fileSavePath2);

                        string newFileName    = Path.GetFileNameWithoutExtension(postedFile.FileName) + "w(" + iCounter + ")" + Path.GetExtension(postedFile.FileName);
                        string newImagePath   = Server.MapPath(uploadPath + newFileName);
                        string waterImagePath = Server.MapPath(ConfigHelper.SitePath + "common/images/watermark/" + BlogConfig.GetSetting().WatermarkImage);

                        if (BlogConfig.GetSetting().WatermarkType == 2 && File.Exists(waterImagePath))
                        {
                            Watermark.CreateWaterImage(fileSavePath2, fileSavePath, BlogConfig.GetSetting().WatermarkPosition, waterImagePath, BlogConfig.GetSetting().WatermarkTransparency, BlogConfig.GetSetting().WatermarkQuality);
                        }
                        else
                        {
                            Watermark.CreateWaterText(fileSavePath2, fileSavePath, BlogConfig.GetSetting().WatermarkPosition, BlogConfig.GetSetting().WatermarkText, BlogConfig.GetSetting().WatermarkQuality, BlogConfig.GetSetting().WatermarkFontName, BlogConfig.GetSetting().WatermarkFontSize);
                        }
                        File.Delete(fileSavePath2);
                    }
                    else
                    {
                        postedFile.SaveAs(fileSavePath);
                    }

                    result = 2;
                    break;
                }
            }

            Response.Redirect(FileName + "?path=" + uploadPath + "&result=" + result);
        }