Example #1
0
 /// <summary>
 /// 获取辩论的扩展信息
 /// </summary>
 /// <param name="tid">主题ID</param>
 /// <returns>辩论主题扩展信息</returns>
 public static DebateInfo GetDebateTopic(int tid)
 {            
     IDataReader debatetopic = DatabaseProvider.GetInstance().GetDebateTopic(tid);
     DebateInfo topicexpand = new DebateInfo();
     if (debatetopic.Read())
     {
         topicexpand.Positiveopinion = debatetopic["positiveopinion"].ToString();
         topicexpand.Negativeopinion = debatetopic["negativeopinion"].ToString();
         topicexpand.Terminaltime = DateTime.Parse(debatetopic["terminaltime"].ToString());
         topicexpand.Positivediggs = TypeConverter.ObjectToInt(debatetopic["positivediggs"]);
         topicexpand.Negativediggs = TypeConverter.ObjectToInt(debatetopic["negativediggs"]);
         topicexpand.Tid = tid;
     }
     debatetopic.Close();
     return topicexpand;
 }
Example #2
0
 /// <summary>
 /// 获取辩论的扩展信息
 /// </summary>
 /// <param name="tid">主题ID</param>
 /// <returns>辩论主题扩展信息</returns>
 public static DebateInfo GetDebateTopic(int tid)
 {
     DebateInfo topicexpand = new DebateInfo();
     IDataReader debatetopic = DatabaseProvider.GetInstance().GetDebateTopic(tid);
     if (debatetopic.Read())
     {
         topicexpand.Positiveopinion = debatetopic["positiveopinion"].ToString();
         topicexpand.Negativeopinion = debatetopic["negativeopinion"].ToString();
         //topicexpand.Positivecolor = debatetopic["positivecolor"].ToString();
         //topicexpand.Negativecolor = debatetopic["negativecolor"].ToString();
         topicexpand.Terminaltime = DateTime.Parse(debatetopic["terminaltime"].ToString());
         topicexpand.Positivediggs = int.Parse(debatetopic["positivediggs"].ToString());
         topicexpand.Negativediggs = int.Parse(debatetopic["negativediggs"].ToString());
         //topicexpand.Positivebordercolor = debatetopic["positivebordercolor"].ToString();
         //topicexpand.Negativebordercolor = debatetopic["negativebordercolor"].ToString();
         topicexpand.Tid = tid;
     }
     debatetopic.Close();
     return topicexpand;
 }
Example #3
0
        /// <summary>
        /// 创建主题信息
        /// </summary>
        /// <param name="admininfo"></param>
        /// <param name="postmessage"></param>
        /// <param name="isbonus"></param>
        /// <param name="topicprice"></param>
        /// <returns></returns>
        public TopicInfo CreateTopic(AdminGroupInfo admininfo, string postmessage, bool isbonus, int topicprice)
        {
            TopicInfo topicinfo = new TopicInfo();
            topicinfo.Fid = forumid;
            topicinfo.Iconid = (DNTRequest.GetInt("iconid", 0) < 0 || DNTRequest.GetInt("iconid", 0) > 15) ? 0 :
                                DNTRequest.GetInt("iconid", 0);
            message = Posts.GetPostMessage(usergroupinfo, admininfo, postmessage,
                (TypeConverter.StrToInt(DNTRequest.GetString("htmlon")) == 1));

            topicinfo.Title = (useradminid == 1) ? Utils.HtmlEncode(DNTRequest.GetString("title")) :
                               Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title")));

            if (useradminid != 1 && (ForumUtils.HasBannedWord(topicinfo.Title) || ForumUtils.HasBannedWord(message)))
            {
                AddErrLine("对不起, 您提交的内容包含不良信息, 因此无法提交, 请返回修改!"); return topicinfo;
            }

            topicinfo.Typeid = DNTRequest.GetInt("typeid", 0);
            if (usergroupinfo.Allowsetreadperm == 1)
                topicinfo.Readperm = DNTRequest.GetInt("topicreadperm", 0) > 255 ? 255 : DNTRequest.GetInt("topicreadperm", 0);

            topicinfo.Price = topicprice;
            topicinfo.Poster = username;
            topicinfo.Posterid = userid;
            topicinfo.Postdatetime = curdatetime;
            topicinfo.Lastpost = curdatetime;
            topicinfo.Lastposter = username;
            topicinfo.Displayorder = Topics.GetTitleDisplayOrder(usergroupinfo, useradminid, forum, topicinfo, message, disablepost);

            string htmltitle = DNTRequest.GetString("htmltitle").Trim();
            if (!Utils.StrIsNullOrEmpty(htmltitle) && Utils.HtmlDecode(htmltitle).Trim() != topicinfo.Title)
            {
                //按照  附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储  例: 11001
                topicinfo.Magic = 11000;
            }

            //标签(Tag)操作                
            string tags = DNTRequest.GetString("tags").Trim();
            string[] tagArray = null;
            if (enabletag && !Utils.StrIsNullOrEmpty(tags))
            {
                if (ForumUtils.InBanWordArray(tags))
                {
                    AddErrLine("标签中含有系统禁止词语,请修改");
                    return topicinfo;
                }

                tagArray = Utils.SplitString(tags, " ", true, 2, 10);
                if (tagArray.Length > 0 && tagArray.Length <= 5)
                {
                    if (topicinfo.Magic == 0)
                        topicinfo.Magic = 10000;

                    topicinfo.Magic = Utils.StrToInt(topicinfo.Magic.ToString() + "1", 0);
                }
                else
                {
                    AddErrLine("超过标签数的最大限制或单个标签长度没有介于2-10之间,最多可填写 5 个标签");
                    return topicinfo;
                }
            }

            if (isbonus)
            {
                topicinfo.Special = 2;

                //检查积分是否足够
                if (mybonustranscredits < topicprice && usergroupinfo.Radminid != 1)
                {
                    AddErrLine(string.Format("无法进行悬赏<br /><br />您当前的{0}为 {1} {3}<br/>悬赏需要{0} {2} {3}", bonusextcreditsinfo.Name, mybonustranscredits, topicprice, bonusextcreditsinfo.Unit));
                    return topicinfo;
                }
                else
                    Users.UpdateUserExtCredits(topicinfo.Posterid, Scoresets.GetBonusCreditsTrans(),
                                       -topicprice * (Scoresets.GetCreditsTax() + 1)); //计算税后的实际支付
            }

            if (type == "poll")
                topicinfo.Special = 1;

            if (type == "debate") //辩论帖
                topicinfo.Special = 4;

            if (!Moderators.IsModer(useradminid, userid, forumid))
                topicinfo.Attention = 1;

            if (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1)
                topicinfo.Hide = 1;

            topicinfo.Tid = Topics.CreateTopic(topicinfo);

            canhtmltitle = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup);
            //保存htmltitle
            if (canhtmltitle && !Utils.StrIsNullOrEmpty(htmltitle) && htmltitle != topicinfo.Title)
                Topics.WriteHtmlTitleFile(htmltitle, topicinfo.Tid);

            if (enabletag && tagArray != null && tagArray.Length > 0)
            {
                if (ForumUtils.HasBannedWord(tags))
                {
                    AddErrLine("标签中含有系统禁止词语,请修改");
                    return topicinfo;
                }
                ForumTags.CreateTopicTags(tagArray, topicinfo.Tid, userid, curdatetime);
            }

            if (type == "debate")
            {
                DebateInfo debatetopic = new DebateInfo();
                debatetopic.Tid = topicinfo.Tid;
                debatetopic.Positiveopinion = DNTRequest.GetString("positiveopinion");
                debatetopic.Negativeopinion = DNTRequest.GetString("negativeopinion");
                debatetopic.Terminaltime = Convert.ToDateTime(DNTRequest.GetString("terminaltime"));
                Topics.CreateDebateTopic(debatetopic);
            }

            Topics.AddParentForumTopics(forum.Parentidlist.Trim(), 1, 1);
            return topicinfo;
        }
Example #4
0
 public bool UpdateDebateTopic(DebateInfo debateInfo)
 {
     DbParameter[] parms = {
                               DbHelper.MakeInParam("@tid",(DbType)SqlDbType.Int,4,debateInfo.Tid),
                               DbHelper.MakeInParam("@positiveopinion",(DbType)SqlDbType.NVarChar,200,debateInfo.Positiveopinion),
                               DbHelper.MakeInParam("@positivediggs",(DbType)SqlDbType.Int,4,debateInfo.Positivediggs),
                               DbHelper.MakeInParam("@negativeopinion",(DbType)SqlDbType.NVarChar,200,debateInfo.Negativeopinion),
                               DbHelper.MakeInParam("@negativediggs",(DbType)SqlDbType.Int,4,debateInfo.Negativediggs),
                               DbHelper.MakeInParam("@terminaltime",(DbType)SqlDbType.DateTime,8,debateInfo.Terminaltime)
                           };
     DbHelper.ExecuteNonQuery(CommandType.StoredProcedure, string.Format("{0}updatedebate", BaseConfigs.GetTablePrefix), parms);
     return true;
 }
Example #5
0
        public void CreateDebateTopic(DebateInfo debateTopic)
        {
            DbParameter[] parms = {
                                      DbHelper.MakeInParam("@tid", (DbType)SqlDbType.Int, 4, debateTopic.Tid),
                                      DbHelper.MakeInParam("@positiveopinion", (DbType)SqlDbType.NVarChar, 200, debateTopic.Positiveopinion),
                                      DbHelper.MakeInParam("@negativeopinion", (DbType)SqlDbType.NVarChar, 200, debateTopic.Negativeopinion),
                                      DbHelper.MakeInParam("@terminaltime", (DbType)SqlDbType.DateTime, 8, debateTopic.Terminaltime)
                                  };

            string commandText = string.Format(@"INSERT INTO [{0}debates]([tid], [positiveopinion], [negativeopinion], [terminaltime]) VALUES(@tid, @positiveopinion, @negativeopinion, @terminaltime)",
                                                 BaseConfigs.GetTablePrefix);
            DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
        }
Example #6
0
        /// <summary>
        /// 获取辩论信息
        /// </summary>
        public void GetDebateInfo()
        {
            debateexpand = Debates.GetDebateTopic(topicid);
            debateList = Debates.GetPostDebateList(topicid);//通过TID得到帖子观点
            if (debateexpand.Terminaltime < DateTime.Now)
                isenddebate = true;

            foreach (ShowtopicPagePostInfo postlistinfo in postlist)
            {
                //设置POST的观点属性
                if (debateList != null && debateList.ContainsKey(postlistinfo.Pid))
                    postlistinfo.Debateopinion = debateList[postlistinfo.Pid];
            }
        }
Example #7
0
        protected override void ShowPage()
        {
            //pagetitle = "编辑帖子";
            #region 判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            this.disablepostctrl = 0;
            if (admininfo != null)
                disablepostctrl = admininfo.Disablepostctrl;
            #endregion

            if (userid == -1)
            {
                forum = new ForumInfo();
                topic = new TopicInfo();
                postinfo = new PostInfo();
                AddErrLine("您尚未登录");
                return;
            }

            #region 获取帖子和主题相关信息
            // 如果帖子ID非数字
            if (postid == -1)
            {
                AddErrLine("无效的帖子ID");
                return;
            }

            postinfo = Posts.GetPostInfo(topicid, postid);
            // 如果帖子不存在
            if (postinfo == null)
            {
                AddErrLine("不存在的帖子ID");
                return;
            }
            pagetitle = (postinfo.Title == "") ? "编辑帖子" : postinfo.Title;
            htmlon = postinfo.Htmlon;
            message = postinfo.Message;
            isfirstpost = postinfo.Layer == 0;

            // 获取主题ID
            if (topicid != postinfo.Tid || postinfo.Tid == -1)
            {
                AddErrLine("无效的主题ID");
                return;
            }

            // 获取该主题的信息
            topic = Topics.GetTopicInfo(postinfo.Tid);
            // 如果该主题不存在
            if (topic == null)
            {
                AddErrLine("不存在的主题ID");
                return;
            }

            if (topic.Special == 1 && postinfo.Layer == 0)
            {
                pollinfo = Polls.GetPollInfo(topic.Tid);
                polloptionlist = Polls.GetPollOptionList(topic.Tid);
            }

            if (topic.Special == 4 && postinfo.Layer == 0)
            {
                debateinfo = Debates.GetDebateTopic(topic.Tid);
            }

            #endregion

            #region 获取并检查版块信息
            ///得到所在版块信息
            forumid = topic.Fid;
            forum = Forums.GetForumInfo(forumid);
            needaudit = UserAuthority.NeedAudit(forum, useradminid, topic, userid, disablepostctrl, usergroupinfo);
            // 如果该版块不存在
            if (forum == null || forum.Layer == 0)
            {
                AddErrLine("版块已不存在");
                forum = new ForumInfo();
                return;
            }

            if (!Utils.StrIsNullOrEmpty(forum.Password) && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password"))
            {
                AddErrLine("本版块被管理员设置了密码");
                SetBackLink(base.ShowForumAspxRewrite(forumid, 0));
                return;
            }

            if (forum.Applytopictype == 1)  //启用主题分类
                topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes);
            customeditbuttons = Caches.GetCustomEditButtonList();
            #endregion

            //是否有编辑帖子的权限
            if (!UserAuthority.CanEditPost(postinfo, userid, useradminid, ref msg))
            {
                AddErrLine(msg);
                return;
            }
            #region  附件信息绑定
            //得到用户可以上传的文件类型
            string attachmentTypeSelect = Attachments.GetAllowAttachmentType(usergroupinfo, forum);
            attachextensions = Attachments.GetAttachmentTypeArray(attachmentTypeSelect);
            attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect);
            //得到今天允许用户上传的附件总大小(字节)
            int MaxTodaySize = (userid > 0 ? MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid) : 0);
            attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;//今天可上传得大小
            //是否有上传附件的权限
            canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg);

            userinfo = Users.GetShortUserInfo(userid);
            if (canpostattach && (config.Enablealbum == 1) && apb != null &&
                (UserGroups.GetUserGroupInfo(userinfo.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0))
            {
                caninsertalbum = true;
                albumlist = apb.GetSpaceAlbumByUserId(userid);
            }
            else
                caninsertalbum = false;

            attachmentlist = Attachments.GetAttachmentListByPid(postinfo.Pid);
            attachmentcount = attachmentlist.Rows.Count;
            //当前用户是否有允许下载附件权限
            allowviewattach = UserAuthority.DownloadAttachment(forum, userid, usergroupinfo);

            #endregion

            smileyoff = (!DNTRequest.IsPost()) ? postinfo.Smileyoff : 1 - forum.Allowsmilies;
            allowimg = forum.Allowimgcode;
            parseurloff = postinfo.Parseurloff;
            bbcodeoff = (usergroupinfo.Allowcusbbcode == 1) ? postinfo.Bbcodeoff : 1;
            usesig = postinfo.Usesig;
            userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
            if (bonusCreditsTrans > 0 && bonusCreditsTrans < 9)
            {
                bonusextcreditsinfo = Scoresets.GetScoreSet(bonusCreditsTrans);
                mybonustranscredits = Users.GetUserExtCredits(userid, bonusCreditsTrans);
            }

            //是否有访问当前版块的权限
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                return;
            }

            // 判断当前用户是否有修改权限, 检查是否具有版主的身份
            if (!Moderators.IsModer(useradminid, userid, forumid))
            {
                if (postinfo.Posterid != userid)
                {
                    AddErrLine("你并非作者, 且你当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有修改该帖的权限");
                    return;
                }
                else if (config.Edittimelimit > 0 && Utils.StrDateDiffMinutes(postinfo.Postdatetime, config.Edittimelimit) > 0)
                {
                    AddErrLine("抱歉, 系统规定只能在帖子发表" + config.Edittimelimit + "分钟内才可以修改");
                    return;
                }
                else if(config.Edittimelimit==-1)
                {
                    AddErrLine("抱歉,系统不允许修改帖子");
                    return;
                }
            }

            #region htmltitle标题
            if (postinfo.Layer == 0)
                canhtmltitle = usergroupinfo.Allowhtmltitle == 1;

            if (Topics.GetMagicValue(topic.Magic, MagicType.HtmlTitle) == 1)
                htmltitle = Topics.GetHtmlTitle(topic.Tid).Replace("\"", "\\\"").Replace("'", "\\'");
            #endregion

            #region tag信息
            enabletag = (config.Enabletag & forum.Allowtag) == 1;
            if (enabletag && Topics.GetMagicValue(topic.Magic, MagicType.TopicTag) == 1)
            {
                foreach (TagInfo tag in ForumTags.GetTagsListByTopic(topic.Tid))
                {
                    if (tag.Orderid > -1)
                        topictags += string.Format(" {0}", tag.Tagname);
                }
                topictags = topictags.Trim();
            }
            #endregion
            userGroupInfoList.Sort(delegate(UserGroupInfo x, UserGroupInfo y) { return (x.Readaccess - y.Readaccess) + (y.Groupid - x.Groupid); });
            //如果是提交...
            if (ispost)
            {
                SetBackLink("editpost.aspx?topicid=" + postinfo.Tid + "&postid=" + postinfo.Pid);

                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                //设置相关帖子信息
                SetPostInfo(admininfo, userinfo, Utils.StrToInt(DNTRequest.GetString("htmlon"), 0) == 1);

                if (IsErr()) return;

                //通过验证的用户可以编辑帖子
                Posts.UpdatePost(postinfo);

                //设置附件相关信息
                System.Text.StringBuilder sb = SetAttachmentInfo();

                if (IsErr()) return;

                UserCredits.UpdateUserCredits(userid);

                #region 设置提示信息和跳转链接
                //辩论地址
                if (topic.Special == 4)
                    SetUrl(Urls.ShowDebateAspxRewrite(topic.Tid));
                else if (DNTRequest.GetQueryString("referer") != "")//ajax快速回复将传递referer参数
                    SetUrl(string.Format("showtopic.aspx?page=end&forumpage={2}&topicid={0}#{1}", topic.Tid, postinfo.Pid, forumpageid));
                else if (pageid > 1)//如果不是ajax,则应该是带pageid的参数
                {
                    if (config.Aspxrewrite == 1)
                        SetUrl(string.Format("showtopic-{0}-{2}{1}#{3}", topic.Tid, config.Extname, pageid, postinfo.Pid));
                    else
                        SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={3}&page={2}#{1}", topic.Tid, postinfo.Pid, pageid, forumpageid));
                }
                else//如果都为空.就跳转到第一页(以免意外情况)
                {
                    if (config.Aspxrewrite == 1)
                        SetUrl(string.Format("showtopic-{0}{1}", topic.Tid, config.Extname));
                    else
                        SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={1}", topic.Tid, forumpageid));
                }

                if (sb.Length > 0)
                {
                    SetMetaRefresh(5);
                    SetShowBackLink(true);
                    if (infloat == 1)
                    {
                        AddErrLine(sb.ToString());
                        return;
                    }
                    else
                    {
                        sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>编辑帖子成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>");
                        sb.Append("</table>");
                        AddMsgLine(sb.ToString());
                    }
                }
                else
                {
                    //编辑主题和回复需要审核
                    if (postinfo.Layer == 0)
                        SetMetaRefresh(2, base.ShowForumAspxRewrite(forumid, forumpageid));
                    else
                        SetMetaRefresh();
                    SetShowBackLink(false);

                    if (useradminid != 1 && (needaudit || topic.Displayorder == -2 || postinfo.Invisible == 1))
                    {
                        if (postinfo.Layer == 0)
                            SetUrl(base.ShowForumAspxRewrite(forumid, forumpageid));
                        else
                            SetUrl(base.ShowTopicAspxRewrite(topic.Tid, forumpageid));
                        AddMsgLine("编辑成功, 但需要经过审核才可以显示");
                    }
                    else
                    {
                        MsgForward("editpost_succeed");
                        AddMsgLine("编辑帖子成功, 返回该主题");
                    }
                }
                #endregion

                // 删除主题游客缓存
                if (postinfo.Layer == 0)
                    ForumUtils.DeleteTopicCacheFile(topic.Tid);
            }
            else
                AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
        }
Example #8
0
        /// <summary>
        /// 获取辩论信息
        /// </summary>
        public void GetDebateInfo(PostpramsInfo postpramsInfo)
        {
            debateexpand = Debates.GetDebateTopic(topicid);
            debateList = Debates.GetPostDebateList(topicid);//通过TID得到帖子观点
            if (debateexpand.Terminaltime < DateTime.Now)
                isenddebate = true;

            int positivepostlistcount = Debates.GetDebatesPostCount(postpramsInfo, 1);
            int negativepostlistcount = Debates.GetDebatesPostCount(postpramsInfo, 2);

            positivepagecount = (positivepostlistcount % pagesize == 0) ? (positivepostlistcount / pagesize) : (positivepostlistcount / pagesize + 1);
            negativepagecount = (negativepostlistcount % pagesize == 0) ? (negativepostlistcount / pagesize) : (negativepostlistcount / pagesize + 1);

            positivepagenumbers = Utils.GetAjaxPageNumbers(1, positivepagecount, "showdebatepage('" + forumpath + "tools/ajax.aspx?t=getdebatepostpage&opinion=1&tid=" + topic.Tid + "&{0}'," + parseurloff + ", " + smileyoff + ", " + bbcodeoff + ",'" + isenddebate + "',1," + userid + "," + topicid + ")", 8);
            negativepagenumbers = Utils.GetAjaxPageNumbers(1, negativepagecount, "showdebatepage('" + forumpath + "tools/ajax.aspx?t=getdebatepostpage&opinion=2&tid=" + topic.Tid + "&{0}'," + parseurloff + ", " + smileyoff + ", " + bbcodeoff + ",'" + isenddebate + "',2," + userid + "," + topicid + ")", 8);

            //防止无人参与时0做除数
            if (debateexpand.Negativediggs + debateexpand.Positivediggs != 0)
            {
                positivepercent = (float)debateexpand.Positivediggs / (float)(debateexpand.Negativediggs + debateexpand.Positivediggs) * 100;
                negativepercent = 100 - positivepercent;
            }

            foreach (ShowtopicPagePostInfo postlistinfo in positivepostlist)
            {
                //设置POST的观点属性
                if (debateList != null && debateList.ContainsKey(postlistinfo.Pid))
                    postlistinfo.Debateopinion = Convert.ToInt32(debateList[postlistinfo.Pid]);
            }
        }
Example #9
0
 /// <summary>
 /// 增加辩论主题扩展信息
 /// </summary>
 /// <param name="debatetopic"></param>
 public static void CreateDebateTopic(DebateInfo debateTopic)
 {
     Data.Debates.CreateDebateTopic(debateTopic);
 }
Example #10
0
        public void AddDebateTopic(DebateInfo debatetopic)
        {
            DbParameter[] parms = {
                                      DbHelper.MakeInParam("@tid", DbType.Int32, 4, debatetopic.Tid),
                                      DbHelper.MakeInParam("@positiveopinion", DbType.String, 200, debatetopic.Positiveopinion),
                                      DbHelper.MakeInParam("@negativeopinion", DbType.String, 200, debatetopic.Negativeopinion),
                                      //DbHelper.MakeInParam("@positivecolor", DbType.AnsiString, 6, debatetopic.Positivecolor),
                                      //DbHelper.MakeInParam("@negativecolor", DbType.AnsiString, 6, debatetopic.Negativecolor),
                                      //DbHelper.MakeInParam("@positivebordercolor", DbType.AnsiString, 6, debatetopic.Positivebordercolor),
                                      //DbHelper.MakeInParam("@negativebordercolor", DbType.AnsiString, 6, debatetopic.Negativebordercolor),
                                      DbHelper.MakeInParam("@terminaltime", DbType.DateTime, 8, debatetopic.Terminaltime)
                                  };

            string sql = string.Format(@"INSERT INTO [{0}debates]([tid], [positiveopinion], [negativeopinion], [terminaltime]) VALUES(@tid, @positiveopinion, @negativeopinion, @terminaltime)", BaseConfigs.GetTablePrefix);

            DbHelper.ExecuteNonQuery(CommandType.Text, sql, parms);
        }
Example #11
0
 /// <summary>
 /// 增加辩论主题扩展信息
 /// </summary>
 /// <param name="debatetopic"></param>
 public static void CreateDebateTopic(DebateInfo debateInfo)
 {
     //debatetopic = ReviseDebateTopicColor(debatetopic);
     DatabaseProvider.GetInstance().CreateDebateTopic(debateInfo);
 }
Example #12
0
 /// <summary>
 /// 更新辩论信息
 /// </summary>
 /// <param name="debateInfo">辩论信息</param>
 /// <returns></returns>
 public static bool UpdateDebateTopic(DebateInfo debateInfo)
 {
     return DatabaseProvider.GetInstance().UpdateDebateTopic(debateInfo);
 }
Example #13
0
        protected override void ShowPage()
        {
            headerad = "";
            footerad = "";
            postleaderboardad = "";

            doublead = "";
            floatad = "";

            allowrate = false;
            disablepostctrl = 0;
            // 获取主题ID
            topicid = DNTRequest.GetInt("topicid", -1);
            // 获取该主题的信息
            string go = DNTRequest.GetString("go").Trim().ToLower();
            int fid = DNTRequest.GetInt("forumid", 0);
            firstpagesmilies = Caches.GetSmiliesFirstPageCache();

            if (go == "")
            {
                fid = 0;
            }
            else if (fid == 0)
            {
                go = "";
            }

            string errmsg = "";
            switch (go)
            {
                case "prev":
                    topic = Topics.GetTopicInfo(topicid, fid, 1);
                    errmsg = "没有更旧的主题, 请返回";
                    break;
                case "next":
                    topic = Topics.GetTopicInfo(topicid, fid, 2);
                    errmsg = "没有更新的主题, 请返回";
                    break;
                default:
                    topic = Topics.GetTopicInfo(topicid);
                    errmsg = "该主题不存在";
                    break;
            }

            if (topic == null)
            {
                AddErrLine(errmsg);

                headerad = Advertisements.GetOneHeaderAd("", 0);
                footerad = Advertisements.GetOneFooterAd("", 0);
                pagewordad = Advertisements.GetPageWordAd("", 0);
                doublead = Advertisements.GetDoubleAd("", 0);
                floatad = Advertisements.GetFloatAd("", 0);
                return;
            }

            if (topic.Identify > 0)
            {
                topicidentify = Caches.GetTopicIdentify(topic.Identify);
            }
            topicid = topic.Tid;
            forumid = topic.Fid;
            forum = Forums.GetForumInfo(forumid);

            forumname = forum.Name;
            pagetitle = topic.Title;
            forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
            navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);

            fid = forumid;

            ///得到广告列表
            ///头部
            headerad = Advertisements.GetOneHeaderAd("", fid);
            footerad = Advertisements.GetOneFooterAd("", fid);
            postleaderboardad = Advertisements.GetOnePostLeaderboardAD("", fid);

            pagewordad = Advertisements.GetPageWordAd("", fid);
            doublead = Advertisements.GetDoubleAd("", fid);
            floatad = Advertisements.GetFloatAd("", fid);

            // 检查是否具有版主的身份
            if (useradminid != 0)
            {
                ismoder = Moderators.IsModer(useradminid, userid, forumid) ? 1 : 0;
                //得到管理组信息
                admininfo = AdminGroups.GetAdminGroupInfo(useradminid);
                if (admininfo != null)
                {
                    disablepostctrl = admininfo.Disablepostctrl;
                }
            }
            //验证不通过则返回
            if (!IsConditionsValid())
                return;

            showratelog = GeneralConfigs.GetConfig().DisplayRateCount > 0 ? 1 : 0;


            topictitle = topic.Title.Trim();
            replytitle = topictitle;
            if (replytitle.Length >= 50)
            {
                replytitle = Utils.CutString(replytitle, 0, 50) + "...";
            }

            //topicmagic = ForumUtils.ShowTopicMagic(topic.Magic);
            topicviews = topic.Views + 1 +
                         (config.TopicQueueStats == 1 ? TopicStats.GetStoredTopicViewCount(topic.Tid) : 0);
            smilies = Caches.GetSmiliesCache();
            smilietypes = Caches.GetSmilieTypesCache();


            //编辑器状态
            StringBuilder sb = new StringBuilder();
            sb.Append("var Allowhtml=1;\r\n"); //+ allhtml.ToString() + "

            parseurloff = 0;

            smileyoff = 1 - forum.Allowsmilies;
            sb.Append("var Allowsmilies=" + (1 - smileyoff).ToString() + ";\r\n");


            bbcodeoff = 1;
            if (forum.Allowbbcode == 1)
            {
                if (usergroupinfo.Allowcusbbcode == 1)
                {
                    bbcodeoff = 0;
                }
            }
            sb.Append("var Allowbbcode=" + (1 - bbcodeoff).ToString() + ";\r\n");

            usesig = ForumUtils.GetCookie("sigstatus") == "0" ? 0 : 1;

            allowimg = forum.Allowimgcode;
            sb.Append("var Allowimgcode=" + allowimg.ToString() + ";\r\n");

            AddScript(sb.ToString());
            int price = 0;
            if (topic.Special == 0)//普通主题
            {
                //购买帖子操作
                //判断是否为购买可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买                
                if (topic.Price > 0 && userid != topic.Posterid && ismoder != 1)
                {
                    price = topic.Price;
                    //时间乘以-1是因为当Configs.GetMaxChargeSpan()==0时,帖子始终为购买帖
                    if (PaymentLogs.IsBuyer(topicid, userid) ||
                        (Utils.StrDateDiffHours(topic.Postdatetime, Scoresets.GetMaxChargeSpan()) > 0 &&
                         Scoresets.GetMaxChargeSpan() != 0)) //判断当前用户是否已经购买
                    {
                        price = -1;
                    }
                }
                try
                {
                    if (price > 0)
                    {
                        if (userid > 0)
                        {
                            float extcredits2 = Discuz.Forum.Users.GetUserExtCredits(userid, 2);
                            if (extcredits2 < price)
                            {
                                //HttpContext.Current.Response.Redirect(forumpath + "buytopic.aspx?topicid=" + topic.Tid);
                                AddErrLine("抱歉,您的金币已不足以浏览该帖!");
                                return;
                            }
                        }
                        else
                        {
                            AddErrLine("您当前的身份是游客,需要登录才能浏览该帖");
                        }
                    }
                }
                catch
                {
                    AddErrLine("您当前的身份是游客,需要登录才能浏览该帖");
                }
            }

            if (topic.Special == 3)//已给分的悬赏帖
            {
                bonuslogs = Bonus.GetLogs(topic.Tid);
            }

            if (topic.Moderated > 0)
            {
                moderactions = TopicAdmins.GetTopicListModeratorLog(topicid);
            }

            try
            {
                topictypes = Caches.GetTopicTypeArray()[topic.Typeid].ToString();
                topictypes = topictypes != "" ? "[" + topictypes + "]" : "";
            }
            catch
            {
            }

            userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetCreditsTrans());

            if (newpmcount > 0)
            {
                pmlist = PrivateMessages.GetPrivateMessageCollectionForIndex(userid, 5, 1, 1);
                showpmhint = Convert.ToInt32(Discuz.Forum.Users.GetShortUserInfo(userid).Newsletter) > 4;
            }


            ispoll = false;
            allowvote = false;
            if (topic.Special == 1)
            {
                ispoll = true;
                polloptionlist = Polls.GetPollOptionList(topicid);
                pollinfo = Polls.GetPollInfo(topicid);
                voters = Polls.GetVoters(topicid, userid, username, out allowvote);

                if (pollinfo.Uid != userid && useradminid != 1) //当前用户不是投票发起人或不是管理组成员
                {
                    if (pollinfo.Visible == 1 && //当为投票才可见时
                    (allowvote || (userid == -1 && !Utils.InArray(topicid.ToString(), ForumUtils.GetCookie("dnt_polled")))))//当允许投票或为游客(且并未投过票时)时
                    {
                        showpollresult = false;
                    }
                }
            }


            if (ispoll)
            {
                if (Utils.StrIsNullOrEmpty(pollinfo.Expiration))
                {
                    //AddErrLine("读取信息失败");
                    //return;
                    pollinfo.Expiration = DateTime.Now.ToString();
                }

                if (DateTime.Parse(pollinfo.Expiration) < DateTime.Now)
                {
                    allowvote = false;
                }

            }


            // 获取帖子总数
            //postcount = Posts.GetPostCount(topicid);
            onlyauthor = DNTRequest.GetString("onlyauthor");
            if (onlyauthor == "" || onlyauthor == "0")
            {
                postcount = topic.Replies + 1;
            }
            else
            {
                postcount = DatabaseProvider.GetInstance().GetPostCount(Posts.GetPostTableID(topicid), topicid, topic.Posterid);
            }

            // 得到Ppp设置
            ppp = Utils.StrToInt(ForumUtils.GetCookie("ppp"), config.Ppp);


            if (ppp <= 0)
            {
                ppp = config.Ppp;
            }

            //获取总页数
            pagecount = postcount % ppp == 0 ? postcount / ppp : postcount / ppp + 1;
            if (pagecount == 0)
            {
                pagecount = 1;
            }
            // 得到当前用户请求的页数
            if (DNTRequest.GetString("page").ToLower().Equals("end"))
            {
                pageid = pagecount;
            }
            else
            {
                pageid = DNTRequest.GetInt("page", 1);
            }
            //修正请求页数中可能的错误
            if (pageid < 1)
            {
                pageid = 1;
            }
            if (pageid > pagecount)
            {
                pageid = pagecount;
            }
            //判断是否为回复可见帖, hide=0为不解析[hide]标签, hide>0解析为回复可见字样, hide=-1解析为以下内容回复可见字样显示真实内容
            //将逻辑判断放入取列表的循环中处理,此处只做是否为回复人的判断,主题作者也该可见
            int hide = 1;
            if (topic.Hide == 1 && (Posts.IsReplier(topicid, userid) || ismoder == 1))
            {
                hide = -1;
            }


            //获取当前页主题列表

            DataSet ds = new DataSet();
            PostpramsInfo postpramsInfo = new PostpramsInfo();
            postpramsInfo.Fid = forum.Fid;
            postpramsInfo.Tid = topicid;
            postpramsInfo.Jammer = forum.Jammer;
            postpramsInfo.Pagesize = ppp;
            postpramsInfo.Pageindex = pageid;
            postpramsInfo.Getattachperm = forum.Getattachperm;
            postpramsInfo.Usergroupid = usergroupid;
            postpramsInfo.Attachimgpost = config.Attachimgpost;
            postpramsInfo.Showattachmentpath = config.Showattachmentpath;
            postpramsInfo.Hide = hide;
            postpramsInfo.Price = price;
            postpramsInfo.Usergroupreadaccess = usergroupinfo.Readaccess;
            if (ismoder == 1)
                postpramsInfo.Usergroupreadaccess = int.MaxValue;
            postpramsInfo.CurrentUserid = userid;
            postpramsInfo.Showimages = forum.Allowimgcode;
            postpramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo();
            postpramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo();
            postpramsInfo.Smiliesmax = config.Smiliesmax;
            postpramsInfo.Bbcodemode = config.Bbcodemode;
            postpramsInfo.CurrentUserGroup = usergroupinfo;
            if (!(onlyauthor.Equals("") || onlyauthor.Equals("0")))
            {
                postpramsInfo.Condition =
                    string.Format(" {0}.posterid={1}", Posts.GetPostTableName(topicid), topic.Posterid);
            }
            postlist = Posts.GetPostList(postpramsInfo, out attachmentlist, ismoder == 1);

            foreach (ShowtopicPageAttachmentInfo showtopicpageattachinfo in attachmentlist)
            {
                if (Forums.AllowGetAttachByUserID(forum.Permuserlist, userid))
                {
                    showtopicpageattachinfo.Getattachperm = 1;
                    showtopicpageattachinfo.Allowread = 1;
                }
            }

            if (topic.Special == 4)
            {
                debateexpand = Debates.GetDebateTopic(topicid);
                debateList = Debates.GetPostDebateList(topicid);//通过TID得到帖子观点

                if (debateexpand.Terminaltime < DateTime.Now)
                {
                    isenddebate = true;
                }

                foreach (ShowtopicPagePostInfo postlistinfo in postlist)
                {
                    //设置POST的观点属性
                    if (debateList != null && debateList.ContainsKey(postlistinfo.Pid))
                        postlistinfo.Debateopinion = Convert.ToInt32(debateList[postlistinfo.Pid]);


                }
            }
            //加载帖内广告
            inpostad = Advertisements.GetInPostAd("", fid, templatepath, postlist.Count > ppp ? ppp : postlist.Count);
            //快速发帖广告
            quickeditorad = Advertisements.GetQuickEditorAD("", fid);

            //快速编辑器背景广告
            string[] quickbgad = Advertisements.GetQuickEditorBgAd("", fid);

            if (quickbgad.Length > 1)
            {
                quickbgadimg = quickbgad[0];
                quickbgadlink = quickbgad[1];
            }

            if (postlist.Count <= 0)
            {
                AddErrLine("读取信息失败");
                return;
            }

            //更新页面Meta中的Description项, 提高SEO友好性
            string metadescritpion = Utils.RemoveHtml(postlist[0].Message);
            metadescritpion = metadescritpion.Length > 100 ? metadescritpion.Substring(0, 100) : metadescritpion;
            UpdateMetaInfo(config.Seokeywords, metadescritpion, config.Seohead);

            //获取相关主题集合
            enabletag = (config.Enabletag & forum.Allowtag) == 1;
            if (enabletag)
            {
                relatedtopics = Topics.GetRelatedTopics(topicid, 5);
            }


            //得到页码链接
            if (onlyauthor == "" || onlyauthor == "0")
            {
                if (config.Aspxrewrite == 1)
                {
                    pagenumbers = Utils.GetStaticPageNumbers(pageid, pagecount, "showtopic-" + topicid.ToString(), config.Extname, 8);
                }
                else
                {
                    pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showtopic.aspx?topicid=" + topicid.ToString(), 8);
                }
            }
            else
            {
                pagenumbers =
                    Utils.GetPageNumbers(pageid, pagecount, "showtopic.aspx?onlyauthor=1&topicid=" + topicid, 8);
            }


            //更新查看次数
            //Topics.UpdateTopicViews(topicid);
            TopicStats.Track(topicid, 1);

            OnlineUsers.UpdateAction(olid, UserAction.ShowTopic.ActionID, forumid, forumname, topicid, topictitle,
                                     config.Onlinetimeout);
            forumlistboxoptions = Caches.GetForumListBoxOptionsCache();

            //得到页码链接
            if (onlyauthor == "" || onlyauthor == "0")
            {
                ForumUtils.WriteCookie("referer",
                                       string.Format("showtopic.aspx?topicid={0}&page={1}", topicid.ToString(), pageid.ToString()));
            }
            else
            {
                ForumUtils.WriteCookie("referer",
                                       string.Format("showtopic.aspx?onlyauthor=1&topicid={0}&page={1}", topicid.ToString(), pageid.ToString()));
            }

            score = Scoresets.GetValidScoreName();
            scoreunit = Scoresets.GetValidScoreUnit();

            string oldtopic = ForumUtils.GetCookie("oldtopic") + "D";
            if (oldtopic.IndexOf("D" + topic.Tid.ToString() + "D") == -1 &&
                DateTime.Now.AddMinutes(-1 * 600) < DateTime.Parse(topic.Lastpost))
            {
                oldtopic = "D" + topic.Tid.ToString() + Utils.CutString(oldtopic, 0, oldtopic.Length - 1);
                if (oldtopic.Length > 3000)
                {
                    oldtopic = Utils.CutString(oldtopic, 0, 3000);
                    oldtopic = Utils.CutString(oldtopic, 0, oldtopic.LastIndexOf("D"));
                }
                ForumUtils.WriteCookie("oldtopic", oldtopic);
            }

            // 判断是否需要生成游客缓存页面
            if (userid == -1 && pageid == 1)
            {
                int topiccachemark = 100 -
                                     (int)
                                     (topic.Displayorder * 15 + topic.Digest * 10 + Math.Min(topic.Views / 20, 50) +
                                      Math.Min(topic.Replies / config.Ppp * 1.5, 15));
                if (topiccachemark < config.Topiccachemark)
                {
                    isguestcachepage = 1;
                }
            }



        }
Example #14
0
        protected override void ShowPage()
        {
            #region 临时帐号发帖
            int realuserid = -1;
            string tempusername = DNTRequest.GetString("tempusername");
            if (tempusername != "" && tempusername != username)
            {
                string temppassword = DNTRequest.GetString("temppassword");
                int question = DNTRequest.GetInt("question", 0);
                string answer = DNTRequest.GetString("answer");
                if (config.Passwordmode == 1)
                {
                    if (config.Secques == 1)
                    {
                        realuserid = Discuz.Forum.Users.CheckDvBbsPasswordAndSecques(tempusername, temppassword, question, answer);
                    }
                    else
                    {
                        realuserid = Discuz.Forum.Users.CheckDvBbsPassword(tempusername, temppassword);
                    }
                }
                else
                {
                    if (config.Secques == 1)
                    {
                        realuserid = Discuz.Forum.Users.CheckPasswordAndSecques(tempusername, temppassword, true, question, answer);
                    }
                    else
                    {
                        realuserid = Discuz.Forum.Users.CheckPassword(tempusername, temppassword, true);
                    }
                }
                if (realuserid == -1)
                {
                    AddErrLine("临时帐号登录失败,无法继续发帖。");
                    return;
                }
                else
                {
                    userid = realuserid;
                    username = tempusername;
                    usergroupinfo = UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(userid).Groupid);
                    usergroupid = usergroupinfo.Groupid;
                    useradminid = Discuz.Forum.Users.GetShortUserInfo(userid).Adminid;
                }
            }
            #endregion

            canhtmltitle = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup);
            firstpagesmilies = Caches.GetSmiliesFirstPageCache();
            bool createpoll = false;
            string[] pollitem = { };

            //内容设置为空;  
            message = "";
            //maxprice = usergroupinfo.Maxprice > Scoresets.GetMaxIncPerTopic() ? Scoresets.GetMaxIncPerTopic() : usergroupinfo.Maxprice;
            maxprice = usergroupinfo.Maxprice;

            forumid = DNTRequest.GetInt("forumid", -1);

            allowposttopic = true;

            if (forumid == -1)
            {
                allowposttopic = false;
                AddErrLine("错误的论坛ID");
                forumnav = "";
                return;
            }
            else
            {
                forum = Forums.GetForumInfo(forumid);
                if (forum == null || forum.Layer == 0)
                {
                    allowposttopic = false;
                    AddErrLine("错误的论坛ID");
                    forumnav = "";
                    return;
                }
                forumname = forum.Name;
                pagetitle = Utils.RemoveHtml(forum.Name);
                forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
                enabletag = (config.Enabletag & forum.Allowtag) == 1;
                if (forum.Applytopictype == 1)  //启用主题分类
                {
                    topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes);
                }
            }

            //得到用户可以上传的文件类型
            StringBuilder sbAttachmentTypeSelect = new StringBuilder();
            if (!usergroupinfo.Attachextensions.Trim().Equals(""))
            {
                sbAttachmentTypeSelect.Append("[id] in (");
                sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions);
                sbAttachmentTypeSelect.Append(")");
            }

            if (!forum.Attachextensions.Equals(""))
            {
                if (sbAttachmentTypeSelect.Length > 0)
                {
                    sbAttachmentTypeSelect.Append(" AND ");
                }
                sbAttachmentTypeSelect.Append("[id] in (");
                sbAttachmentTypeSelect.Append(forum.Attachextensions);
                sbAttachmentTypeSelect.Append(")");
            }
            attachextensions = Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString());
            attachextensionsnosize = Attachments.GetAttachmentTypeString(sbAttachmentTypeSelect.ToString());

            //得到今天允许用户上传的附件总大小(字节)
            int MaxTodaySize = 0;
            if (userid > 0)
            {
                MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid);		//今天已上传大小
            }
            attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;//今天可上传得大小



            StringBuilder sb = new StringBuilder();
            //sb.Append("var allowhtml=1;\r\n"); //+ allhtml.ToString() + "

            parseurloff = 0;

            smileyoff = 1 - forum.Allowsmilies;
            //sb.Append("var allowsmilies=" + (1-smileyoff).ToString() + ";\r\n");


            bbcodeoff = 1;
            if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1)
            {
                bbcodeoff = 0;
            }
            //sb.Append("var allowbbcode=" + (1-bbcodeoff).ToString() + ";\r\n");

            usesig = ForumUtils.GetCookie("sigstatus") == "0" ? 0 : 1;

            allowimg = forum.Allowimgcode;
            //sb.Append("var allowimgcode=" + allowimg.ToString() + ";\r\n");



            //AddScript(sb.ToString());


            // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖
            if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1)
            {
                string visittime = "";
                if (Scoresets.BetweenTime(config.Postbanperiods, out visittime))
                {
                    AddErrLine("在此时间段( " + visittime + " )内用户不可以发帖");
                    return;
                }
            }

            if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password"))
            {
                AddErrLine("本版块被管理员设置了密码");
                SetBackLink(base.ShowForumAspxRewrite(forumid, 0));
                return;
            }


            if (!Forums.AllowViewByUserID(forum.Permuserlist, userid)) //判断当前用户在当前版块浏览权限
            {
                if (string.IsNullOrEmpty(forum.Viewperm))//当板块权限为空时,按照用户组权限
                {
                    if (usergroupinfo.Allowvisit != 1)
                    {
                        AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该版块的权限");
                        needlogin = true;
                        return;
                    }
                }
                else//当板块权限不为空,按照板块权限
                {
                    if (!Forums.AllowView(forum.Viewperm, usergroupid))
                    {
                        AddErrLine("您没有浏览该版块的权限");
                        needlogin = true;
                        return;
                    }
                }
            }

            if (!Forums.AllowPostByUserID(forum.Permuserlist, userid)) //判断当前用户在当前版块发主题权限
            {
                if (forum.Postperm == null || forum.Postperm == string.Empty)//权限设置为空时,根据用户组权限判断
                {
                    // 验证用户是否有发表主题的权限
                    if (usergroupinfo.Allowpost != 1)
                    {
                        AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发表主题的权限");
                        needlogin = true;
                        return;
                    }
                }
                else//权限设置不为空时,根据板块权限判断
                {
                    if (!Forums.AllowPost(forum.Postperm, usergroupid))
                    {
                        AddErrLine("您没有在该版块发表主题的权限");
                        needlogin = true;
                        return;
                    }
                }
            }



            //是否有上传附件的权限
            if (Forums.AllowPostAttachByUserID(forum.Permuserlist, userid))
            {
                canpostattach = true;
            }
            else
            {
                if (forum.Postattachperm == "")
                {
                    if (usergroupinfo.Allowpostattach == 1)
                    {
                        canpostattach = true;
                    }
                }
                else
                {
                    if (Forums.AllowPostAttach(forum.Postattachperm, usergroupid))
                    {
                        canpostattach = true;
                    }
                }
            }

            ShortUserInfo user = Discuz.Forum.Users.GetShortUserInfo(userid);

            // 如果是受灌水限制用户, 则判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(useradminid);
            disablepost = 0;
            if (admininfo != null)
            {
                disablepost = admininfo.Disablepostctrl;
            }
            if (admininfo == null || admininfo.Disablepostctrl != 1)
            {

                int Interval = Utils.StrDateDiffSeconds(lastposttime, config.Postinterval);
                if (Interval < 0)
                {
                    AddErrLine("系统规定发帖间隔为" + config.Postinterval.ToString() + "秒, 您还需要等待 " + (Interval * -1).ToString() + " 秒");
                    return;
                }
                else if (userid != -1)
                {
                    string joindate = Discuz.Forum.Users.GetUserJoinDate(userid);
                    if (joindate == "")
                    {
                        AddErrLine("您的用户资料出现错误");
                        return;
                    }

                    Interval = Utils.StrDateDiffMinutes(joindate, config.Newbiespan);
                    if (Interval < 0)
                    {
                        AddErrLine("系统规定新注册用户必须要在" + config.Newbiespan.ToString() + "分钟后才可以发帖, 您还需要等待 " + (Interval * -1).ToString() + " 分");
                        return;
                    }

                }
            }


            creditstrans = Scoresets.GetCreditsTrans();
            userextcreditsinfo = Scoresets.GetScoreSet(creditstrans);

            //message = ForumUtils.GetCookie("postmessage");
            if (userid > 0)
            {
                spaceid = Discuz.Forum.Users.GetShortUserInfo(userid).Spaceid;
            }

            type = DNTRequest.GetString("type").ToLower();

            //int specialpost = 0;
            if (forum.Allowspecialonly > 0 && Utils.StrIsNullOrEmpty(type))
            {
                AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", forum.Name));
                return;
            }

            if (forum.Allowpostspecial > 0)
            {
                if (type == "poll" && (forum.Allowpostspecial & 1) != 1)
                {
                    AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表投票", forum.Name));
                    return;
                }

                if (type == "bonus" && (forum.Allowpostspecial & 4) != 4)
                {
                    AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表悬赏", forum.Name));
                    return;
                }
                if (type == "debate" && (forum.Allowpostspecial & 16) != 16)
                {
                    AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表辩论", forum.Name));
                    return;
                }
            }

            // 验证用户是否有发布投票的权限
            if (type == "poll" && usergroupinfo.Allowpostpoll != 1)
            {
                AddErrLine(string.Format("您当前的身份 \"{0}\" 没有发布投票的权限", usergroupinfo.Grouptitle));
                needlogin = true;
                return;
            }

            // 验证用户是否有发布悬赏的权限
            if (type == "bonus" && usergroupinfo.Allowbonus != 1)
            {
                AddErrLine(string.Format("您当前的身份 \"{0}\" 没有发布悬赏的权限", usergroupinfo.Grouptitle));
                needlogin = true;
                return;
            }

            // 验证用户是否有发起辩论的权限
            if (type == "debate" && usergroupinfo.Allowdebate != 1)
            {
                AddErrLine(string.Format("您当前的身份 \"{0}\" 没有发起辩论的权限", usergroupinfo.Grouptitle));
                needlogin = true;
                return;
            }

            if (type == "bonus")
            {
                //当“交易金币设置”有效时(1-8的整数):
                int creditTrans = Scoresets.GetCreditsTrans();
                if (creditTrans <= 0)
                {
                    AddErrLine(string.Format("系统未设置\"交易金币设置\", 无法判断当前要使用的(扩展)金币字段, 暂时无法发布悬赏", usergroupinfo.Grouptitle));
                    return;
                }
                mycurrenttranscredits = Discuz.Forum.Users.GetUserExtCredits(userid, creditTrans);
            }


            //如果不是提交...
            if (!ispost)
            {
                AddLinkCss("/templates/" + templatepath + "/editor.css", "css");

                smilies = Caches.GetSmiliesCache();
                smilietypes = Caches.GetSmilieTypesCache();
                customeditbuttons = Caches.GetCustomEditButtonList();
                topicicons = Caches.GetTopicIconsCache();
            }
            else
            {
                SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", forumid, type));

                string postmessage = DNTRequest.GetString("message");
                postmessage = postmessage.Replace(Shove._Web.Utility.GetUrl(), Discuz.Common.XmlConfig.GetCpsClubUrl().ToString());
                ForumUtils.WriteCookie("postmessage", postmessage);

                message = postmessage;

                #region 常规项验证

                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }


                if (forum.Applytopictype == 1 && forum.Postbytopictype == 1 && topictypeselectoptions != string.Empty)
                {
                    if (DNTRequest.GetString("typeid").Trim().Equals(""))
                    {
                        AddErrLine("主题类型不能为空");
                    }
                    //检测所选主题分类是否有效
                    if (!Forums.IsCurrentForumTopicType(DNTRequest.GetString("typeid").Trim(), forum.Topictypes))
                    {
                        AddErrLine("错误的主题类型");
                    }
                }
                if (DNTRequest.GetString("title").Trim().Equals(""))
                {
                    AddErrLine("标题不能为空");
                }
                else if (DNTRequest.GetString("title").IndexOf(" ") != -1)
                {
                    AddErrLine("标题不能包含全角空格符");
                }
                else if (DNTRequest.GetString("title").Length > 60)
                {
                    AddErrLine("标题最大长度为60个字符,当前为 " + DNTRequest.GetString("title").Length.ToString() + " 个字符");
                }

                if (postmessage.Equals(""))
                {
                    AddErrLine("内容不能为空");
                }

                if (admininfo != null && admininfo.Disablepostctrl != 1)
                {
                    if (postmessage.Length < config.Minpostsize)
                    {
                        AddErrLine("您发表的内容过少, 系统设置要求帖子内容不得少于 " + config.Minpostsize.ToString() + " 字多于 " + config.Maxpostsize.ToString() + " 字");
                    }
                    else if (postmessage.Length > config.Maxpostsize)
                    {
                        AddErrLine("您发表的内容过多, 系统设置要求帖子内容不得少于 " + config.Minpostsize.ToString() + " 字多于 " + config.Maxpostsize.ToString() + " 字");
                    }
                }



                //新用户广告强力屏蔽检查

                if ((config.Disablepostad == 1) && useradminid < 1 || userid == -1)  //如果开启新用户广告强力屏蔽检查或是游客
                {
                    if (userid == -1 || (config.Disablepostadpostcount != 0 && user.Posts <= config.Disablepostadpostcount) ||
                        (config.Disablepostadregminute != 0 && DateTime.Now.AddMinutes(-config.Disablepostadregminute) <= Convert.ToDateTime(user.Joindate)))
                    {
                        foreach (string regular in config.Disablepostadregular.Replace("\r", "").Split('\n'))
                        {
                            if (Posts.IsAD(regular, DNTRequest.GetString("title"), postmessage))
                            {
                                AddErrLine("发帖失败,内容中似乎有广告信息,请检查标题和内容,如有疑问请与管理员联系");
                                return;
                            }
                        }
                    }
                }


                if (IsErr())
                {
                    return;
                }



                // 如果用户上传了附件,则检测用户是否有上传附件的权限
                if (ForumUtils.IsPostFile())
                {
                    if (Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()).Trim() == "")
                    {
                        AddErrLine("系统不允许上传附件");
                    }

                    if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userid))
                    {
                        if (!Forums.AllowPostAttach(forum.Postattachperm, usergroupid))
                        {
                            AddErrLine("您没有在该版块上传附件的权限");
                        }
                        else if (usergroupinfo.Allowpostattach != 1)
                        {
                            AddErrLine(string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", usergroupinfo.Grouptitle));
                        }
                    }
                }

                #endregion

                #region 投票验证
                if (!DNTRequest.GetString("createpoll").Equals(""))
                {
                    // 验证用户是否有发布投票的权限
                    if (usergroupinfo.Allowpostpoll != 1)
                    {
                        AddErrLine(string.Format("您当前的身份 \"{0}\" 没有发布投票的权限", usergroupinfo.Grouptitle));
                        return;
                    }


                    createpoll = true;
                    pollitem = Utils.SplitString(DNTRequest.GetString("PollItemname"), "\r\n");
                    if (pollitem.Length < 2)
                    {
                        AddErrLine("投票项不得少于2个");
                    }
                    else if (pollitem.Length > config.Maxpolloptions)
                    {
                        AddErrLine(string.Format("系统设置为投票项不得多于{0}个", config.Maxpolloptions));
                    }
                    else
                    {
                        for (int i = 0; i < pollitem.Length; i++)
                        {
                            if (pollitem[i].Trim().Equals(""))
                            {
                                AddErrLine("投票项不能为空");
                            }
                        }
                    }

                    enddatetime = DNTRequest.GetString("enddatetime");
                    if (!Utils.IsDateString(enddatetime))
                    {
                        AddErrLine("投票结束日期格式错误");
                    }
                }
                #endregion

                bool isbonus = type == "bonus";

                #region 悬赏/售价验证

                int topicprice = 0;
                string tmpprice = DNTRequest.GetString("topicprice");

                if (Regex.IsMatch(tmpprice, "^[0-9]*[0-9][0-9]*$") || tmpprice == string.Empty)
                {
                    if (!isbonus)
                    {
                        topicprice = Utils.StrToInt(tmpprice, 0);

                        if (topicprice > maxprice && maxprice > 0)
                        {
                            if (userextcreditsinfo.Unit.Equals(""))
                            {
                                AddErrLine(string.Format("主题售价不能高于 {0} {1}", maxprice.ToString(), userextcreditsinfo.Name));
                            }
                            else
                            {
                                AddErrLine(string.Format("主题售价不能高于 {0} {1}({2})", maxprice.ToString(), userextcreditsinfo.Name, userextcreditsinfo.Unit));
                            }
                        }
                        else if (topicprice > 0 && maxprice <= 0)
                        {
                            AddErrLine(string.Format("您当前的身份 \"{0}\" 未被允许出售主题", usergroupinfo.Grouptitle));
                        }
                        else if (topicprice < 0)
                        {
                            AddErrLine("主题售价不能为负数");
                        }
                    }
                    else
                    {
                        topicprice = Utils.StrToInt(tmpprice, 0);

                        if (usergroupinfo.Allowbonus == 0)
                        {
                            AddErrLine(string.Format("您当前的身份 \"{0}\" 未被允许进行悬赏", usergroupinfo.Grouptitle));
                        }

                        if (topicprice < usergroupinfo.Minbonusprice || topicprice > usergroupinfo.Maxbonusprice)
                        {
                            AddErrLine(string.Format("悬赏价格超出范围, 您应在 {0} - {1} {2}{3} 范围内进行悬赏", usergroupinfo.Minbonusprice, usergroupinfo.Maxbonusprice,
                                userextcreditsinfo.Unit, userextcreditsinfo.Name));
                        }
                    }
                }
                else
                {
                    if (!isbonus)
                    {
                        AddErrLine("主题售价只能为整数");
                    }
                    else
                    {
                        AddErrLine("悬赏价格只能为整数");
                    }
                }
                #endregion

                string positiveopinion = DNTRequest.GetString("positiveopinion");
                string negativeopinion = DNTRequest.GetString("negativeopinion");
                string terminaltime = DNTRequest.GetString("terminaltime");

                if (type == "debate")
                {
                    if (usergroupinfo.Allowdebate != 1)
                    {
                        AddErrLine(string.Format("您当前的身份 \"{0}\" 没有发起辩论的权限", usergroupinfo.Grouptitle));
                        return;

                    }

                    if (positiveopinion == string.Empty)
                    {
                        AddErrLine("正方观点不能为空");
                    }
                    if (negativeopinion == string.Empty)
                    {
                        AddErrLine("反方观点不能为空");
                    }
                    if (!Utils.IsDateString(terminaltime))
                    {
                        AddErrLine("结束日期格式不正确");
                    }

                }

                if (IsErr())
                {
                    return;
                }


                int iconid = DNTRequest.GetInt("iconid", 0);
                if (iconid > 15 || iconid < 0)
                {
                    iconid = 0;
                }
                int hide = 1;
                //if (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1)
                //{
                //    hide = 1;
                //}

                string curdatetime = Utils.GetDateTime();

                TopicInfo topicinfo = new TopicInfo();
                topicinfo.Fid = forumid;
                topicinfo.Iconid = iconid;
                if (useradminid == 1)
                {
                    topicinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title"));
                    //message = Utils.HtmlEncode(postmessage);
                }
                else
                {
                    topicinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title")));
                    //message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage));
                }


                if (ForumUtils.HasBannedWord(topicinfo.Title) || ForumUtils.HasBannedWord(message))
                {
                    AddErrLine("对不起, 您提交的内容包含不良信息, 因此无法提交, 请返回修改!");
                    return;
                }

                topicinfo.Typeid = DNTRequest.GetInt("typeid", 0);
                if (usergroupinfo.Allowsetreadperm == 1)
                {
                    int topicreadperm = DNTRequest.GetInt("topicreadperm", 0);
                    topicreadperm = topicreadperm > 255 ? 255 : topicreadperm;
                    topicinfo.Readperm = topicreadperm;
                }
                else
                {
                    topicinfo.Readperm = 0;
                }
                topicinfo.Price = topicprice;
                topicinfo.Poster = username;
                topicinfo.Posterid = userid;
                topicinfo.Postdatetime = curdatetime;
                topicinfo.Lastpost = curdatetime;
                topicinfo.Lastposter = username;
                topicinfo.Views = 0;
                topicinfo.Replies = 0;

                if (forum.Modnewposts == 1 && useradminid != 1)
                {
                    if (useradminid > 1)
                    {
                        if (disablepost == 1)
                        {
                            topicinfo.Displayorder = 0;
                        }
                        else
                        {
                            topicinfo.Displayorder = -2;
                        }
                    }
                    else
                    {
                        topicinfo.Displayorder = -2;
                    }
                }
                else
                {
                    topicinfo.Displayorder = 0;
                }

                if (useradminid != 1)
                {
                    if (Scoresets.BetweenTime(config.Postmodperiods) || ForumUtils.HasAuditWord(topicinfo.Title) || ForumUtils.HasAuditWord(message))
                    {
                        topicinfo.Displayorder = -2;
                    }
                }


                topicinfo.Highlight = "";
                topicinfo.Digest = 0;
                topicinfo.Rate = 0;
                topicinfo.Hide = hide;
                //topicinfo.Poll = 0;
                topicinfo.Attachment = 0;
                topicinfo.Moderated = 0;
                topicinfo.Closed = 0;

                string htmltitle = DNTRequest.GetString("htmltitle").Trim();
                if (htmltitle != string.Empty && Utils.HtmlDecode(htmltitle).Trim() != topicinfo.Title)
                {
                    topicinfo.Magic = 11000;
                    //按照  附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储
                    //例: 11001
                }

                //标签(Tag)操作                
                string tags = DNTRequest.GetString("tags").Trim();
                string[] tagArray = null;
                if (enabletag && tags != string.Empty)
                {
                    tagArray = Utils.SplitString(tags, " ", true, 2, 10);
                    if (tagArray.Length > 0 && tagArray.Length <= 5)
                    {
                        if (topicinfo.Magic == 0)
                        {
                            topicinfo.Magic = 10000;
                        }
                        topicinfo.Magic = Utils.StrToInt(topicinfo.Magic.ToString() + "1", 0);
                    }
                    else
                    {

                        AddErrLine("超过标签数的最大限制,最多可填写 5 个标签");
                        return;
                    }
                }

                if (isbonus)
                {
                    topicinfo.Special = 2;

                    //检查金币是否足够
                    if (mycurrenttranscredits < topicprice)
                    {
                        AddErrLine("您的金币不足, 无法进行悬赏");
                        return;
                    }
                    else
                    {
                        Discuz.Forum.Users.UpdateUserExtCredits(topicinfo.Posterid, Scoresets.GetCreditsTrans(), -topicprice);
                    }
                }

                if (type == "poll")
                {
                    topicinfo.Special = 1;
                }
                //辩论帖
                if (type == "debate")
                {
                    topicinfo.Special = 4;
                }

                int topicid = Topics.CreateTopic(topicinfo);
                //保存htmltitle
                if (canhtmltitle && htmltitle != string.Empty && htmltitle != topicinfo.Title)
                {
                    Topics.WriteHtmlTitleFile(htmltitle, topicid);
                }

                if (enabletag && tagArray != null && tagArray.Length > 0)
                {
                    if (ForumUtils.HasBannedWord(tags))
                    {
                        AddErrLine("标签中含有系统禁止词语,请修改");
                        return;
                    }

                    ForumTags.CreateTopicTags(tagArray, topicid, userid, curdatetime);
                }

                if (type == "debate")
                {
                    DebateInfo debatetopic = new DebateInfo();
                    debatetopic.Tid = topicid;
                    debatetopic.Positiveopinion = positiveopinion;
                    debatetopic.Negativeopinion = negativeopinion;
                    //debatetopic.Positivecolor = DNTRequest.GetString("positivecolor");
                    //debatetopic.Negativecolor = DNTRequest.GetString("negativecolor");
                    debatetopic.Terminaltime = Convert.ToDateTime(DNTRequest.GetString("terminaltime"));
                    Topics.AddDebateTopic(debatetopic);
                }

                PostInfo postinfo = new PostInfo();
                postinfo.Fid = forumid;
                postinfo.Tid = topicid;
                postinfo.Parentid = 0;
                postinfo.Layer = 0;
                postinfo.Poster = username;
                postinfo.Posterid = userid;
                if (useradminid == 1)
                {
                    postinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title"));
                }
                else
                {
                    postinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title")));
                }

                postinfo.Postdatetime = curdatetime;
                postinfo.Message = message.Replace("<hide>","[hide]").Replace("</hide>","[/hide]");
                postinfo.Ip = DNTRequest.GetIP();
                postinfo.Lastedit = "";

                if (ForumUtils.HasAuditWord(postinfo.Message))
                {
                    postinfo.Invisible = 1;
                }

                if (forum.Modnewposts == 1 && useradminid != 1)
                {
                    if (useradminid > 1)
                    {
                        if (disablepost == 1)
                        {
                            postinfo.Invisible = 0;
                        }
                        else
                        {
                            postinfo.Invisible = 1;
                        }
                    }
                    else
                    {
                        postinfo.Invisible = 1;
                    }
                }
                else
                {
                    postinfo.Invisible = 0;
                }
                // 如果当前用户非管理员并且论坛设定了发帖审核时间段,当前时间如果在其中的一个时间段内,则用户所发帖均为待审核状态
                if (useradminid != 1)
                {
                    if (Scoresets.BetweenTime(config.Postmodperiods))
                    {
                        postinfo.Invisible = 0;
                    }
                }



                postinfo.Usesig = Utils.StrToInt(DNTRequest.GetString("usesig"), 0);
                postinfo.Htmlon = 1;

                postinfo.Smileyoff = smileyoff;
                if (smileyoff == 0 && forum.Allowsmilies == 1)
                {
                    postinfo.Smileyoff = Utils.StrToInt(DNTRequest.GetString("smileyoff"), 0);
                }

                postinfo.Bbcodeoff = 1;
                if (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1)
                {
                    postinfo.Bbcodeoff = Utils.StrToInt(DNTRequest.GetString("bbcodeoff"), 0);
                }
                postinfo.Parseurloff = Utils.StrToInt(DNTRequest.GetString("parseurloff"), 0);
                postinfo.Attachment = 0;
                postinfo.Rate = 0;
                postinfo.Ratetimes = 0;
                postinfo.Topictitle = topicinfo.Title;

                int postid = 0;

                try
                {
                    postid = Posts.CreatePost(postinfo);
                }
                catch
                {
                    TopicAdmins.DeleteTopics(topicid.ToString(), false);
                    AddErrLine("帖子保存出现异常");
                    return;
                }

                Topics.AddParentForumTopics(forum.Parentidlist.Trim(), 1, 1);


                //设置用户的金币
                ///首先读取版块内自定义金币
                ///版设置了自定义金币则使用,否则使用论坛默认金币
                float[] values = null;
                if (!forum.Postcredits.Equals(""))
                {
                    int index = 0;
                    float tempval = 0;
                    values = new float[8];
                    foreach (string ext in Utils.SplitString(forum.Postcredits, ","))
                    {

                        if (index == 0)
                        {
                            if (!ext.Equals("True"))
                            {
                                values = null;
                                break;
                            }
                            index++;
                            continue;
                        }
                        tempval = Utils.StrToFloat(ext, 0);
                        values[index - 1] = tempval;
                        index++;
                        if (index > 8)
                        {
                            break;
                        }
                    }
                }

                //if (values != null)
                //{
                //    ///使用版块内金币
                //    UserCredits.UpdateUserCreditsByPostTopic(userid, values);
                //}
                //else
                //{
                //    ///使用默认金币
                //    UserCredits.UpdateUserCreditsByPostTopic(userid);
                //}

                StringBuilder itemvaluelist = new StringBuilder("");
                if (createpoll)
                {
                    // 生成以回车换行符为分割的项目与结果列
                    for (int i = 0; i < pollitem.Length; i++)
                    {
                        itemvaluelist.Append("0\r\n");
                    }

                    string PollItemname = Utils.HtmlEncode(DNTRequest.GetFormString("PollItemname"));
                    if (PollItemname != "")
                    {
                        int multiple = DNTRequest.GetString("multiple") == "on" ? 1 : 0;
                        int maxchoices = 0;
                        if (multiple <= 0)
                        {
                            multiple = 0;
                        }

                        if (multiple == 1)
                        {
                            maxchoices = DNTRequest.GetInt("maxchoices", 1);
                            if (maxchoices > pollitem.Length)
                            {
                                maxchoices = pollitem.Length;
                            }
                        }

                        if (!Polls.CreatePoll(topicid, multiple, pollitem.Length, PollItemname.Trim(), itemvaluelist.ToString().Trim(), enddatetime, userid, maxchoices, DNTRequest.GetString("visiblepoll") == "on" ? 1 : 0))
                        {
                            AddErrLine("投票错误");
                            return;
                        }
                    }
                    else
                    {
                        AddErrLine("投票项为空");
                        return;
                    }
                }


                sb = new StringBuilder();
                sb.Remove(0, sb.Length);

                int watermarkstatus = config.Watermarkstatus;
                if (forum.Disablewatermark == 1)
                {
                    watermarkstatus = 0;
                }
                AttachmentInfo[] attachmentinfo = ForumUtils.SaveRequestFiles(forumid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstatus, config, "postfile");
                if (attachmentinfo != null)
                {
                    if (attachmentinfo.Length > config.Maxattachments)
                    {
                        AddErrLine("系统设置为每个帖子附件不得多于" + config.Maxattachments + "个");
                        return;
                    }
                    int errorAttachment = Attachments.BindAttachment(attachmentinfo, postid, sb, topicid, userid);
                    int[] aid = Attachments.CreateAttachments(attachmentinfo);
                    string tempMessage = Attachments.FilterLocalTags(aid, attachmentinfo, postinfo.Message);

                    if (!tempMessage.Equals(postinfo.Message))
                    {
                        postinfo.Message = tempMessage;
                        postinfo.Pid = postid;
                        Posts.UpdatePost(postinfo);
                    }

                    UserCredits.UpdateUserCreditsByUploadAttachment(userid, aid.Length - errorAttachment);
                }

                OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forumname, -1, "", config.Onlinetimeout);
                // 更新在线表中的用户最后发帖时间
                OnlineUsers.UpdatePostTime(olid);

                if (sb.Length > 0)
                {
                    SetUrl(base.ShowTopicAspxRewrite(topicid, 0));
                    SetMetaRefresh(5);
                    SetShowBackLink(true);
                    sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表主题成功,但以下附件上传失败:</nobr></span><br /></td></tr>");
                    sb.Append("</table>");
                    AddMsgLine(sb.ToString());
                }
                else
                {

                    SetShowBackLink(false);
                    if (useradminid != 1)
                    {
                        bool needaudit = false; //是否需要审核

                        if (Scoresets.BetweenTime(config.Postmodperiods))
                        {
                            needaudit = true;
                        }
                        else
                        {
                            if (forum.Modnewposts == 1 && useradminid != 1)
                            {
                                if (useradminid > 1)
                                {
                                    if (disablepost == 1 && topicinfo.Displayorder != -2)
                                    {
                                        if (useradminid == 3 && !Moderators.IsModer(useradminid, userid, forumid))
                                        {
                                            needaudit = true;
                                        }
                                        else
                                        {
                                            needaudit = false;
                                        }
                                    }
                                    else
                                    {
                                        needaudit = true;
                                    }
                                }
                                else
                                {
                                    needaudit = true;
                                }
                            }
                            else
                            {
                                if (useradminid != 1 && topicinfo.Displayorder == -2)
                                {
                                    needaudit = true;
                                }
                            }
                        }
                        if (needaudit)
                        {
                            SetUrl(base.ShowForumAspxRewrite(forumid, 0));
                            SetMetaRefresh();
                            AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块");
                        }
                        else
                        {
                            PostTopicSucceed(values, topicinfo, topicid);
                        }
                    }
                    else
                    {
                        PostTopicSucceed(values, topicinfo, topicid);
                    }
                }
                ForumUtils.WriteCookie("postmessage", "");


                //如果已登录就不需要再登录
                if (needlogin && userid > 0)
                    needlogin = false;
            }
        }
Example #15
0
 /// <summary>
 /// 更新辩论信息
 /// </summary>
 /// <param name="debateInfo">辩论信息</param>
 /// <returns></returns>
 public static bool UpdateDebateTopic(DebateInfo debateInfo)
 {
     if (debateInfo.Tid <= 0)
         return false;
     return Discuz.Data.Debates.UpdateDebateTopic(debateInfo);
 }