예제 #1
0
파일: Debates.cs 프로젝트: xiongeee/BBX
        private static StringBuilder IsValidDebates(int tid, string message, bool ispost)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
            if (!ispost || ForumUtils.IsCrossSitePost())
            {
                stringBuilder.Append("<error>您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。</error>");
                return(stringBuilder);
            }
            Regex           regex           = new Regex("\\[area=([\\s\\S]+?)\\]([\\s\\S]+?)\\[/area\\]", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            MatchCollection matchCollection = regex.Matches(message);

            if (matchCollection.Count == 0)
            {
                stringBuilder.Append("<error>评论内容不能为空</error>");
                return(stringBuilder);
            }
            var topicInfo = Topic.FindByID(tid);

            if (tid == 0 || topicInfo.Special != 4)
            {
                stringBuilder.Append("<error>本主题不是辩论帖,无法点评</error>");
                return(stringBuilder);
            }
            var db = Debate.FindByTid(tid);

            if (db.TerminalTime > DateTime.Now)
            {
                stringBuilder.Append("<error>本辩论帖结束时间未到,无法点评</error>");
                return(stringBuilder);
            }
            return(stringBuilder);
        }
예제 #2
0
파일: postreply.cs 프로젝트: xiongeee/BBX
        //private void UpdateTopicInfo(string postmessage)
        //{
        //	int num = (ForumUtils.IsHidePost(postmessage) && this.usergroupinfo.AllowHideCode) ? 1 : 0;
        //	if (num == 1 && this.topic.Hide != 1)
        //	{
        //		this.topic.Hide = num;
        //		Topics.UpdateTopicHide(this.topicid);
        //	}
        //	if (Moderators.IsModer(this.useradminid, this.userid, this.topic.Fid) && this.topic.Attention == 1)
        //	{
        //		Topic.UpdateTopicAttentionByTidList(0, topicid);
        //	}
        //	else
        //	{
        //		if (this.topic.PosterID != -1 && this.userid == this.topic.PosterID)
        //		{
        //			Topic.UpdateTopicAttentionByTidList(1, topicid);
        //		}
        //	}
        //	Topics.UpdateTopicReplyCount(this.topicid);
        //}

        private void NormalValidate(AdminGroup admininfo, string postmessage, IUser user)
        {
            if (ForumUtils.IsCrossSitePost())
            {
                base.AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                return;
            }
            if (this.posttitle.Length > 60)
            {
                base.AddErrLine("标题最大长度为60个字符,当前为 " + this.posttitle.Length + " 个字符");
            }
            if (Utils.StrIsNullOrEmpty(postmessage.Replace("\u3000", "")))
            {
                base.AddErrLine("内容不能为空");
            }
            if (admininfo != null && !admininfo.DisablePostctrl)
            {
                if (postmessage.Length < this.config.Minpostsize)
                {
                    base.AddErrLine("您发表的内容过少, 系统设置要求帖子内容不得少于 " + this.config.Minpostsize + " 字多于 " + this.config.Maxpostsize + " 字");
                }
                else
                {
                    if (postmessage.Length > this.config.Maxpostsize)
                    {
                        base.AddErrLine("您发表的内容过多, 系统设置要求帖子内容不得少于 " + this.config.Minpostsize + " 字多于 " + this.config.Maxpostsize + " 字");
                    }
                }
            }
            if (this.topic.Special == 4 && DNTRequest.GetInt("debateopinion", 0) == 0)
            {
                base.AddErrLine("请选择您在辩论中的观点");
            }
            if (this.topic.Special == 4)
            {
                var debateTopic = Debate.FindByTid(this.topic.ID);
                if (debateTopic.Terminaled)
                {
                    base.AddErrLine("此辩论主题已经到期");
                }
            }
            if (this.config.DisablePostAD && this.useradminid < 1 && ((this.config.DisablePostADPostCount != 0 && user.Posts <= this.config.DisablePostADPostCount) || (this.config.DisablePostADRegMinute != 0 && DateTime.Now.AddMinutes((double)(-(double)this.config.DisablePostADRegMinute)) <= user.JoinDate.ToDateTime())))
            {
                string[] array = this.config.DisablePostADRegular.Replace("\r", "").Split('\n');
                for (int i = 0; i < array.Length; i++)
                {
                    string regular = array[i];
                    if (Posts.IsAD(regular, this.posttitle, postmessage))
                    {
                        base.AddErrLine("发帖失败,内容中有不符合新用户强力广告屏蔽规则的字符,请检查标题和内容,如有疑问请与管理员联系");
                    }
                }
            }
        }
예제 #3
0
파일: Debates.cs 프로젝트: xiongeee/BBX
        private static List <Post> GetDebatePostList(PostpramsInfo pi, out List <Attachment> attachList, bool isModer, int debateOpinion, PostOrderType postOrderType)
        {
            var sb = new StringBuilder();
            //var list = BBX.Data.Debates.GetDebatePostList(pi, debateOpinion, postOrderType);
            var list = Post.SearchDebate(pi.Tid, debateOpinion, (pi.Pageindex - 1) * pi.Pagesize, pi.Pagesize);

            if (list.Count == 0 && pi.Pageindex > 1)
            {
                //var count = BBX.Data.Debates.GetRealDebatePostCount(pi.Tid, debateOpinion);
                var count = Post.SearchDebateCount(pi.Tid, debateOpinion);
                pi.Pageindex = ((count % pi.Pagesize == 0) ? (count / pi.Pagesize) : (count / pi.Pagesize + 1));
                //list = BBX.Data.Debates.GetDebatePostList(pi, debateOpinion, postOrderType);
                list = Post.SearchDebate(pi.Tid, debateOpinion, (pi.Pageindex - 1) * pi.Pagesize, pi.Pagesize);
            }
            var list2 = list.ToList();
            // 设置楼层
            var start = (pi.Pageindex - 1) * pi.Pagesize;
            var db    = Debate.FindByTid(pi.Tid);

            foreach (var item in list2)
            {
                item.Id = ++start;

                if (db != null)
                {
                    db.CastTo(item);
                }
            }

            var sb2           = new StringBuilder();
            int inPostAdCount = Advertisement.GetInPostAdCount("", pi.Fid);

            foreach (var item in list2)
            {
                Posts.LoadExtraPostInfo(item, inPostAdCount);
                sb.AppendFormat("{0},", item.ID);
                if (item.Attachment > 0)
                {
                    sb2.AppendFormat("{0},", item.ID);
                }
            }
            attachList = Attachments.GetAttachmentList(pi, sb2.ToString().TrimEnd(','));
            var postDiggs = Debates.GetPostDiggs(sb.ToString().Trim(','));

            foreach (var item in list2)
            {
                if (postDiggs.ContainsKey(item.ID))
                {
                    item.Diggs = postDiggs[item.ID];
                }
            }
            Posts.ParsePostListExtraInfo(pi, attachList, isModer, list2);
            return(list2);
        }
예제 #4
0
 public void GetDebateInfo()
 {
     this.debateexpand = Debate.FindByTid(this.topicid);
     this.debateList   = Debates.GetPostDebateList(this.topicid);
     if (this.debateexpand.Terminaled)
     {
         this.isenddebate = true;
         if (this.isenddebate)
         {
             this.canreply = false;
         }
     }
     foreach (var item in this.postlist)
     {
         if (this.debateList != null && this.debateList.ContainsKey(item.ID))
         {
             item.Debateopinion = this.debateList[item.ID];
         }
     }
 }
예제 #5
0
파일: editpost.cs 프로젝트: xiongeee/BBX
        protected override void ShowPage()
        {
            var adminGroupInfo = AdminGroup.FindByID(this.usergroupid);

            this.disablepostctrl = false;
            if (adminGroupInfo != null)
            {
                this.disablepostctrl = adminGroupInfo.DisablePostctrl;
            }
            if (this.userid == -1)
            {
                this.forum    = new XForum();
                this.topic    = new Topic();
                this.postinfo = new Post();
                base.AddErrLine("您尚未登录");
                return;
            }
            if (this.postid == -1)
            {
                base.AddErrLine("无效的帖子ID");
                return;
            }
            //this.postinfo = Posts.GetPostInfo(this.topicid, this.postid);
            postinfo = Post.FindByID(postid);
            if (this.postinfo == null)
            {
                base.AddErrLine("不存在的帖子ID");
                return;
            }
            this.pagetitle   = ((String.IsNullOrEmpty(this.postinfo.Title)) ? "编辑帖子" : this.postinfo.Title);
            this.htmlon      = this.postinfo.HtmlOn;
            this.message     = this.postinfo.Message;
            this.isfirstpost = (this.postinfo.Layer == 0);
            if (this.topicid != this.postinfo.Tid || this.postinfo.Tid == -1)
            {
                base.AddErrLine("无效的主题ID");
                return;
            }
            //this.topic = Topics.GetTopicInfo(this.postinfo.Tid);
            topic = Topic.FindByID(postinfo.Tid);
            if (this.topic == null)
            {
                base.AddErrLine("不存在的主题ID");
                return;
            }
            if (this.topic.Special == 1 && this.postinfo.Layer == 0)
            {
                //修改为Xcode方法
                this.pollinfo       = Poll.FindByTid(topic.ID);
                this.polloptionlist = PollOption.FindAllByTid(topic.ID);
            }
            if (this.topic.Special == 4 && this.postinfo.Layer == 0)
            {
                this.debateinfo = Debate.FindByTid(this.topic.ID);
            }
            this.forumid   = this.topic.Fid;
            this.forum     = Forums.GetForumInfo(this.forumid);
            this.needaudit = UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo, this.topic);
            if (this.forum == null || this.forum.Layer == 0)
            {
                base.AddErrLine("版块已不存在");
                this.forum = new XForum();
                return;
            }
            if (!this.forum.Password.IsNullOrEmpty() && Utils.MD5(this.forum.Password) != ForumUtils.GetCookie("forum" + this.forumid + "password"))
            {
                base.AddErrLine("本版块被管理员设置了密码");
                base.SetBackLink(base.ShowForumAspxRewrite(this.forumid, 0));
                return;
            }
            if (this.forum.ApplytopicType == 1)
            {
                this.topictypeselectoptions = Forums.GetCurrentTopicTypesOption(this.forum.Fid, this.forum.Topictypes);
            }
            this.customeditbuttons = Caches.GetCustomEditButtonList();
            if (!UserAuthority.CanEditPost(this.postinfo, this.userid, this.useradminid, ref this.msg))
            {
                base.AddErrLine(this.msg);
                return;
            }
            //string allowAttachmentType = Attachments.GetAllowAttachmentType(this.usergroupinfo, this.forum);
            this.attachextensions       = AttachType.GetAttachmentTypeArray(usergroupinfo, forum);
            this.attachextensionsnosize = AttachType.GetAttachmentTypeString(usergroupinfo, forum);
            int num = (this.userid > 0) ? Attachment.GetUploadFileSizeByuserid(this.userid) : 0;

            this.attachsize      = this.usergroupinfo.MaxSizeperday - num;
            this.canpostattach   = UserAuthority.PostAttachAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg);
            this.userinfo        = BBX.Entity.User.FindByID(this.userid);
            this.attachmentlist  = Attachment.FindAllByPid(this.postinfo.ID);
            this.attachmentcount = this.attachmentlist.Count;
            this.allowviewattach = UserAuthority.DownloadAttachment(this.forum, this.userid, this.usergroupinfo);
            this.smileyoff       = ((!DNTRequest.IsPost()) ? this.postinfo.SmileyOff : (forum.AllowSmilies ? 0 : 1));
            //this.allowimg = this.forum.Allowimgcode;
            this.parseurloff        = this.postinfo.ParseUrlOff;
            this.bbcodeoff          = this.usergroupinfo.AllowCusbbCode ? this.postinfo.BBCodeOff : 1;
            this.usesig             = this.postinfo.UseSig;
            this.userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
            if (this.bonusCreditsTrans > 0 && this.bonusCreditsTrans < 9)
            {
                this.bonusextcreditsinfo = Scoresets.GetScoreSet(this.bonusCreditsTrans);
                this.mybonustranscredits = Users.GetUserExtCredits(this.userid, this.bonusCreditsTrans);
            }
            if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
            {
                base.AddErrLine(this.msg);
                return;
            }
            if (!Moderators.IsModer(this.useradminid, this.userid, this.forumid))
            {
                if (this.postinfo.PosterID != this.userid)
                {
                    base.AddErrLine("你并非作者, 且你当前的身份 \"" + this.usergroupinfo.GroupTitle + "\" 没有修改该帖的权限");
                    return;
                }
                if (this.config.Edittimelimit > 0 && this.postinfo.PostDateTime.AddMinutes(this.config.Edittimelimit) < DateTime.Now)
                {
                    base.AddErrLine("抱歉, 系统规定只能在帖子发表" + this.config.Edittimelimit + "分钟内才可以修改");
                    return;
                }
                if (this.config.Edittimelimit == -1)
                {
                    base.AddErrLine("抱歉,系统不允许修改帖子");
                    return;
                }
                this.alloweditpost = true;
            }
            else
            {
                if (adminGroupInfo != null && adminGroupInfo.AllowEditPost && Moderators.IsModer(this.useradminid, this.userid, this.forumid))
                {
                    this.alloweditpost = true;
                }
            }
            if (!this.alloweditpost && this.postinfo.PosterID != this.userid)
            {
                base.AddErrLine("您当前的身份没有编辑帖子的权限");
                return;
            }
            if (this.postinfo.Layer == 0)
            {
                this.canhtmltitle = this.usergroupinfo.AllowHtmlTitle;
            }
            if (Topics.GetMagicValue(this.topic.Magic, MagicType.HtmlTitle) == 1)
            {
                this.htmltitle = Topics.GetHtmlTitle(this.topic.ID).Replace("\"", "\\\"").Replace("'", "\\'");
            }
            this.enabletag = config.Enabletag && forum.AllowTag;
            if (this.enabletag && Topics.GetMagicValue(this.topic.Magic, MagicType.TopicTag) == 1)
            {
                foreach (var item in Tag.GetTagsListByTopic(this.topic.ID))
                {
                    if (item.OrderID > -1)
                    {
                        this.topictags += string.Format(" {0}", item.Name);
                    }
                }
                this.topictags = this.topictags.Trim();
            }
            this.userGroupInfoList.Sort((x, y) => x.Readaccess - y.Readaccess + (y.ID - x.ID));
            if (this.ispost)
            {
                base.SetBackLink("editpost.aspx?topicid=" + this.postinfo.Tid + "&postid=" + this.postinfo.ID);
                if (ForumUtils.IsCrossSitePost())
                {
                    base.AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }
                this.SetPostInfo(adminGroupInfo, this.userinfo, DNTRequest.GetString("htmlon").ToInt(0) == 1);
                if (base.IsErr())
                {
                    return;
                }
                //Posts.UpdatePost(this.postinfo);
                postinfo.Update();
                var stringBuilder = this.SetAttachmentInfo();
                if (base.IsErr())
                {
                    return;
                }
                CreditsFacade.UpdateUserCredits(this.userid);
                string url;
                if (this.topic.Special == 4)
                {
                    url = Urls.ShowTopicAspxRewrite(this.topic.ID, this.pageid);
                }
                else
                {
                    if (DNTRequest.GetQueryString("referer") != "")
                    {
                        url = string.Format("showtopic.aspx?page=end&forumpage={2}&topicid={0}#{1}", this.topic.ID, this.postinfo.ID, this.forumpageid);
                    }
                    else
                    {
                        if (this.pageid > 1)
                        {
                            if (this.config.Aspxrewrite == 1)
                            {
                                url = string.Format("showtopic-{0}-{2}{1}#{3}", new object[]
                                {
                                    this.topic.ID,
                                    this.config.Extname,
                                    this.pageid,
                                    this.postinfo.ID
                                });
                            }
                            else
                            {
                                url = string.Format("showtopic.aspx?topicid={0}&forumpage={3}&page={2}#{1}", new object[]
                                {
                                    this.topic.ID,
                                    this.postinfo.ID,
                                    this.pageid,
                                    this.forumpageid
                                });
                            }
                        }
                        else
                        {
                            if (this.config.Aspxrewrite == 1)
                            {
                                url = string.Format("showtopic-{0}{1}", this.topic.ID, this.config.Extname);
                            }
                            else
                            {
                                url = string.Format("showtopic.aspx?topicid={0}&forumpage={1}", this.topic.ID, this.forumpageid);
                            }
                        }
                    }
                }
                base.SetUrl(url);
                if (stringBuilder.Length > 0)
                {
                    base.SetMetaRefresh(5);
                    base.SetShowBackLink(true);
                    if (this.infloat == 1)
                    {
                        base.AddErrLine(stringBuilder.ToString());
                        return;
                    }
                    stringBuilder.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>编辑帖子成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>");
                    stringBuilder.Append("</table>");
                    base.AddMsgLine(stringBuilder.ToString());
                }
                else
                {
                    if (this.postinfo.Layer == 0)
                    {
                        base.SetMetaRefresh(2, url);
                    }
                    else
                    {
                        base.SetMetaRefresh();
                    }
                    base.SetShowBackLink(false);
                    if (this.useradminid != 1 && (this.needaudit || this.topic.DisplayOrder == -2 || this.postinfo.Invisible == 1))
                    {
                        if (this.postinfo.Layer == 0)
                        {
                            base.SetUrl(base.ShowForumAspxRewrite(this.forumid, this.forumpageid));
                        }
                        else
                        {
                            base.SetUrl(base.ShowTopicAspxRewrite(this.topic.ID, this.forumpageid));
                        }
                        base.AddMsgLine("编辑成功, 但需要经过审核才可以显示");
                    }
                    else
                    {
                        base.MsgForward("editpost_succeed");
                        base.AddMsgLine("编辑帖子成功, 返回该主题");
                    }
                }
                if (this.postinfo.Layer == 0)
                {
                    ForumUtils.DeleteTopicCacheFile(this.topic.ID);
                    return;
                }
            }
            else
            {
                base.AddLinkCss(BaseConfigs.GetForumPath + "templates/" + this.templatepath + "/editor.css", "css");
            }
        }