Exemple #1
0
        /// <summary>
        /// 创建主题帖信息
        /// </summary>
        /// <param name="topicinfo"></param>
        /// <returns></returns>
        public PostInfo CreatePost(TopicInfo topicinfo)
        {
            PostInfo postinfo = new PostInfo();

            postinfo.Fid      = forumid;
            postinfo.Tid      = topicinfo.Tid;
            postinfo.Poster   = username;
            postinfo.Posterid = userid;
            postinfo.Title    = useradminid == 1 ? Utils.HtmlEncode(posttitle) :
                                postinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(posttitle));
            postinfo.Postdatetime              = curdatetime;
            postinfo.Message     = message;
            postinfo.Ip          = DNTRequest.GetIP();
            postinfo.Invisible   = UserAuthority.GetTopicPostInvisible(forum, useradminid, userid, usergroupinfo, postinfo);
            postinfo.Usesig      = TypeConverter.StrToInt(DNTRequest.GetString("usesig"));
            postinfo.Htmlon      = (usergroupinfo.Allowhtml == 1 && (TypeConverter.StrToInt(DNTRequest.GetString("htmlon")) == 1)) ? 1 : 0;
            postinfo.Smileyoff   = (smileyoff == 0 && forum.Allowsmilies == 1) ? TypeConverter.StrToInt(DNTRequest.GetString("smileyoff")) : smileyoff;
            postinfo.Bbcodeoff   = (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1) ? postinfo.Bbcodeoff = TypeConverter.StrToInt(DNTRequest.GetString("bbcodeoff")) : 1;
            postinfo.Parseurloff = TypeConverter.StrToInt(DNTRequest.GetString("parseurloff"));
            postinfo.Topictitle  = topicinfo.Title;

            //if (Utils.GetCookie("lasttopictitle") == Utils.MD5(postinfo.Title) || Utils.GetCookie("lasttopicmessage") == Utils.MD5(postinfo.Message))
            //{
            //    AddErrLine("请勿重复发帖");
            //    return postinfo;
            //}

            try
            {
                postinfo.Pid = Posts.CreatePost(postinfo);
                Utils.WriteCookie("lasttopictitle", Utils.MD5(postinfo.Title));
                Utils.WriteCookie("lasttopicmessage", Utils.MD5(postinfo.Message));
            }
            catch
            {
                TopicAdmins.DeleteTopics(topicinfo.Tid.ToString(), false);
                AddErrLine("帖子保存出现异常");
            }

            //创建投票
            if (createpoll)
            {
                msg = Polls.CreatePoll(DNTRequest.GetFormString("PollItemname"), DNTRequest.GetString("multiple") == "on" ? 1 : 0,
                                       DNTRequest.GetInt("maxchoices", 1), DNTRequest.GetString("visiblepoll") == "on" ? 1 : 0, DNTRequest.GetString("allowview") == "on" ? 1 : 0,
                                       enddatetime, topicinfo.Tid, pollitem, userid);
            }
            return(postinfo);
        }
Exemple #2
0
        public Post CreatePost(Topic topicinfo)
        {
            var pi = new Post();

            pi.Fid      = this.forumid;
            pi.Tid      = topicinfo.ID;
            pi.Poster   = this.username;
            pi.PosterID = this.userid;
            pi.Title    = ((this.useradminid == 1) ? Utils.HtmlEncode(this.posttitle) : Utils.HtmlEncode(ForumUtils.BanWordFilter(this.posttitle)));
            //pi.Postdatetime = DateTime.Now.ToFullString();
            //pi.Title = topicinfo.Title;
            pi.Message = this.message;
            //pi.Ip = WebHelper.UserHost;
            pi.Invisible   = UserAuthority.GetTopicPostInvisible(this.forum, this.useradminid, this.userid, this.usergroupinfo, pi);
            pi.UseSig      = DNTRequest.GetInt("usesig");
            pi.HtmlOn      = ((this.usergroupinfo.AllowHtml && DNTRequest.GetInt("htmlon") == 1) ? 1 : 0);
            pi.SmileyOff   = (smileyoff == 0 && forum.AllowSmilies) ? DNTRequest.GetInt("smileyoff") : this.smileyoff;
            pi.BBCodeOff   = (this.usergroupinfo.AllowCusbbCode && this.forum.Allowbbcode == 1) ? DNTRequest.GetInt("bbcodeoff") : 1;
            pi.ParseUrlOff = DNTRequest.GetInt("parseurloff");
            //pi.Topictitle = topicinfo.Title;
            //try
            //{
            //pi.Pid = Posts.CreatePost(pi);
            //pi.Insert();
            Utils.WriteCookie("lasttopictitle", Utils.MD5(pi.Title));
            Utils.WriteCookie("lasttopicmessage", Utils.MD5(pi.Message));
            //}
            //catch
            //{
            //	TopicAdmins.DeleteTopics(topicinfo.ID.ToString(), false);
            //	base.AddErrLine("帖子保存出现异常");
            //}
            if (this.createpoll)
            {
                this.msg = Poll.CreatePoll(
                    DNTRequest.GetFormString("PollItemname"),
                    (DNTRequest.GetString("multiple") == "on") ? 1 : 0,
                    DNTRequest.GetInt("maxchoices", 1),
                    (DNTRequest.GetString("visiblepoll") == "on") ? 1 : 0,
                    (DNTRequest.GetString("allowview") == "on") ? true : false,
                    Utility.ToDateTime(this.enddatetime), topicinfo.ID, this.pollitem, this.userid);
            }
            return(pi);
        }