예제 #1
0
        protected override void ShowPage()
        {
            #region 临时帐号发帖
            //int realuserid = -1;
            //bool tempaccountspost = false;
            //string tempusername = DNTRequest.GetString("tempusername");
            //if (!Utils.StrIsNullOrEmpty(tempusername) && tempusername != username)
            //{
            //    realuserid = Users.CheckTempUserInfo(tempusername, DNTRequest.GetString("temppassword"), DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer"));
            //    if (realuserid == -1)
            //    {
            //        AddErrLine("临时帐号登录失败,无法继续发帖。");
            //        return;
            //    }
            //    else
            //    {
            //        userid = realuserid;
            //        username = tempusername;
            //        tempaccountspost = true;
            //    }
            //}
            #endregion

            if (userid > 0)
            {
                userinfo = Users.GetShortUserInfo(userid);
            }

            #region 判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            if (admininfo != null)
            {
                disablepost = admininfo.Disablepostctrl;
            }

            if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, userinfo, ref msg))
            {
                AddErrLine(msg); return;
            }
            #endregion

            //获取主题帖信息
            PostInfo postinfo = GetPostAndTopic(admininfo);
            if (IsErr())
            {
                return;
            }

            forum     = Forums.GetForumInfo(forumid);
            smileyoff = 1 - forum.Allowsmilies;
            bbcodeoff = (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) ? 0 : 1;
            allowimg  = forum.Allowimgcode;
            needaudit = UserAuthority.NeedAudit(forum, useradminid, topic, userid, disablepost, usergroupinfo);
            #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);

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

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

            #region 访问和发帖权限校验
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                needlogin = true;
                return;
            }
            if (!UserAuthority.PostReply(forum, userid, usergroupinfo, topic))
            {
                AddErrLine(topic.Closed == 1 ? "主题已关闭无法回复" : "您没有发表回复的权限");
                needlogin = (topic.Closed == 1 ? false : true);
                return;
            }

            if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, userinfo, ref msg))
            {
                AddErrLine(msg);
                return;
            }
            #endregion

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

            if (forum.Templateid > 0)
            {
                templatepath = Templates.GetTemplateItem(forum.Templateid).Directory;
            }

            AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
            //如果是提交...
            if (ispost)
            {
                string backlink = (DNTRequest.GetInt("topicid", -1) > 0 ?
                                   string.Format("postreply.aspx?topicid={0}&restore=1&forumpage=" + forumpageid, topicid) :
                                   string.Format("postreply.aspx?postid={0}&restore=1&forumpage=" + forumpageid, postid));

                if (!DNTRequest.GetString("quote").Equals(""))
                {
                    backlink = string.Format("{0}&quote={1}", backlink, DNTRequest.GetString("quote"));
                }

                SetBackLink(backlink);

                #region 验证提交信息
                //常规项验证
                NormalValidate(admininfo, postmessage, userinfo);

                if (IsErr())
                {
                    return;
                }
                #endregion

                //是否有上传附件的权限
                canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg);

                // 产生新帖子
                if (!string.IsNullOrEmpty(DNTRequest.GetFormString("toreplay_user").Trim()))
                {
                    postmessage = DNTRequest.GetFormString("toreplay_user").Trim() + "\n\n" + postmessage;
                }

                postinfo = CreatePostInfo(postmessage);

                //获取被回复帖子的作者uid
                int replyUserid = postid > 0 ? Posts.GetPostInfo(topicid, postid).Posterid : postinfo.Posterid;
                postid = postinfo.Pid;
                if (IsErr())
                {
                    return;
                }

                #region 当回复成功后,发送通知
                if (postinfo.Pid > 0 && DNTRequest.GetString("postreplynotice") == "on")
                {
                    Notices.SendPostReplyNotice(postinfo, topic, replyUserid);
                }
                #endregion

                //向第三方应用同步数据
                Sync.Reply(postid.ToString(), topic.Tid.ToString(), topic.Title, postinfo.Poster, postinfo.Posterid.ToString(), topic.Fid.ToString(), "");

                //更新主题相关信息
                //UpdateTopicInfo(postmessage);

                #region 处理附件
                //处理附件
                StringBuilder    sb             = new StringBuilder();
                AttachmentInfo[] attachmentinfo = null;
                string           attachId       = DNTRequest.GetFormString("attachid");
                if (!string.IsNullOrEmpty(attachId))
                {
                    attachmentinfo = Attachments.GetNoUsedAttachmentArray(userid, attachId);
                    Attachments.UpdateAttachment(attachmentinfo, topic.Tid, postinfo.Pid, postinfo, ref sb, userid, config, usergroupinfo);
                }

                //加入相册
                if (config.Enablealbum == 1 && apb != null)
                {
                    sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username));
                }
                #endregion

                OnlineUsers.UpdateAction(olid, UserAction.PostReply.ActionID, forumid, forum.Name, topicid, topictitle);

                #region 设置提示信息和跳转链接
                //辩论地址
                if (topic.Special == 4)
                {
                    SetUrl(Urls.ShowDebateAspxRewrite(topicid));
                }
                else if (infloat == 0)//此处加是否弹窗提交判断是因为在IE6下弹窗提交会造成gettopicinfo, getpostlist(位于showtopic页面)被提交了两次
                {
                    SetUrl(string.Format("showtopic.aspx?forumpage={0}&topicid={1}&page=end&jump=pid#{2}", forumpageid, topicid, postid));
                }

                if (DNTRequest.GetFormString("continuereply") == "on")
                {
                    SetUrl("postreply.aspx?topicid=" + topicid + "&forumpage=" + forumpageid + "&continuereply=yes");
                }

                if (sb.Length > 0)
                {
                    UpdateUserCredits(Forums.GetValues(forum.Replycredits));
                    SetMetaRefresh(5);
                    SetShowBackLink(true);
                    if (infloat == 1)
                    {
                        AddErrLine(sb.ToString());
                        return;
                    }
                    else
                    {
                        AddMsgLine("<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表回复成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr></table>");
                    }
                }
                else
                {
                    SetMetaRefresh();
                    SetShowBackLink(false);
                    //上面已经进行用户组判断
                    if (postinfo.Invisible == 1)
                    {
                        AddMsgLine(string.Format("发表回复成功, 但需要经过审核才可以显示. {0}<br /><br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, 0) + "\">点击这里返回 {1}</a>)", (DNTRequest.GetFormString("continuereply") == "on" ? "继续回复" : "返回该主题"), forum.Name));
                    }
                    else
                    {
                        UpdateUserCredits(Forums.GetValues(forum.Replycredits));
                        MsgForward("postreply_succeed");
                        AddMsgLine(string.Format("发表回复成功, {0}<br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, 0) + "\">点击这里返回 {1}</a>)<br />", (DNTRequest.GetFormString("continuereply") == "on" ? "继续回复" : "返回该主题"), forum.Name));
                    }
                }
                #endregion

                // 删除主题游客缓存
                if (topic.Replies < (config.Ppp + 10))
                {
                    ForumUtils.DeleteTopicCacheFile(topicid);
                }

                //发送邮件通知
                if (DNTRequest.GetString("emailnotify") == "on" && topic.Posterid != -1 && topic.Posterid != userid)
                {
                    SendNotifyEmail(Users.GetShortUserInfo(topic.Posterid).Email.Trim(), postinfo, Utils.GetRootUrl(BaseConfigs.GetForumPath) + string.Format("showtopic.aspx?topicid={0}&page=end&jump=pid#{1}", topicid, postid));
                }
            }
        }
예제 #2
0
파일: postreply.cs 프로젝트: xiongeee/BBX
        protected override void ShowPage()
        {
            if (userid > 0)
            {
                userinfo = BBX.Entity.User.FindByID(this.userid);
            }

            var adminGroupInfo = AdminGroup.FindByID(this.usergroupid);

            if (adminGroupInfo != null)
            {
                disablepost = adminGroupInfo.DisablePostctrl;
            }

            if (!UserAuthority.CheckPostTimeSpan(this.usergroupinfo, adminGroupInfo, this.oluserinfo, this.userinfo, ref this.msg))
            {
                if (this.continuereply != "")
                {
                    base.AddErrLine("<b>回帖成功</b><br />由于" + this.msg + "后刷新继续");
                    return;
                }
                base.AddErrLine(this.msg);
                return;
            }
            else
            {
                var postInfo = this.GetPostAndTopic(adminGroupInfo);
                if (base.IsErr())
                {
                    return;
                }

                this.forum     = Forums.GetForumInfo(this.forumid);
                this.smileyoff = this.forum.AllowSmilies ? 0 : 1;
                this.bbcodeoff = ((this.forum.AllowBbCode && this.usergroupinfo.AllowCusbbCode) ? 0 : 1);
                //this.allowimg = this.forum.AllowImgCode ? 1 : 0;
                this.needaudit = UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo, this.topic);
                if (this.needaudit && this.topic.DisplayOrder == -2)
                {
                    base.AddErrLine("主题尚未通过审核, 不能执行回复操作");
                    return;
                }
                //string allowAttachmentType = Attachments.GetAllowAttachmentType(this.usergroupinfo, this.forum);
                this.attachextensions       = AttachType.GetAttachmentTypeArray(usergroupinfo, this.forum);
                this.attachextensionsnosize = AttachType.GetAttachmentTypeString(usergroupinfo, this.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);
                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 (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
                {
                    base.AddErrLine(this.msg);
                    this.needlogin = true;
                    return;
                }
                if (!UserAuthority.PostReply(forum, this.userid, this.usergroupinfo, this.topic))
                {
                    base.AddErrLine((this.topic.Closed == 1) ? "主题已关闭无法回复" : "您没有发表回复的权限");
                    this.needlogin = (this.topic.Closed != 1);
                    return;
                }
                if (!UserAuthority.CheckPostTimeSpan(this.usergroupinfo, adminGroupInfo, this.oluserinfo, this.userinfo, ref this.msg))
                {
                    base.AddErrLine(this.msg);
                    return;
                }
                if (adminGroupInfo != null)
                {
                    this.disablepost = adminGroupInfo.DisablePostctrl;
                }
                if (this.forum.TemplateID > 0)
                {
                    this.templatepath = Template.FindByID(this.forum.TemplateID).Directory;
                }

                base.AddLinkCss(BaseConfigs.GetForumPath + "templates/" + this.templatepath + "/editor.css", "css");
                this.customeditbuttons = Caches.GetCustomEditButtonList();
                if (this.ispost)
                {
                    string text = (DNTRequest.GetInt("topicid", -1) > 0) ? string.Format("postreply.aspx?topicid={0}&restore=1&forumpage=" + this.forumpageid, this.topicid) : string.Format("postreply.aspx?postid={0}&restore=1&forumpage=" + this.forumpageid, this.postid);
                    if (!String.IsNullOrEmpty(DNTRequest.GetString("quote")))
                    {
                        text = string.Format("{0}&quote={1}", text, DNTRequest.GetString("quote"));
                    }
                    base.SetBackLink(text);
                    this.NormalValidate(adminGroupInfo, this.postmessage, this.userinfo);
                    if (base.IsErr())
                    {
                        return;
                    }

                    this.canpostattach = UserAuthority.PostAttachAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg);
                    if (!string.IsNullOrEmpty(DNTRequest.GetFormString("toreplay_user").Trim()))
                    {
                        this.postmessage = DNTRequest.GetFormString("toreplay_user").Trim() + "\n\n" + this.postmessage;
                    }
                    postInfo = this.CreatePostInfo(this.postmessage);
                    int replyuserid = (this.postid > 0) ? Post.FindByID(this.postid).PosterID : postInfo.PosterID;
                    this.postid = postInfo.ID;
                    if (base.IsErr())
                    {
                        return;
                    }

                    if (postInfo.ID > 0 && DNTRequest.GetString("postreplynotice") == "on")
                    {
                        Notice.SendPostReplyNotice(postInfo, this.topic, replyuserid);
                    }
                    Sync.Reply(this.postid.ToString(), this.topic.ID.ToString(), this.topic.Title, postInfo.Poster, postInfo.PosterID.ToString(), this.topic.Fid.ToString(), "");
                    StringBuilder stringBuilder = new StringBuilder();
                    //AttachmentInfo[] array = null;
                    string formString = DNTRequest.GetFormString("attachid");
                    if (!string.IsNullOrEmpty(formString))
                    {
                        var array = Attachments.GetNoUsedAttachmentArray(this.userid, formString);
                        Attachments.UpdateAttachment(array, this.topic.ID, postInfo.ID, postInfo, ref stringBuilder, this.userid, this.config, this.usergroupinfo);
                    }
                    Online.UpdateAction(this.olid, UserAction.PostReply, this.forumid, this.forum.Name, this.topicid, this.topictitle);
                    if (this.topic.Special == 4)
                    {
                        base.SetUrl(Urls.ShowDebateAspxRewrite(this.topicid));
                    }
                    else
                    {
                        if (this.infloat == 0)
                        {
                            base.SetUrl(string.Format("showtopic.aspx?forumpage={0}&topicid={1}&page=end&jump=pid#{2}", this.forumpageid, this.topicid, this.postid));
                        }
                    }
                    if (DNTRequest.GetFormString("continuereply") == "on")
                    {
                        base.SetUrl("postreply.aspx?topicid=" + this.topicid + "&forumpage=" + this.forumpageid + "&continuereply=yes");
                    }
                    if (stringBuilder.Length > 0)
                    {
                        this.UpdateUserCredits();
                        base.SetMetaRefresh(5);
                        base.SetShowBackLink(true);
                        if (this.infloat == 1)
                        {
                            base.AddErrLine(stringBuilder.ToString());
                            return;
                        }
                        base.AddMsgLine("<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表回复成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr></table>");
                    }
                    else
                    {
                        base.SetMetaRefresh();
                        base.SetShowBackLink(false);
                        if (postInfo.Invisible == 1)
                        {
                            base.AddMsgLine(string.Format("发表回复成功, 但需要经过审核才可以显示. {0}<br /><br />(<a href=\"" + base.ShowForumAspxRewrite(this.forumid, 0) + "\">点击这里返回 {1}</a>)", (DNTRequest.GetFormString("continuereply") == "on") ? "继续回复" : "返回该主题", this.forum.Name));
                        }
                        else
                        {
                            this.UpdateUserCredits();
                            base.MsgForward("postreply_succeed");
                            base.AddMsgLine(string.Format("发表回复成功, {0}<br />(<a href=\"" + base.ShowForumAspxRewrite(this.forumid, 0) + "\">点击这里返回 {1}</a>)<br />", (DNTRequest.GetFormString("continuereply") == "on") ? "继续回复" : "返回该主题", this.forum.Name));
                        }
                    }
                    if (this.topic.Replies < this.config.Ppp + 10)
                    {
                        ForumUtils.DeleteTopicCacheFile(this.topicid);
                    }
                    if (DNTRequest.GetString("emailnotify") == "on" && this.topic.PosterID != -1 && this.topic.PosterID != this.userid)
                    {
                        this.SendNotifyEmail(BBX.Entity.User.FindByID(this.topic.PosterID).Email.Trim(), postInfo, Utils.GetRootUrl(BaseConfigs.GetForumPath) + string.Format("showtopic.aspx?topicid={0}&page=end&jump=pid#{1}", this.topicid, this.postid));
                    }
                }
                return;
            }
        }
예제 #3
0
        protected override void ShowPage()
        {
            if (oluserinfo.Groupid == 4)
            {
                AddErrLine("你所在的用户组,为禁止发言"); return;
            }

            #region 临时帐号发帖
            //int realuserid = -1;
            //bool tempaccountspost = false;
            //string tempusername = DNTRequest.GetString("tempusername");
            //if (!Utils.StrIsNullOrEmpty(tempusername) && tempusername != username)
            //{
            //    realuserid = Users.CheckTempUserInfo(tempusername, DNTRequest.GetString("temppassword"), DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer"));
            //    if (realuserid == -1)
            //    {
            //        AddErrLine("临时帐号登录失败,无法继续发帖。"); return;
            //    }
            //    else
            //    {
            //        userid = realuserid;
            //        username = tempusername;
            //        tempaccountspost = true;
            //    }
            //}


            #endregion

            if (userid > 0)
            {
                userinfo = Users.GetShortUserInfo(userid);
                //    if (userinfo != null)
                //    {
                //        usergroupinfo = UserGroups.GetUserGroupInfo(userinfo.Groupid);
                //        usergroupid = usergroupinfo.Groupid;
                //        useradminid = userinfo.Adminid;
                //    }
            }

            #region 获取并检查版块信息
            forum = Forums.GetForumInfo(forumid);
            if (forum == null || forum.Layer == 0)
            {
                forum          = new ForumInfo();//如果不初始化对象,则会报错
                allowposttopic = false;
                AddErrLine("错误的论坛ID"); return;
            }

            pagetitle = Utils.RemoveHtml(forum.Name);
            enabletag = (config.Enabletag & forum.Allowtag) == 1;

            if (forum.Applytopictype == 1)  //启用主题分类
            {
                topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes);
            }

            if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password"))
            {
                AddErrLine("本版块被管理员设置了密码");
                SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return;
            }
            needaudit         = UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo);
            smileyoff         = 1 - forum.Allowsmilies;
            bbcodeoff         = (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) ? 0 : 1;
            allowimg          = forum.Allowimgcode;
            customeditbuttons = Caches.GetCustomEditButtonList();
            #endregion

            #region 访问和发帖权限校验
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                needlogin = true; return;
            }

            if (!UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                needlogin = true; return;
            }
            #endregion

            #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);

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

            canhtmltitle = usergroupinfo.Allowhtmltitle == 1;

            #region 积分信息
            creditstrans        = Scoresets.GetTopicAttachCreditsTrans();
            userextcreditsinfo  = Scoresets.GetScoreSet(creditstrans);
            bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans());
            #endregion

            #region 特殊主题权限判断
            if (forum.Allowspecialonly > 0 && !Utils.InArray(type, "poll,bonus,debate"))
            {
                AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", forum.Name)); return;
            }
            if (!UserAuthority.PostSpecialAuthority(forum, type, ref msg))
            {
                AddErrLine(msg); return;
            }
            if (!UserAuthority.PostSpecialAuthority(usergroupinfo, type, ref msg))
            {
                AddErrLine(msg);
                needlogin = true; return;
            }
            if (type == "bonus")
            {
                int creditTrans = Scoresets.GetBonusCreditsTrans();
                //当“交易积分设置”有效时(1-8的整数):
                if (creditTrans <= 0)
                {
                    //AddErrLine(string.Format("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏", usergroupinfo.Grouptitle)); return;
                    AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏"); return;
                }
                mybonustranscredits = Users.GetUserExtCredits(userid, creditTrans);
            }
            userGroupInfoList.Sort(delegate(UserGroupInfo x, UserGroupInfo y) { return((x.Readaccess - y.Readaccess) + (y.Groupid - x.Groupid)); });
            #endregion

            //发帖不受审核、过滤、灌水等限制权限
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            disablepost = admininfo != null ? admininfo.Disablepostctrl : usergroupinfo.Disableperiodctrl;
            //如果是提交...
            if (ispost)
            {
                #region 判断是否是灌水
                if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, userinfo, ref msg))
                {
                    AddErrLine(msg); return;
                }
                #endregion

                SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", forumid, type));

                ForumUtils.WriteCookie("postmessage", postmessage);

                #region 验证提交信息
                //常规项验证
                NormalValidate(admininfo, postmessage, userinfo);
                if (IsErr())
                {
                    return;
                }

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

                    if (!UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg))
                    {
                        AddErrLine(msg);
                    }
                }

                //发悬赏校验
                int  topicprice = 0;
                bool isbonus    = type == "bonus";
                ValidateBonus(ref topicprice, ref isbonus);

                //发特殊主题校验
                ValidatePollAndDebate();

                if (IsErr())
                {
                    return;
                }
                #endregion

                int hide = (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) ? 1 : 0;

                TopicInfo topicinfo = CreateTopic(admininfo, postmessage, isbonus, topicprice);
                if (IsErr())
                {
                    return;
                }

                PostInfo postinfo = CreatePost(topicinfo);

                if (IsErr())
                {
                    return;
                }

                #region 处理附件
                //处理附件
                StringBuilder    sb             = new StringBuilder();
                AttachmentInfo[] attachmentinfo = null;
                string           attachId       = DNTRequest.GetFormString("attachid");
                if (!string.IsNullOrEmpty(attachId))
                {
                    attachmentinfo = Attachments.GetNoUsedAttachmentArray(userid, attachId);
                    Attachments.UpdateAttachment(attachmentinfo, topicinfo.Tid, postinfo.Pid, postinfo, ref sb, userid, config, usergroupinfo);
                }
                //加入相册
                if (config.Enablealbum == 1 && apb != null)
                {
                    sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username));
                }
                #endregion

                #region 添加日志的操作
                SpacePluginBase spb = SpacePluginProvider.GetInstance();
                if (DNTRequest.GetFormString("addtoblog") == "on" && spb != null)
                {
                    if (userid != -1 && userinfo.Spaceid > 0)
                    {
                        spb.CreateTopic(topicinfo, postinfo, attachmentinfo);
                    }
                    else
                    {
                        AddMsgLine("您的个人空间尚未开通, 无法同时添加为日志");
                    }
                }
                #endregion

                OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forum.Name, -1, "");

                #region 设置提示信息和跳转链接
                if (sb.Length > 0)
                {
                    SetUrl(base.ShowTopicAspxRewrite(topicinfo.Tid, 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>");
                        AddMsgLine(sb.Append("</table>").ToString());
                    }
                }
                else
                {
                    SetShowBackLink(false);
                    if (useradminid != 1)
                    {
                        //是否需要审核
                        if (UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo) || topicinfo.Displayorder == -2)
                        {
                            ForumUtils.WriteCookie("postmessage", "");
                            SetLastPostedForumCookie();
                            SetUrl(base.ShowForumAspxRewrite(forumid, forumpageid));
                            SetMetaRefresh();
                            AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块");
                        }
                        else
                        {
                            PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid);
                        }
                    }
                    else
                    {
                        PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid);
                    }
                }
                #endregion

                //ForumUtils.WriteCookie("postmessage", "");
                //SetLastPostedForumCookie();

                //如果已登录就不需要再登录
                if (needlogin && userid > 0)
                {
                    needlogin = false;
                }
            }
            else //非提交操作
            {
                AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
            }
        }
예제 #4
0
        protected override void ShowPage()
        {
            if (this.oluserinfo.GroupID == 4)
            {
                base.AddErrLine("你所在的用户组,为禁止发言");
                return;
            }
            if (this.userid > 0)
            {
                this.userinfo = BBX.Entity.User.FindByID(this.userid);
            }
            if (HttpContext.Current.Request.RawUrl.Contains("javascript:"))
            {
                base.AddErrLine("非法的链接");
                return;
            }
            this.forum = XForum.FindByID(forumid);
            if (this.forum == null || this.forum.Layer == 0)
            {
                this.forum          = new XForum();
                this.allowposttopic = false;
                base.AddErrLine("错误的论坛ID");
                return;
            }
            this.pagetitle = Utils.RemoveHtml(this.forum.Name);
            this.enabletag = config.Enabletag && this.forum.AllowTag;
            if (this.forum.ApplytopicType == 1)
            {
                this.topictypeselectoptions = Forums.GetCurrentTopicTypesOption(this.forum.Fid, this.forum.TopicTypes);
            }
            if (!String.IsNullOrEmpty(this.forum.Password) && Utils.MD5(this.forum.Password) != ForumUtils.GetCookie("forum" + this.forumid + "password"))
            {
                base.AddErrLine("本版块被管理员设置了密码");
                base.SetBackLink(base.ShowForumAspxRewrite(this.forumid, 0));
                return;
            }
            this.needaudit = UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo);
            this.smileyoff = forum.AllowSmilies ? 0 : 1;
            this.bbcodeoff = ((this.forum.Allowbbcode == 1 && this.usergroupinfo.AllowCusbbCode) ? 0 : 1);
            //this.allowimg = this.forum.Allowimgcode;
            this.customeditbuttons = Caches.GetCustomEditButtonList();
            if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
            {
                base.AddErrLine(this.msg);
                this.needlogin = true;
                return;
            }
            if (!UserAuthority.PostAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
            {
                base.AddErrLine(this.msg);
                this.needlogin = true;
                return;
            }
            //string allowAttachmentType = Attachments.GetAllowAttachmentType(this.usergroupinfo, this.forum);
            this.attachextensions       = AttachType.GetAttachmentTypeArray(usergroupinfo, this.forum);
            this.attachextensionsnosize = AttachType.GetAttachmentTypeString(usergroupinfo, this.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.canhtmltitle        = this.usergroupinfo.AllowHtmlTitle;
            this.creditstrans        = Scoresets.GetTopicAttachCreditsTrans();
            this.userextcreditsinfo  = Scoresets.GetScoreSet(this.creditstrans);
            this.bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans());
            if (this.forum.AllowSpecialOnly && !Utils.InArray(this.type, "poll,bonus,debate"))
            {
                base.AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", this.forum.Name));
                return;
            }
            if (!UserAuthority.PostSpecialAuthority(this.forum, this.type, ref this.msg))
            {
                base.AddErrLine(this.msg);
                return;
            }
            if (!UserAuthority.PostSpecialAuthority(this.usergroupinfo, this.type, ref this.msg))
            {
                base.AddErrLine(this.msg);
                this.needlogin = true;
                return;
            }
            if (this.type == "bonus")
            {
                int bonusCreditsTrans = Scoresets.GetBonusCreditsTrans();
                if (bonusCreditsTrans <= 0)
                {
                    base.AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏");
                    return;
                }
                this.mybonustranscredits = Users.GetUserExtCredits(this.userid, bonusCreditsTrans);
            }
            this.userGroupInfoList.Sort((x, y) => x.Readaccess - y.Readaccess + (y.ID - x.ID));
            var adminGroupInfo = AdminGroup.FindByID(this.usergroupid);

            this.disablepost = adminGroupInfo != null ? adminGroupInfo.DisablePostctrl : this.usergroupinfo.DisablePeriodctrl;
            if (this.ispost)
            {
                if (!UserAuthority.CheckPostTimeSpan(this.usergroupinfo, adminGroupInfo, this.oluserinfo, this.userinfo, ref this.msg))
                {
                    base.AddErrLine(this.msg);
                    return;
                }
                base.SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", this.forumid, this.type));
                ForumUtils.WriteCookie("postmessage", this.postmessage);
                this.NormalValidate(adminGroupInfo, this.postmessage, this.userinfo);
                if (base.IsErr())
                {
                    return;
                }
                if (ForumUtils.IsPostFile())
                {
                    if (Utils.StrIsNullOrEmpty(AttachType.GetAttachmentTypeArray(usergroupinfo, forum)))
                    {
                        base.AddErrLine("系统不允许上传附件");
                    }
                    if (!UserAuthority.PostAttachAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
                    {
                        base.AddErrLine(this.msg);
                    }
                }
                int  topicprice = 0;
                bool isbonus    = this.type == "bonus";
                this.ValidateBonus(ref topicprice, ref isbonus);
                this.ValidatePollAndDebate();
                if (base.IsErr())
                {
                    return;
                }
                if (ForumUtils.IsHidePost(this.postmessage))
                {
                    int arg_5B2_0 = this.usergroupinfo.AllowHideCode ? 1 : 0;
                }
                var topicInfo = this.CreateTopic(adminGroupInfo, this.postmessage, isbonus, topicprice);
                if (base.IsErr())
                {
                    return;
                }
                //var postInfo = this.CreatePost(topicInfo);
                var postInfo = Post.FindByID(topicInfo.LastPostID);
                //if (base.IsErr())
                //{
                //	return;
                //}
                var stringBuilder = new StringBuilder();
                //AttachmentInfo[] array = null;
                string formString = DNTRequest.GetFormString("attachid");
                if (!string.IsNullOrEmpty(formString))
                {
                    var array = Attachments.GetNoUsedAttachmentArray(this.userid, formString);
                    Attachments.UpdateAttachment(array, topicInfo.ID, postInfo.ID, postInfo, ref stringBuilder, this.userid, this.config, this.usergroupinfo);
                }
                Online.UpdateAction(this.olid, UserAction.PostTopic, this.forumid, this.forum.Name, -1, "");
                if (this.isbindconnect && this.feedstatus)
                {
                    // 推送到QQ空间和微博
                    //PushFeed pushFeed = new PushFeed();
                    //pushFeed.TopicPushFeed(topicInfo, postInfo, array, this.feedstatus);
                }
                if (stringBuilder.Length > 0)
                {
                    base.SetUrl(base.ShowTopicAspxRewrite(topicInfo.ID, 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>");
                    base.AddMsgLine(stringBuilder.Append("</table>").ToString());
                }
                else
                {
                    base.SetShowBackLink(false);
                    if (this.useradminid != 1 && (UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo) || topicInfo.DisplayOrder == -2))
                    {
                        ForumUtils.WriteCookie("postmessage", "");
                        this.SetLastPostedForumCookie();
                        base.SetUrl(base.ShowForumAspxRewrite(this.forumid, this.forumpageid));
                        base.SetMetaRefresh();
                        base.AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块");
                    }
                    else
                    {
                        this.PostTopicSucceed(this.forum, topicInfo);
                    }
                }
                if (this.needlogin && this.userid > 0)
                {
                    this.needlogin = false;
                    return;
                }
            }
            else
            {
                base.AddLinkCss(BaseConfigs.GetForumPath + "templates/" + this.templatepath + "/editor.css", "css");
            }
        }