Example #1
0
 public bool ValidateAuthority()
 {
     if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
     {
         base.AddErrLine(this.msg);
         if (this.userid == -1)
         {
             this.needlogin = true;
         }
         return(false);
     }
     this.canreply = (this.ismoder == 1 || UserAuthority.PostReply(forum, this.userid, this.usergroupinfo, this.topic));
     if (this.userid > -1)
     {
         this.canposttopic = UserAuthority.PostAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg);
         if (!this.canposttopic && !this.pagename.StartsWith("showtopic") && !this.pagename.StartsWith("showtree"))
         {
             base.AddErrLine(this.msg);
             return(false);
         }
     }
     if (this.useradminid != 1 && !this.usergroupinfo.DisablePeriodctrl)
     {
         string text = "";
         if (Scoresets.BetweenTime(this.config.Postbanperiods, out text))
         {
             this.canposttopic = false;
         }
         this.isnewbie = UserAuthority.CheckNewbieSpan(this.userid);
     }
     return(true);
 }
Example #2
0
        /// <summary>
        /// 权限认证,包括回复,下载附件,发主题等
        /// </summary>
        /// <returns></returns>
        public bool ValidateAuthority()
        {
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                if (userid == -1)
                {
                    needlogin = true;
                }

                return(false);
            }

            //是否有回复权限
            canreply = (ismoder == 1 ? true : UserAuthority.PostReply(forum, userid, usergroupinfo, topic));

            //判断是否有发主题权限
            if (userid > -1)
            {
                canposttopic = UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg);
                if (!canposttopic)
                {
                    if (!pagename.StartsWith("showtopic") && !pagename.StartsWith("showtree"))
                    {
                        AddErrLine(msg);
                        return(false);
                    }
                }
            }

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

                isnewbie = UserAuthority.CheckNewbieSpan(userid);
            }

            return(true);
        }
Example #3
0
        protected override void ShowPage()
        {
            GetPostAds(forumid);

            if (userid > 0 && useradminid > 0)
            {
                AdminGroupInfo admingroupinfo = AdminGroups.GetAdminGroupInfo(usergroupid);
                if (admingroupinfo != null)
                {
                    disablepostctrl = admingroupinfo.Disablepostctrl;
                }
            }

            #region 获取版块信息
            if (forumid == -1)
            {
                AddLinkRss(forumpath + "tools/rss.aspx", "最新主题");
                AddErrLine("无效的版块ID");
                return;
            }
            forum = Forums.GetForumInfo(forumid);
            if (forum == null || forum.Fid < 1)
            {
                if (config.Rssstatus == 1)
                {
                    AddLinkRss(forumpath + "tools/rss.aspx", Utils.EncodeHtml(config.Forumtitle) + " 最新主题");
                }

                AddErrLine("不存在的版块ID");
                return;
            }
            #endregion

            if (config.Rssstatus == 1)
            {
                AddLinkRss(forumpath + "tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新主题");
            }

            if (JumpUrl(forum))
            {
                return;
            }

            needaudit = UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo);

            // 检查是否具有版主的身份
            if (useradminid > 0)
            {
                ismoder = Moderators.IsModer(useradminid, userid, forumid);
            }

            //设置搜索和排序条件
            SetSearchCondition();

            showforumlogin = IsShowForumLogin(forum);
            pagetitle      = Utils.RemoveHtml(forum.Name);
            navhomemenu    = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);
            forumnav       = ShowForumAspxRewrite(ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname).Replace("\"showforum", "\"" + forumurl + "showforum"),
                                                  forumid, pageid);
            topicextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
            bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans());

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

            if (forum.Viewbytopictype == 1) //允许按类别浏览
            {
                topictypeselectlink = Forums.GetCurrentTopicTypesLink(forum.Fid, forum.Topictypes, forumurl + "showforum.aspx");
            }
            #endregion

            //更新页面Meta中的keyword,description项, 提高SEO友好性
            UpdateMetaInfo(Utils.StrIsNullOrEmpty(forum.Seokeywords) ? config.Seokeywords : forum.Seokeywords,
                           Utils.StrIsNullOrEmpty(forum.Seodescription) ? forum.Description : forum.Seodescription,
                           config.Seohead);

            //设置编辑器状态
            SetEditorState();

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

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

                isnewbie = UserAuthority.CheckNewbieSpan(userid);
            }

            //是否显示快速发主题编辑器(全局权限判定,版块权限判定,是否是游客,游客需要显示,登录用户是否允许发主题且已过新手见习期)
            if ((config.Fastpost == 1 || config.Fastpost == 3) && forum.Allowspecialonly <= 0 && (userid < 0 || (canposttopic && !isnewbie)))
            {
                canquickpost = true;
            }
            #endregion

            // 得到子版块列表
            if (forum.Subforumcount > 0)
            {
                subforumlist = Forums.GetSubForumCollection(forumid, forum.Colcount, config.Hideprivate, usergroupid, config.Moddisplay);
            }
            if (!forum.Rules.Equals(""))
            {
                forum.Rules = UBB.ParseSimpleUBB(forum.Rules);//替换版规中的UBB
            }
            //获取主题总数
            topiccount = Topics.GetTopicCount(forumid, true, condition);

            #region 设置分页及主题列表信息
            // 得到Tpp设置
            if (tpp <= 0)
            {
                tpp = config.Tpp;
            }

            // 得到Ppp设置
            if (ppp <= 0)
            {
                ppp = config.Ppp;
            }

            //修正请求页数中可能的错误
            if (pageid < 1)
            {
                pageid = 1;
            }

            int toptopicpagecount = 0;

            if (forum.Layer > 0)
            {
                //获取当前页置顶主题列表
                DataRow dr = Topics.GetTopTopicListID(forumid);
                if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString()))
                {
                    topiccount = topiccount + TypeConverter.ObjectToInt(dr["tid0Count"]);
                }

                //获取总页数
                pagecount = topiccount % tpp == 0 ? topiccount / tpp : topiccount / tpp + 1;
                if (pagecount == 0)
                {
                    pagecount = 1;
                }
                if (pageid > pagecount)
                {
                    pageid = pagecount;
                }

                if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString()))
                {
                    toptopiccount = TypeConverter.ObjectToInt(dr["tidCount"]);
                    if (toptopiccount > tpp * (pageid - 1))
                    {
                        toptopiclist      = Topics.GetTopTopicList(forumid, tpp, pageid, dr["tid"].ToString(), forum.Autoclose, forum.Topictypeprefix);
                        toptopicpagecount = toptopiccount / tpp;
                    }

                    if (toptopicpagecount >= pageid || (pageid == 1 && toptopicpagecount != toptopiccount))
                    {
                        topiclist = GetTopicInfoList(tpp - toptopiccount % tpp, pageid - toptopicpagecount, 0);
                    }
                    else
                    {
                        topiclist = GetTopicInfoList(tpp, pageid - toptopicpagecount, toptopiccount % tpp);
                    }
                }
                else
                {
                    toptopicpagecount = 0;
                    topiclist         = GetTopicInfoList(tpp, pageid, 0);
                }

                //如果topiclist为空则更新当前论坛帖数
                if (topiclist == null || topiclist.Count == 0 || topiclist.Count > topiccount)
                {
                    Forums.SetRealCurrentTopics(forum.Fid);
                }

                SetPageNumber();
                //当版块数大于一个并且当版块数量为一个时不是版块自身时显示下拉菜单
                showvisitedforumsmenu = visitedforums != null && ((visitedforums.Length == 1 && visitedforums[0].Fid != forumid) || visitedforums.Length > 1);
                SetVisitedForumsCookie();
                //保存查看版块的页数
                Utils.WriteCookie("forumpageid", pageid.ToString(), 30);

                //判断是否需要生成游客缓存页面
                IsGuestCachePage();
            }
            #endregion

            #region 替换版规中的UBB
            forum.Description = UBB.ParseSimpleUBB(forum.Description);
            #endregion

            #region 更新在线信息
            OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, forum.Name, -1, "");

            if ((forumtotalonline < config.Maxonlinelist && (config.Whosonlinestatus == 2 || config.Whosonlinestatus == 3)) || DNTRequest.GetString("showonline") == "yes")
            {
                showforumonline = true;
                onlineuserlist  = OnlineUsers.GetForumOnlineUserCollection(forumid, out forumtotalonline, out forumtotalonlineguest,
                                                                           out forumtotalonlineuser, out forumtotalonlineinvisibleuser);
            }
            //if (DNTRequest.GetString("showonline") != "no")
            //{
            //     showforumonline = false;
            //}

            if (DNTRequest.GetString("showonline") == "no")
            {
                showforumonline = false;
            }
            #endregion

            //修正版主列表
            if (forum.Moderators.Trim() != "")
            {
                string moderHtml = string.Empty;
                foreach (string m in forum.Moderators.Split(','))
                {
                    moderHtml += string.Format("<a href=\"{0}userinfo.aspx?username={1}\">{2}</a>,", forumpath, Utils.UrlEncode(m), m);
                }

                forum.Moderators = moderHtml.TrimEnd(',');
            }

            ForumUtils.UpdateVisitedForumsOptions(forumid);
        }
Example #4
0
        protected override void ShowPage()
        {
            this.GetPostAds(this.forumid);
            if (this.userid > 0 && this.useradminid > 0)
            {
                var adminGroupInfo = AdminGroup.FindByID(this.usergroupid);
                if (adminGroupInfo != null)
                {
                    this.disablepostctrl = adminGroupInfo.DisablePostctrl;
                }
            }
            if (this.forumid == -1)
            {
                base.AddLinkRss(this.forumpath + "tools/rss.aspx", "最新主题");
                base.AddErrLine("无效的版块ID");
                return;
            }
            this.forum = Forums.GetForumInfo(this.forumid);
            if (this.forum == null || this.forum.Fid < 1)
            {
                if (this.config.Rssstatus == 1)
                {
                    base.AddLinkRss(this.forumpath + "tools/rss.aspx", Utils.EncodeHtml(this.config.Forumtitle) + " 最新主题");
                }
                base.AddErrLine("不存在的版块ID");
                return;
            }
            if (this.config.Rssstatus == 1)
            {
                base.AddLinkRss(this.forumpath + "tools/" + Urls.RssAspxRewrite(this.forum.Fid), Utils.EncodeHtml(this.forum.Name) + " 最新主题");
            }
            if (this.JumpUrl(this.forum))
            {
                return;
            }
            this.needaudit = UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo);
            if (this.useradminid > 0)
            {
                this.ismoder = Moderators.IsModer(this.useradminid, this.userid, this.forumid);
            }
            //this.SetSearchCondition();
            this.showforumlogin      = this.IsShowForumLogin(this.forum);
            this.pagetitle           = Utils.RemoveHtml(this.forum.Name);
            this.navhomemenu         = Caches.GetForumListMenuDivCache(this.usergroupid, this.userid, this.config.Extname);
            this.forumnav            = base.ShowForumAspxRewrite(ForumUtils.UpdatePathListExtname(this.forum.Pathlist.Trim(), this.config.Extname).Replace("\"showforum", "\"" + this.forumurl + "showforum"), this.forumid, this.pageid);
            this.topicextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
            this.bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans());
            if (this.forum.ApplytopicType == 1)
            {
                this.topictypeselectoptions = Forums.GetCurrentTopicTypesOption(this.forum.Fid, this.forum.Topictypes);
            }
            if (this.forum.ApplytopicType == 1)
            {
                this.topictypeselectlink = Forums.GetCurrentTopicTypesLink(this.forum.Fid, this.forum.Topictypes, this.forumurl + "showforum.aspx");
            }
            meta = PageHelper.UpdateMetaInfo(meta, this.forum.Seokeywords.IsNullOrEmpty() ? this.config.Seokeywords : this.forum.Seokeywords, this.forum.Seodescription.IsNullOrEmpty() ? this.forum.Description : this.forum.Seodescription, this.config.Seohead);
            this.SetEditorState();
            if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
            {
                base.AddErrLine(this.msg);
                this.needlogin = (this.userid == -1);
                return;
            }
            this.canposttopic = UserAuthority.PostAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg);
            if (this.useradminid != 1 && !this.usergroupinfo.DisablePeriodctrl)
            {
                string text = "";
                if (this.canposttopic && Scoresets.BetweenTime(this.config.Postbanperiods, out text))
                {
                    this.canposttopic = false;
                }
                this.isnewbie = UserAuthority.CheckNewbieSpan(this.userid);
            }
            if ((this.config.Fastpost == 1 || this.config.Fastpost == 3) && !this.forum.AllowSpecialOnly && (this.userid < 0 || (this.canposttopic && !this.isnewbie)))
            {
                this.canquickpost = true;
            }
            if ((forum as XForum).Childs.Count > 0)
            {
                this.subforumlist = Forums.GetSubForumCollection(this.forumid, this.forum.ColCount, this.config.Hideprivate, this.usergroupid, this.config.Moddisplay);
            }
            if (!this.forum.Rules.IsNullOrWhiteSpace())
            {
                this.forum.Rules = UBB.ParseSimpleUBB(this.forum.Rules);
            }
            // 满足条件的主题数
            this.topiccount = Topic.SearchCount(forumid, topictypeid, interval, filter);
            if (tpp <= 0)
            {
                tpp = this.config.Tpp;
            }
            if (this.ppp <= 0)
            {
                this.ppp = this.config.Ppp;
            }
            if (this.pageid < 1)
            {
                this.pageid = 1;
            }

            // 内层板块,需要显示主题列表
            if (this.forum.Layer > 0)
            {
                // 置顶主题列表
                var tops = Topic.GetTop(forumid);
                if (tops.Count > 0)
                {
                    // 加上非本板块的主题数
                    topiccount += tops.Count(e => e.Fid != forumid);
                }

                // 根据主题总数计算分页
                //pagecount = ((topiccount % tpp == 0) ? (topiccount / tpp) : (topiccount / tpp + 1));
                pagecount = topiccount / tpp;
                if (topiccount % tpp > 0)
                {
                    pagecount++;
                }
                if (pagecount == 0)
                {
                    pagecount = 1;
                }
                if (pageid > pagecount)
                {
                    pageid = pagecount;
                }

                // 如果有置顶主题,则先读取置顶主题,再读取部分普通主题以填满一页
                if (tops.Count > 0)
                {
                    // 置顶主题数
                    var toptopiccount = tops.Count;
                    // 置顶主题构成的完整页数,不包括半截
                    int topPageCount = toptopiccount / tpp;
                    // 置顶主题可能满好几页,如果分到当前页还有主题,则需要处理
                    if (toptopiccount > tpp * (pageid - 1))
                    {
                        // 取出本页所属的置顶主题
                        toptopiclist = Topics.GetTopTopicList(tops, tpp, pageid, forum.AutoClose, forum.Topictypeprefix);

                        if (toptopiclist.Count < tpp)
                        {
                            // 本页有一部分置顶主题,要注意计算本页普通主题的数量(总页大小-置顶帖在本页的大小),开始行很简单从0开始即可(因为是第一页普通主题)
                            topiclist = GetTopicInfoList(tpp - toptopiclist.Count, pageid - topPageCount, 0);
                        }
                    }
                    else
                    {
                        // 已经没有置顶主题,取满一页普通主题,注意开始行的计算
                        topiclist = GetTopicInfoList(tpp, pageid - topPageCount, toptopiccount % tpp);
                    }
                }
                else
                {
                    // 如果没有置顶主题,则直接读取一页普通主题
                    topiclist = GetTopicInfoList(tpp, pageid, 0);
                }
                // 如果没有主题,或者实际主题列表大于主题总数,那么更新论坛的主题数
                // 在XCode支持下,即使有缓存,这种可能性也很小很小
                if (topiclist == null || topiclist.Count == 0 || topiclist.Count > topiccount)
                {
                    XForum.SetRealCurrentTopics(this.forum.Fid);
                }
                this.SetPageNumber();

                var vs = visitedforums;
                this.showvisitedforumsmenu = (vs != null && ((vs.Length == 1 && vs[0].Fid != forumid) || vs.Length > 1));
                this.SetVisitedForumsCookie();
                Utils.WriteCookie("forumpageid", this.pageid.ToString(), 30);
                this.IsGuestCachePage();
            }
            this.forum.Description = UBB.ParseSimpleUBB(this.forum.Description);
            Online.UpdateAction(this.olid, UserAction.ShowForum, this.forumid, this.forum.Name, -1, "");
            if ((this.forumtotalonline < this.config.Maxonlinelist && (this.config.Whosonlinestatus == 2 || this.config.Whosonlinestatus == 3)) || DNTRequest.GetString("showonline") == "yes")
            {
                this.showforumonline = true;
                this.onlineuserlist  = Online.GetList(this.forumid, Online._.UserID, true);

                var st = Online.GetStat();
                this.forumtotalonline              = st.Total;
                this.forumtotalonlineuser          = st.User;
                this.forumtotalonlineinvisibleuser = st.Invisible;
                this.forumtotalonlineguest         = st.Guest;
            }
            if (DNTRequest.GetString("showonline") == "no")
            {
                this.showforumonline = false;
            }
            // 这里会导致版主列表不断增大,直到最后内存溢出,临时解决
            if (!forum.Moderators.IsNullOrWhiteSpace() && (forum.ModeratorsHtml.IsNullOrWhiteSpace() || !forum.ModeratorsHtml.Contains("href")))
            {
                string   text2 = string.Empty;
                string[] array = this.forum.Moderators.Split(',');
                for (int i = 0; i < array.Length; i++)
                {
                    text2 += string.Format("<a href=\"{0}userinfo.aspx?username={1}\">{2}</a>,", this.forumpath, Utils.UrlEncode(array[i]), array[i]);
                }
                this.forum.ModeratorsHtml = text2.TrimEnd(',');
            }
            ForumUtils.UpdateVisitedForumsOptions(this.forumid);
        }