示例#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);
 }
示例#2
0
        /// <summary>
        /// 校验用户是否可以访问论坛
        /// </summary>
        /// <returns></returns>
        private bool ValidateUserPermission()
        {
            if (onlineusercount >= config.Maxonlines && useradminid != 1 && pagename != "login.aspx" && pagename != "logout.aspx")
            {
                ShowMessage("抱歉,目前访问人数太多,你暂时无法访问论坛.", 0);
                return(false);
            }

            if (usergroupinfo.Allowvisit != 1 && useradminid != 1 && pagename != "login.aspx" && pagename != "register.aspx" && pagename != "logout.aspx" && pagename != "activationuser.aspx" && pagename != "getpassword.aspx")
            {
                ShowMessage("抱歉, 您所在的用户组不允许访问论坛", 2);
                return(false);
            }

            // 如果IP访问列表有设置则进行判断
            if (config.Ipaccess.Trim() != "")
            {
                string[] regctrl = Utils.SplitString(config.Ipaccess, "\n");
                if (!Utils.InIPArray(DNTRequest.GetIP(), regctrl))
                {
                    ShowMessage("抱歉, 系统设置了IP访问列表限制, 您无法访问本论坛", 0);
                    return(false);
                }
            }


            // 如果IP访问列表有设置则进行判断
            if (config.Ipdenyaccess.Trim() != "")
            {
                string[] regctrl = Utils.SplitString(config.Ipdenyaccess, "\n");
                if (Utils.InIPArray(DNTRequest.GetIP(), regctrl))
                {
                    ShowMessage("由于您严重违反了论坛的相关规定, 已被禁止访问.", 2);
                    return(false);
                }
            }

            // 如果当前用户请求页面不是登录页面并且当前用户非管理员并且论坛设定了时间段,当时间在其中的一个时间段内,则跳转到论坛登录页面
            if (useradminid != 1 && pagename != "login.aspx" && pagename != "logout.aspx" && usergroupinfo.Disableperiodctrl != 1)
            {
                if (Scoresets.BetweenTime(config.Visitbanperiods))
                {
                    ShowMessage("在此时间段内不允许访问本论坛", 2);
                    return(false);
                }
            }
            return(true);
        }
示例#3
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);
        }
示例#4
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public ArchiverPage()
        {
            config = GeneralConfigs.GetConfig();

            if (config.Archiverstatus == 2 && DNTRequest.IsSearchEnginesGet())//启用,但当用户从搜索引擎点击时自动转向动态页面
            {
                string url = OrganizeURL(HttpContext.Current.Request.Url);
                HttpContext.Current.Response.Redirect(url);
            }

            if (config.Archiverstatus == 3 && DNTRequest.IsBrowserGet())            //启用,但当用户使用浏览器访问时自动转向动态页面
            {
                string url = OrganizeURL(HttpContext.Current.Request.Url);
                HttpContext.Current.Response.Redirect(url);
            }

            int onlineusercount = OnlineUsers.GetOnlineAllUserCount();

            if (onlineusercount >= config.Maxonlines)
            {
                ShowError("抱歉,目前访问人数太多,你暂时无法访问论坛.", 0);
            }

            if (config.Nocacheheaders == 1)
            {
                HttpContext.Current.Response.Buffer          = true;
                HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
                HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
                HttpContext.Current.Response.Expires      = 0;
                HttpContext.Current.Response.CacheControl = "no-cache";
                HttpContext.Current.Response.Cache.SetNoStore();
            }

            OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);

            userid      = oluserinfo.Userid;
            useradminid = oluserinfo.Adminid;


            // 如果论坛关闭且当前用户请求页面不是登录页面且用户非管理员, 则跳转至论坛关闭信息页
            if (config.Closed == 1 && oluserinfo.Adminid != 1)
            {
                ShowError("", 1);
            }

            usergroupinfo = UserGroups.GetUserGroupInfo(oluserinfo.Groupid);

            // 如果不允许访问论坛则转向到tools/ban.htm
            if (usergroupinfo.Allowvisit != 1)
            {
                ShowError("抱歉, 您所在的用户组不允许访问论坛", 2);
            }
            // 如果IP访问列表有设置则进行判断
            if (config.Ipaccess.Trim() != "")
            {
                string[] regctrl = Utils.SplitString(config.Ipaccess, "\n");
                if (!Utils.InIPArray(DNTRequest.GetIP(), regctrl))
                {
                    ShowError("抱歉, 系统设置了IP访问列表限制, 您无法访问本论坛", 0);
                    return;
                }
            }


            // 如果IP访问列表有设置则进行判断
            if (config.Ipdenyaccess.Trim() != "")
            {
                string[] regctrl = Utils.SplitString(config.Ipdenyaccess, "\n");
                if (Utils.InIPArray(DNTRequest.GetIP(), regctrl))
                {
                    ShowError("由于您严重违反了论坛的相关规定, 已被禁止访问.", 2);
                    return;
                }
            }

            // 如果当前用户请求页面不是登录页面并且当前用户非管理员并且论坛设定了时间段,当时间在其中的一个时间段内,则跳转到论坛登录页面
            if (oluserinfo.Adminid != 1 && DNTRequest.GetPageName() != "login.aspx")
            {
                if (Scoresets.BetweenTime(config.Visitbanperiods))
                {
                    ShowError("在此时间段内不允许访问本论坛", 2);
                    return;
                }
            }

            HttpContext.Current.Response.Write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n");

            if (config.Seokeywords != "")
            {
                HttpContext.Current.Response.Write("<meta name=\"keywords\" content=\"" + config.Seokeywords + "\" />\r\n");
            }
            if (config.Seodescription != "")
            {
                HttpContext.Current.Response.Write("<meta name=\"description\" content=\"" + config.Seodescription + "\" />\r\n");
            }
            HttpContext.Current.Response.Write(config.Seohead.Trim());
            HttpContext.Current.Response.Write("\r\n<link href=\"dntarchiver.css\" rel=\"stylesheet\" type=\"text/css\" />");

            if (config.Archiverstatus == 0)
            {
                ShowError("系统禁止使用Archiver", 3);
                HttpContext.Current.Response.End();
                return;
            }
        }
示例#5
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);
        }
示例#6
0
        /// <summary>
        #endregion 变量声明

        protected override void ShowPage()
        {
            pagetitle = "附件下载";

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

            // 获取附件ID
            attachmentid = DNTRequest.GetInt("attachmentid", -1);
            // 如果附件ID非数字
            if (attachmentid == -1)
            {
                AddErrLine("无效的附件ID");
                return;
            }

            if (DNTRequest.GetString("goodsattach") == "yes")
            {
            }
            else
            {
                // 获取该附件的信息
                attachmentinfo = Attachments.GetAttachmentInfo(attachmentid);
                // 如果该附件不存在
                if (attachmentinfo == null)
                {
                    AddErrLine("不存在的附件ID");
                    return;
                }
                topicid = attachmentinfo.Tid;

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

                topictitle = topic.Title;
                forumid    = topic.Fid;
                ForumInfo forum = Forums.GetForumInfo(forumid);
                forumname = forum.Name;

                pagetitle = Utils.RemoveHtml(forum.Name);
                forumnav  = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);

                //添加判断特殊用户的代码
                if (!Forums.AllowViewByUserID(forum.Permuserlist, userid))
                {
                    if (!Forums.AllowView(forum.Viewperm, usergroupid))
                    {
                        AddErrLine("您没有浏览该版块的权限");
                        if (userid == -1)
                        {
                            needlogin = true;
                        }
                        return;
                    }
                }

                //添加判断特殊用户的代码
                if (!Forums.AllowGetAttachByUserID(forum.Permuserlist, userid))
                {
                    if (forum.Getattachperm == "" || forum.Getattachperm == null)
                    {
                        // 验证用户是否有下载附件的权限
                        if (usergroupinfo.Allowgetattach != 1)
                        {
                            AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有下载或查看附件的权限");
                            if (userid == -1)
                            {
                                needlogin = true;
                            }
                            return;
                        }
                    }
                    else
                    {
                        if (!Forums.AllowGetAttach(forum.Getattachperm, usergroupid))
                        {
                            AddErrLine("您没有在该版块下载附件的权限");
                            if (userid == -1)
                            {
                                needlogin = true;
                            }
                            return;
                        }
                    }
                }

                // 检查用户是否拥有足够的阅读权限
                if ((attachmentinfo.Readperm > usergroupinfo.Readaccess) && (attachmentinfo.Uid != userid) && (!Moderators.IsModer(useradminid, userid, forumid)))
                {
                    AddErrLine("您的阅读权限不够");
                    if (userid == -1)
                    {
                        needlogin = true;
                    }
                    return;
                }
                //如果图片是不直接显示(作为附件显示) 并且不是作者本人下载都会扣分
                if (config.Showimages != 1 || !Utils.IsImgFilename(attachmentinfo.Filename.Trim()) && userid != attachmentinfo.Uid)
                {
                    if (UserCredits.UpdateUserCreditsByDownloadAttachment(userid) == -1)
                    {
                        AddErrLine("您的金币不足");
                        return;
                    }
                }

                if (attachmentinfo.Filename.IndexOf("http") < 0)
                {
                    if (!System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + "upload/" + attachmentinfo.Filename))
                    {
                        AddErrLine("该附件文件不存在或已被删除");
                        return;
                    }
                }

                Attachments.UpdateAttachmentDownloads(attachmentid);

                if (attachmentinfo.Filename.IndexOf("http") < 0)
                {
                    Utils.ResponseFile(AppDomain.CurrentDomain.BaseDirectory + "upload/" + attachmentinfo.Filename, System.IO.Path.GetFileName(attachmentinfo.Attachment), attachmentinfo.Filetype);
                    //ResponseFile("/Forum/" + "upload/" + attachmentinfo.Filename.Trim(), attachmentinfo.Filetype);
                }
                else
                {
                    //Utils.ResponseFile(attachmentinfo.Filename.Trim(), System.IO.Path.GetFileName(attachmentinfo.Filename).Trim(), attachmentinfo.Filetype);
                    ResponseFile(attachmentinfo.Filename.Trim(), attachmentinfo.Filetype);
                }
            }
        }
示例#7
0
        protected override void ShowPage()
        {
            pagetitle = "附件下载";

            if (attachmentid == -1)
            {
                AddErrLine("无效的附件ID");
                return;
            }

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

            if (DNTRequest.GetString("goodsattach").ToLower() == "yes")
                GetGoodsAttachInfo(attachmentid);
            else
            {
                // 获取该附件的信息
                attachmentinfo = Attachments.GetAttachmentInfo(attachmentid);
                if (attachmentinfo == null)
                {
                    AddErrLine("不存在的附件ID");
                    return;
                }
                //当前用户已上传但是还没有绑定到帖子的附件需要特殊处理,直接输出图片
                if ((userid > 0 || userid == -1) && userid == attachmentinfo.Uid && attachmentinfo.Tid == 0 && attachmentinfo.Filetype.StartsWith("image/"))
                {
                    HttpContext.Current.Response.Clear();
                    if(attachmentinfo.Filename.IndexOf("http") < 0 )
                       HttpContext.Current.Response.TransmitFile(BaseConfigs.GetForumPath + "upload/" + attachmentinfo.Filename.Trim());
                    else
                       HttpContext.Current.Response.Redirect(attachmentinfo.Filename.Trim());
                    
                    HttpContext.Current.Response.End();
                    return;
                }
                // 获取该主题的信息
                topic = Topics.GetTopicInfo(attachmentinfo.Tid);
                if (topic == null)
                {
                    AddErrLine("不存在的主题ID");
                    return;
                }

                ForumInfo forum = Forums.GetForumInfo(topic.Fid);
                pagetitle = Utils.RemoveHtml(forum.Name);
                if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
                {
                    AddErrLine(msg);
                    if (userid == -1)
                        needlogin = true;
                    return;
                }

                //添加判断特殊用户的代码
                if (!UserAuthority.CheckUsertAttachAuthority(forum, usergroupinfo, userid, ref msg))
                {
                    AddErrLine(msg);
                    if (userid == -1)
                        needlogin = true;
                    return;
                }

                ismoder = Moderators.IsModer(useradminid, userid, forum.Fid);
                // 检查用户是否拥有足够的阅读权限
                if ((attachmentinfo.Readperm > usergroupinfo.Readaccess) && (attachmentinfo.Uid != userid) && (!ismoder))
                {
                    AddErrLine("您的阅读权限不够");
                    if (userid == -1)
                        needlogin = true;
                    return;
                }

                //检查附件是否存在
                if (attachmentinfo.Filename.IndexOf("http") < 0 && !File.Exists(Utils.GetMapPath(string.Format(@"{0}upload/{1}", BaseConfigs.GetForumPath, attachmentinfo.Filename))))
                {
                    AddErrLine("该附件文件不存在或已被删除");
                    return;
                }

                //(!Utils.IsImgFilename(attachmentinfo.Filename.Trim()) || config.Showimages != 1):判断文件是否是图片和图片是否允许在帖子中直接显示
                //userid != attachmentinfo.Uid && !ismoder:判断当前下载用户是否是该附件的发布者和当前用户是否具有管理权限
                //Utils.StrIsNullOrEmpty(Utils.GetCookie("dnt_attachment_" + attachmentid))当前用户是否已经下载过该附件
                if ((!Utils.IsImgFilename(attachmentinfo.Filename.Trim()) || config.Showimages != 1) &&
                    (userid != attachmentinfo.Uid && !ismoder && Utils.StrIsNullOrEmpty(Utils.GetCookie("dnt_attachment_" + attachmentid))))
                {
                    if (Scoresets.IsSetDownLoadAttachScore() && UserCredits.UpdateUserExtCreditsByDownloadAttachment(userid, 1) == -1)
                    {
                        string addExtCreditsTip = "";
                        if (EPayments.IsOpenEPayments())
                            addExtCreditsTip = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>";
                        AddErrLine("您的积分不足" + addExtCreditsTip);
                        return;
                    }
                    //设置该附件已经下载的cookie
                    Utils.WriteCookie("dnt_attachment_" + attachmentid, "true", 5);
                }

                //检查附件是否存在
                if (AttachPaymentLogs.HasBoughtAttach(userid, usergroupinfo.Radminid, attachmentinfo))
                {
                    AddErrLine("该附件为交易附件, 请先行购买!");
                    return;
                }
                //如果是图片就不更新下载次数
                if (!Utils.IsImgFilename(attachmentinfo.Filename.Trim()))
                {
                    Attachments.UpdateAttachmentDownloads(attachmentid);
                }

                EntLibConfigInfo entLibConfigInfo = EntLibConfigs.GetConfig();
                //当使用企业版squid静态文件加速时
                if (attachmentinfo.Filename.IndexOf("http") < 0 && entLibConfigInfo != null && !Utils.StrIsNullOrEmpty(entLibConfigInfo.Attachmentdir))
                    attachmentinfo.Filename = EntLibConfigs.GetConfig().Attachmentdir.TrimEnd('/') + "/" + attachmentinfo.Filename;

                if (attachmentinfo.Filename.IndexOf("http") < 0)
                {   //当使用mongodb数据库存储附件及相关信息时
                    if (entLibConfigInfo != null && entLibConfigInfo.Cacheattachfiles.Enable && entLibConfigInfo.Cacheattachfiles.Attachpostid > 0 && entLibConfigInfo.Cacheattachfiles.Attachpostid < attachmentinfo.Pid)
                        Discuz.Cache.Data.DBCacheService.GetAttachFilesService().ResponseFile(attachmentinfo.Filename, Path.GetFileName(attachmentinfo.Attachment), attachmentinfo.Filetype);
                    else
                        Utils.ResponseFile(Utils.GetMapPath(BaseConfigs.GetForumPath + @"upload/" + attachmentinfo.Filename), Path.GetFileName(attachmentinfo.Attachment), attachmentinfo.Filetype);
                }
                else
                {
                    try //添加try语法, 以防止在并发访问情况下, 服务器端远程链接被关闭后出现应用程序 '警告'(事件查看器)
                    {
                        HttpContext.Current.Response.Clear();
                        HttpContext.Current.Response.Redirect(attachmentinfo.Filename.Trim());
                        HttpContext.Current.Response.End();
                    }
                    catch { }
                }
            }
        }
示例#8
0
        /// <summary>
        /// 创建帖子信息
        /// </summary>
        /// <param name="postmessage"></param>
        /// <returns></returns>
        public PostInfo CreatePostInfo(string postmessage)
        {
            PostInfo postinfo = new PostInfo();

            postinfo.Fid      = forumid;
            postinfo.Tid      = topicid;
            postinfo.Parentid = postinfo.Parentid;
            postinfo.Layer    = postinfo.Layer + 1;
            postinfo.Poster   = username;
            postinfo.Posterid = userid;
            bool ishtmlon = (Utils.StrToInt(DNTRequest.GetString("htmlon"), 0) == 1);

            if (useradminid == 1)
            {
                postinfo.Title = Utils.HtmlEncode(posttitle);
                if (usergroupinfo.Allowhtml == 0)
                {
                    postinfo.Message = Utils.HtmlEncode(postmessage);
                }
                else
                {
                    postinfo.Message = ishtmlon ? postmessage : Utils.HtmlEncode(postmessage);
                }
            }
            else
            {
                postinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString(config.Antispamposttitle)));
                if (usergroupinfo.Allowhtml == 0)
                {
                    postinfo.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage));
                }
                else
                {
                    postinfo.Message = ishtmlon ? ForumUtils.BanWordFilter(postmessage) :
                                       Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage));
                }
            }
            postinfo.Postdatetime = Utils.GetDateTime();

            if (Utils.StrIsNullOrEmpty(postinfo.Message.Replace(" ", "")))
            {
                AddErrLine("内容不能为空, 请返回修改!");
                return(postinfo);
            }

            if (useradminid != 1 && (ForumUtils.HasBannedWord(posttitle) || ForumUtils.HasBannedWord(postmessage)))
            {
                string bannedWord = ForumUtils.GetBannedWord(posttitle) == string.Empty ? ForumUtils.GetBannedWord(postmessage) : ForumUtils.GetBannedWord(posttitle);
                AddErrLine(string.Format("对不起, 您提交的内容包含不良信息  <font color=\"red\">{0}</font>, 请返回修改!", bannedWord));
                return(postinfo);
            }

            postinfo.Ip            = DNTRequest.GetIP();
            postinfo.Lastedit      = "";
            postinfo.Debateopinion = DNTRequest.GetInt("debateopinion", 0);
            postinfo.Invisible     = needaudit ? 1 : 0;

            // 如果当前用户非管理员并且论坛设定了发帖审核时间段,当前时间如果在其中的一个时间段内,则用户所发帖均为待审核状态
            if (useradminid != 1 && !Moderators.IsModer(useradminid, userid, forumid))
            {
                if (Scoresets.BetweenTime(config.Postmodperiods) || ForumUtils.HasAuditWord(postinfo.Title) || ForumUtils.HasAuditWord(postinfo.Message))
                {
                    postinfo.Invisible = 1;
                }
            }

            postinfo.Usesig      = TypeConverter.StrToInt(DNTRequest.GetString("usesig"));
            postinfo.Htmlon      = (usergroupinfo.Allowhtml == 1 && ishtmlon) ? 1 : postinfo.Htmlon;
            postinfo.Smileyoff   = (smileyoff != 0) ? smileyoff : TypeConverter.StrToInt(DNTRequest.GetString("smileyoff"));
            postinfo.Bbcodeoff   = (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1) ? TypeConverter.StrToInt(DNTRequest.GetString("bbcodeoff")) : 1;
            postinfo.Parseurloff = TypeConverter.StrToInt(DNTRequest.GetString("parseurloff"));
            postinfo.Attachment  = 0;
            postinfo.Rate        = 0;
            postinfo.Ratetimes   = 0;
            postinfo.Topictitle  = topic.Title;

            if ((postinfo.Title != "" && Utils.GetCookie("lastposttitle") == Utils.MD5(postinfo.Title)) || Utils.GetCookie("lastpostmessage") == Utils.MD5(postinfo.Message))
            {
                AddErrLine("请勿重复发帖");
                return(postinfo);
            }
            postinfo.Pid = Posts.CreatePost(postinfo);
            Utils.WriteCookie("lastposttitle", Utils.MD5(postinfo.Title));
            Utils.WriteCookie("lastpostmessage", Utils.MD5(postinfo.Message));
            return(postinfo);
        }
示例#9
0
        //public ArchiverPage() { }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (this.config.Archiverstatus == 2 && IsSearchEnginesGet())
            {
                Response.Redirect(this.OrganizeURL(Request.Url));
            }
            if (this.config.Archiverstatus == 3 && IsBrowserGet())
            {
                Response.Redirect(this.OrganizeURL(Request.Url));
            }
            if (Online.Meta.Count >= this.config.Maxonlines)
            {
                this.ShowError("抱歉,目前访问人数太多,你暂时无法访问论坛.", 0);
            }
            if (this.config.Nocacheheaders == 1)
            {
                Response.Buffer          = true;
                Response.ExpiresAbsolute = DateTime.Now.AddDays(-1.0);
                Response.Cache.SetExpires(DateTime.Now.AddDays(-1.0));
                Response.Expires      = 0;
                Response.CacheControl = "no-cache";
                Response.Cache.SetNoStore();
            }
            var onlineUserInfo = Online.UpdateInfo();

            this.userid      = onlineUserInfo.UserID;
            this.useradminid = (int)onlineUserInfo.AdminID;
            if (this.config.Closed == 1 && onlineUserInfo.AdminID != 1)
            {
                this.ShowError("", 1);
            }
            this.usergroupinfo = onlineUserInfo.Group;
            if (!this.usergroupinfo.AllowVisit)
            {
                this.ShowError("抱歉, 您所在的用户组 \"" + usergroupinfo.GroupTitle + "\" 不允许访问论坛", 2);
            }
            if (!config.Ipaccess.IsNullOrWhiteSpace() && !Utils.InIPArray(WebHelper.UserHost, Utils.SplitString(config.Ipaccess, "\n")))
            {
                this.ShowError("抱歉, 系统设置了IP访问列表限制, 您无法访问本论坛", 0);
                return;
            }
            if (!config.Ipdenyaccess.IsNullOrWhiteSpace() && Utils.InIPArray(WebHelper.UserHost, Utils.SplitString(config.Ipdenyaccess, "\n")))
            {
                this.ShowError("由于您严重违反了论坛的相关规定, 已被禁止访问.", 2);
                return;
            }
            if (onlineUserInfo.AdminID != 1 && DNTRequest.GetPageName() != "login.aspx" && Scoresets.BetweenTime(this.config.Visitbanperiods))
            {
                this.ShowError("在此时间段内不允许访问本论坛", 2);
                return;
            }
            Response.Write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n    ");
            if (!String.IsNullOrEmpty(config.Seokeywords))
            {
                Response.Write("<meta name=\"keywords\" content=\"" + this.config.Seokeywords + "\" />\r\n");
            }
            if (!String.IsNullOrEmpty(config.Seodescription))
            {
                Response.Write("<meta name=\"description\" content=\"" + this.config.Seodescription + "\" />\r\n");
            }
            Response.Write(this.config.Seohead.Trim());
            Response.Write("\r\n<link href=\"dntarchiver.css\" rel=\"stylesheet\" type=\"text/css\" />");
            if (this.config.Archiverstatus == 0)
            {
                this.ShowError("系统禁止使用Archiver", 3);
                Response.End();
            }
        }
示例#10
0
        protected override void ShowPage()
        {
            this.pagetitle = "附件下载";
            if (this.attachmentid == -1)
            {
                base.AddErrLine("无效的附件ID");
                return;
            }
            if (this.useradminid != 1 && !this.usergroupinfo.DisablePeriodctrl)
            {
                string str = "";
                if (Scoresets.BetweenTime(this.config.Attachbanperiods, out str))
                {
                    base.AddErrLine("在此时间段( " + str + " )内用户不可以下载附件");
                    return;
                }
            }

            var att = Attachment.FindByID(attachmentid);

            this.attachmentinfo = att;
            if (att == null)
            {
                base.AddErrLine("不存在的附件ID");
                return;
            }
            if ((userid > 0 || userid == -1) && userid == att.Uid && att.Tid == 0 && att.FileType.StartsWith("image/"))
            {
                Response.Clear();
                if (att.IsLocal)
                {
                    Response.TransmitFile(att.FullFileName);
                }
                else
                {
                    Response.Redirect(att.FileName);
                }

                Response.End();
                return;
            }
            this.topic = Topic.FindByID(att.Tid);
            if (this.topic == null)
            {
                base.AddErrLine("不存在的主题ID");
                return;
            }
            var fi = XForum.FindByID(this.topic.Fid);

            this.pagetitle = Utils.RemoveHtml(fi.Name);
            if (!UserAuthority.VisitAuthority(fi, this.usergroupinfo, userid, ref this.msg))
            {
                base.AddErrLine(this.msg);
                if (userid == -1)
                {
                    this.needlogin = true;
                }
                return;
            }
            if (!UserAuthority.CheckUsertAttachAuthority(fi, this.usergroupinfo, userid, ref this.msg))
            {
                base.AddErrLine(this.msg);
                if (userid == -1)
                {
                    this.needlogin = true;
                }
                return;
            }
            this.ismoder = Moderators.IsModer(this.useradminid, userid, fi.ID);
            var q = WebHelper.RequestInt("q");

            if (att.ReadPerm > this.usergroupinfo.Readaccess && att.Uid != userid && !this.ismoder)
            {
                if (q != 1)
                {
                    Response.Clear();
                    Response.Redirect("/images/common/imgerror2.png");
                    Response.End();
                    return;
                }
                base.AddErrLine("您的阅读权限不够");
                if (userid == -1)
                {
                    this.needlogin = true;
                }
                return;
            }

            if (att.IsLocal && !File.Exists(att.FullFileName))
            {
                base.AddErrLine("该附件文件不存在或已被删除");
                return;
            }
            var key = "attachment_" + attachmentid;

            if ((!att.ImgPost || config.Showimages != 1) && userid != att.Uid && !ismoder && Utils.GetCookie(key).IsNullOrEmpty())
            {
                if (Scoresets.IsSetDownLoadAttachScore() && CreditsFacade.IsEnoughCreditsDownloadAttachment(userid, 1) && CreditsFacade.DowlnLoadAttachments(userid, 1) == -1)
                {
                    string msg = "";
                    if (EPayments.IsOpenEPayments())
                    {
                        msg = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>";
                    }

                    base.AddErrLine("您的积分不足" + msg);
                    return;
                }
                Utils.WriteCookie(key, "true", 5);
            }
            if (AttachPaymentLog.HasBoughtAttach(userid, this.usergroupinfo.RadminID, att))
            {
                if (q != 1)
                {
                    Response.Clear();
                    Response.Redirect("/images/common/imgerror2.png");
                    Response.End();
                    return;
                }
                base.AddErrLine("该附件为交易附件, 请先行购买!");
                return;
            }

            if (!attachmentinfo.ImgPost)
            {
                attachmentinfo.Downloads++;
                attachmentinfo.Save();
            }
            if (!att.IsLocal)
            {
                try
                {
                    Response.Clear();
                    Response.Redirect(att.FileName);
                    Response.End();
                }
                catch { }
                return;
            }

            Utils.ResponseFile(att.FullFileName, Path.GetFileName(att.Name), att.FileType);
        }
示例#11
0
文件: postreply.cs 项目: xiongeee/BBX
        public Post CreatePostInfo(string postmessage)
        {
            var pi = new Post();

            pi.Fid = this.forumid;
            pi.Tid = this.topicid;
            pi.Layer++;
            //pi.Poster = this.username;
            //pi.Posterid = this.userid;
            bool flag = DNTRequest.GetString("htmlon").ToInt(0) == 1;
            var  msg  = pi.Message;

            if (this.useradminid == 1)
            {
                pi.Title = Utils.HtmlEncode(this.posttitle);
                if (!this.usergroupinfo.AllowHtml)
                {
                    msg = Utils.HtmlEncode(postmessage);
                }
                else
                {
                    msg = (flag ? postmessage : Utils.HtmlEncode(postmessage));
                }
            }
            else
            {
                pi.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString(this.config.Antispamposttitle)));
                if (!this.usergroupinfo.AllowHtml)
                {
                    msg = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage));
                }
                else
                {
                    msg = (flag ? ForumUtils.BanWordFilter(postmessage) : Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage)));
                }
            }
            pi.Message = msg;
            //pi.Postdatetime = Utils.GetDateTime();
            if (Utils.StrIsNullOrEmpty(msg.Replace("\u3000", "")))
            {
                base.AddErrLine("内容不能为空, 请返回修改!");
                return(pi);
            }
            if (this.useradminid != 1 && (ForumUtils.HasBannedWord(this.posttitle) || ForumUtils.HasBannedWord(postmessage)))
            {
                string arg = (ForumUtils.GetBannedWord(this.posttitle) == string.Empty) ? ForumUtils.GetBannedWord(postmessage) : ForumUtils.GetBannedWord(this.posttitle);
                base.AddErrLine(string.Format("对不起, 您提交的内容包含不良信息  <font color=\"red\">{0}</font>, 请返回修改!", arg));
                return(pi);
            }
            //pi.Ip = WebHelper.UserHost;
            //pi.Lastedit = "";
            //pi.Debateopinion = DNTRequest.GetInt("debateopinion", 0);
            var debateopinion = DNTRequest.GetInt("debateopinion", 0);

            pi.Invisible = (this.needaudit ? 1 : 0);
            if (this.useradminid != 1 && !Moderators.IsModer(this.useradminid, this.userid, this.forumid) && (Scoresets.BetweenTime(this.config.Postmodperiods) || ForumUtils.HasAuditWord(pi.Title) || ForumUtils.HasAuditWord(msg)))
            {
                pi.Invisible = 1;
            }
            pi.UseSig      = DNTRequest.GetInt("usesig");
            pi.HtmlOn      = (this.usergroupinfo.AllowHtml && flag) ? 1 : 0;
            pi.SmileyOff   = ((this.smileyoff != 0) ? this.smileyoff : DNTRequest.GetInt("smileyoff"));
            pi.BBCodeOff   = ((this.usergroupinfo.AllowCusbbCode && this.forum.Allowbbcode == 1) ? DNTRequest.GetInt("bbcodeoff") : 1);
            pi.ParseUrlOff = DNTRequest.GetInt("parseurloff");
            //pi.Attachment = 0;
            //pi.Rate = 0;
            //pi.Ratetimes = 0;
            //pi.Title = this.topic.Title;
            if ((pi.Title != "" && Utils.GetCookie("lastposttitle") == Utils.MD5(pi.Title)) || Utils.GetCookie("lastpostmessage") == Utils.MD5(msg))
            {
                base.AddErrLine("请勿重复发帖");
                return(pi);
            }
            //pi.Pid = Posts.CreatePost(pi);
            pi.Create();

            if (debateopinion > 0)
            {
                Debate.CreateDebateExpandInfo(pi.Tid, pi.ID, debateopinion, 0);
            }

            Utils.WriteCookie("lastposttitle", Utils.MD5(pi.Title));
            Utils.WriteCookie("lastpostmessage", Utils.MD5(msg));
            ForumUtils.WriteCookie("clearUserdata", "forum");
            return(pi);
        }
示例#12
0
        protected override void ShowPage()
        {
            if (config.Enablemall == 0) //未启用交易模式
            {
                AddErrLine("系统未开启交易模式, 当前页面暂时无法访问!");
                return;
            }

            #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");
            //    realuserid = Users.CheckTempUserInfo(tempusername, temppassword, question, answer);
            //    if (realuserid == -1)
            //    {
            //        AddErrLine("临时帐号登录失败,无法继续发帖。");
            //        return;
            //    }
            //    else
            //    {
            //        userid = realuserid;
            //        username = tempusername;
            //        usergroupinfo = UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(userid).Groupid);
            //        usergroupid = usergroupinfo.Groupid;
            //        useradminid = Users.GetShortUserInfo(userid).Adminid;
            //    }
            //}
            #endregion

            #region 获取分类对象信息
            int categoryid = DNTRequest.GetInt("categoryid", -1);

            //如果是提交...
            if (ispost)
            {
                categoryid = DNTRequest.GetInt("goodscategoryid", -1);
            }

            if (categoryid > 0)
            {
                goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(categoryid);
            }

            if (goodscategoryinfo == null)
            {
                goodscategoryinfo            = new Goodscategoryinfo();
                goodscategoryinfo.Categoryid = -1;
            }

            if (goodscategoryinfo.Fid <= 0)
            {
                allowpostgoods = false;
                forumnav       = "";
                AddErrLine("错误的商品分类ID");
                return;
            }
            #endregion

            canhtmltitle     = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup);
            firstpagesmilies = Caches.GetSmiliesFirstPageCache();

            //内容设置为空;
            message = "";

            if (config.Enablemall == 1) //开启普通模式
            {
                forumid  = GoodsCategories.GetCategoriesFid(categoryid);
                forumnav = "";
                if (forumid == -1)
                {
                    allowpostgoods = false;
                    AddErrLine("错误的商品分类ID");
                    return;
                }
                else
                {
                    forum = Forums.GetForumInfo(forumid);
                    if (forum == null || forum.Layer == 0)
                    {
                        allowpostgoods = false;
                        AddErrLine("错误的商品分类ID");
                        return;
                    }

                    if (forum.Istrade <= 0)
                    {
                        allowpostgoods = false;
                        AddErrLine("当前版块不允许发布商品");
                        return;
                    }

                    forumname = forum.Name;
                    pagetitle = Utils.RemoveHtml(forum.Name);
                    forumnav  = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
                    enabletag = (config.Enabletag & forum.Allowtag) == 1;
                }
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                pagetitle          = "发布商品";
                forumnav           = "";
                enabletag          = true;
                forum              = new ForumInfo();
                forum.Allowsmilies = 1;
                forum.Allowbbcode  = 1;
            }

            //得到用户可以上传的文件类型
            StringBuilder sbAttachmentTypeSelect = new StringBuilder();
            if (!usergroupinfo.Attachextensions.Trim().Equals(""))
            {
                sbAttachmentTypeSelect.Append("[id] in (");
                sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions);
                sbAttachmentTypeSelect.Append(")");
            }
            if (config.Enablemall == 1) //开启普通模式
            {
                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;          //今天可上传得大小

            parseurloff = 0;
            bbcodeoff   = 1;

            if (config.Enablemall == 1) //开启普通模式
            {
                smileyoff = 1 - forum.Allowsmilies;
                allowimg  = forum.Allowimgcode;

                if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1)
                {
                    bbcodeoff = 0;
                }
            }


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

            if (config.Enablemall == 1) //开启普通模式
            {
                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 (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限
                    {
                        if (useradminid != 1 && (usergroupinfo.Allowvisit != 1 || usergroupinfo.Allowtrade != 1))
                        {
                            AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布商品的权限");
                            return;
                        }
                    }
                    else//当板块权限不为空,按照板块权限
                    {
                        if (!Forums.AllowView(forum.Viewperm, usergroupid))
                        {
                            AddErrLine("您没有发布商品的权限");
                            return;
                        }
                    }
                }

                if (!Forums.AllowPostByUserID(forum.Permuserlist, userid))        //判断当前用户在当前版块发布商品权限
                {
                    if (forum.Postperm == null || forum.Postperm == string.Empty) //权限设置为空时,根据用户组权限判断
                    {
                        // 验证用户是否有发布商品的权限
                        if (useradminid != 1 && usergroupinfo.Allowtrade != 1)
                        {
                            AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布商品的权限");
                            return;
                        }
                    }
                    else//权限设置不为空时,根据板块权限判断
                    {
                        if (!Forums.AllowPost(forum.Postperm, usergroupid))
                        {
                            AddErrLine("您没有发布商品的权限");
                            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;
                        }
                    }
                }
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                canpostattach = true;
                allowimg      = 1;
                smileyoff     = 0;
            }


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

            // 如果是受灌水限制用户, 则判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            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)
                {
                    ShortUserInfo shortUserInfo = Discuz.Data.Users.GetShortUserInfo(userid);
                    string        joindate      = (shortUserInfo != null) ? shortUserInfo.Joindate : "";
                    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);

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

            //如果不是提交...
            if (!ispost)
            {
                AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
                smilies           = Caches.GetSmiliesCache();
                smilietypes       = Caches.GetSmilieTypesCache();
                customeditbuttons = Caches.GetCustomEditButtonList();
            }
            else
            {
                SetBackLink(string.Format("postgoods.aspx?categoryid={0}&restore=1", categoryid));

                string postmessage = DNTRequest.GetString("message");

                ForumUtils.WriteCookie("postmessage", postmessage);

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

                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 + " 个字符");
                }

                if (postmessage.Equals("") || postmessage.Replace(" ", "").Equals(""))
                {
                    AddErrLine("商品内容不能为空");
                }

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

                //新用户广告强力屏蔽检查
                if (config.Disablepostad == 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 (config.Enablemall == 1) //开启普通模式
                    {
                        if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userid))
                        {
                            if (!Forums.AllowPostAttach(forum.Postattachperm, usergroupid))
                            {
                                AddErrLine("您没有在该版块上传附件的权限");
                            }
                            else if (usergroupinfo.Allowpostattach != 1)
                            {
                                AddErrLine(string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", usergroupinfo.Grouptitle));
                            }
                        }
                    }
                }

                if (IsErr())
                {
                    return;
                }

                int iconid = DNTRequest.GetInt("iconid", 0);
                if (iconid > 15 || iconid < 0)
                {
                    iconid = 0;
                }

                string curdatetime = Utils.GetDateTime();

                Goodsinfo goodsinfo = new Goodsinfo();

                //当在高级模式下则绑定相应店铺信息
                if (config.Enablemall == 2)
                {
                    Shopinfo shopinfo = Shops.GetShopByUserId(user.Uid);
                    if (shopinfo != null)
                    {
                        goodsinfo.Shopid = shopinfo.Shopid;
                    }
                }
                goodsinfo.Categoryid         = goodscategoryinfo.Categoryid;
                goodsinfo.Parentcategorylist = goodscategoryinfo.Parentidlist;
                goodsinfo.Recommend          = DNTRequest.GetString("recommend") == "on" ? 1 : 0;
                goodsinfo.Discount           = DNTRequest.GetInt("discount", 0);
                goodsinfo.Selleruid          = userid;
                goodsinfo.Seller             = username;
                goodsinfo.Account            = DNTRequest.GetString("account");
                goodsinfo.Price     = Convert.ToDecimal(DNTRequest.GetFormFloat("price", 1).ToString());
                goodsinfo.Amount    = DNTRequest.GetInt("amount", 0);
                goodsinfo.Quality   = DNTRequest.GetInt("quality", 0);
                goodsinfo.Lid       = DNTRequest.GetInt("locus_2", 0);
                goodsinfo.Locus     = Locations.GetLocusByLID(goodsinfo.Lid);
                goodsinfo.Transport = DNTRequest.GetInt("transport", 0);
                if (goodsinfo.Transport != 0)
                {
                    goodsinfo.Ordinaryfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_mail", 0).ToString());
                    goodsinfo.Expressfee  = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_express", 0).ToString());
                    goodsinfo.Emsfee      = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_ems", 0).ToString());
                }
                goodsinfo.Itemtype = DNTRequest.GetInt("itemtype", 0);

                DateTime dateline;
                switch (DNTRequest.GetInt("_now", 0))
                {
                case 1: dateline = Convert.ToDateTime(string.Format("{0} {1}:{2}:00", DNTRequest.GetString("_date"), DNTRequest.GetInt("_hour", 0), DNTRequest.GetInt("_minute", 0))); break; //设定

                case 2: dateline = Convert.ToDateTime("1900-01-01 00:00:00"); break;                                                                                                          //返回100年之后的日期作为"暂不设置"

                default: dateline = DateTime.Now; break;                                                                                                                                      //立即
                }

                goodsinfo.Dateline   = dateline;
                goodsinfo.Expiration = Convert.ToDateTime(DNTRequest.GetString("expiration"));
                goodsinfo.Lastbuyer  = "";
                goodsinfo.Lasttrade  = Convert.ToDateTime("1900-01-01 00:00:00");
                goodsinfo.Lastupdate = Convert.ToDateTime(Utils.GetDateTime());
                goodsinfo.Totalitems = 0;
                goodsinfo.Tradesum   = 0;
                goodsinfo.Closed     = 0;
                goodsinfo.Aid        = 0;
                goodsinfo.Costprice  = Convert.ToDecimal(DNTRequest.GetFormFloat("costprice", 1).ToString());
                goodsinfo.Invoice    = DNTRequest.GetInt("invoice", 0);
                goodsinfo.Repair     = DNTRequest.GetInt("repair", 0);
                if (useradminid == 1)
                {
                    goodsinfo.Message = Utils.HtmlEncode(postmessage);
                }
                else
                {
                    goodsinfo.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage));
                }

                goodsinfo.Otherlink = "";
                int readperm = DNTRequest.GetInt("readperm", 0);
                goodsinfo.Readperm  = readperm > 255 ? 255 : readperm;
                goodsinfo.Tradetype = DNTRequest.GetInt("tradetype", 0);

                if (goodsinfo.Tradetype == 1 && Utils.StrIsNullOrEmpty(goodsinfo.Account)) //当为支付宝在线支付方式下,如果"支付宝账户"为空时
                {
                    AddErrLine("请输入支付宝帐号信息。");
                    return;
                }

                goodsinfo.Viewcount    = 0;
                goodsinfo.Displayorder = DNTRequest.GetString("displayorder") == "on" ? 0 : -3;

                if (config.Enablemall == 1) //当为版块交易帖是时
                {
                    if (forum.Modnewposts == 1 && useradminid != 1)
                    {
                        if (useradminid > 1)
                        {
                            if (disablepost != 1)
                            {
                                goodsinfo.Displayorder = -2;
                                disablepost            = 0;
                            }
                        }
                        else
                        {
                            goodsinfo.Displayorder = -2;
                            disablepost            = 0;
                        }
                    }
                }

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

                goodsinfo.Bbcodeoff = 1;
                if (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1)
                {
                    goodsinfo.Bbcodeoff = Utils.StrToInt(DNTRequest.GetString("bbcodeoff"), 0);
                }

                goodsinfo.Parseurloff = Utils.StrToInt(DNTRequest.GetString("parseurloff"), 0);

                if (useradminid == 1)
                {
                    goodsinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title"));
                }
                else
                {
                    goodsinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title")));
                }

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

                //标签(Tag)操作
                string   tags      = DNTRequest.GetString("tags").Trim();
                string[] tagsArray = null;
                if (enabletag && tags != string.Empty)
                {
                    tagsArray = Utils.SplitString(tags, " ", true, 2, 10);
                    if (tagsArray.Length > 0)
                    {
                        if (goodsinfo.Magic == 0)
                        {
                            goodsinfo.Magic = 10000;
                        }

                        goodsinfo.Magic = Utils.StrToInt(goodsinfo.Magic.ToString() + "1", 0);
                    }
                }

                goodsinfo.Goodsid = Goods.CreateGoods(goodsinfo);
                //保存htmltitle
                if (canhtmltitle && htmltitle != string.Empty && htmltitle != goodsinfo.Title)
                {
                    Goods.WriteHtmlSubjectFile(htmltitle, goodsinfo.Goodsid);
                }

                if (enabletag && tagsArray != null && tagsArray.Length > 0)
                {
                    DbProvider.GetInstance().CreateGoodsTags(string.Join(" ", tagsArray), goodsinfo.Goodsid, userid, curdatetime);
                    GoodsTags.WriteGoodsTagsCacheFile(goodsinfo.Goodsid);
                }

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

                int watermarkstatus = (forum.Disablewatermark == 1) ? 0 : config.Watermarkstatus;

                Goodsattachmentinfo[] attachmentinfo = Discuz.Mall.MallUtils.SaveRequestFiles(categoryid, 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 = GoodsAttachments.BindAttachment(attachmentinfo, goodsinfo.Goodsid, sb, goodsinfo.Categoryid, userid);
                    int[]  aid             = GoodsAttachments.CreateAttachments(attachmentinfo);
                    string tempMessage     = GoodsAttachments.FilterLocalTags(aid, attachmentinfo, goodsinfo.Message);

                    goodsinfo.Goodspic = (attachmentinfo.Length > 0) ? attachmentinfo[0].Filename : "";
                    if (!tempMessage.Equals(goodsinfo.Message))
                    {
                        goodsinfo.Message = tempMessage;
                        goodsinfo.Aid     = aid[0];
                    }
                    Goods.UpdateGoods(goodsinfo);

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

                //加入相册
                #region 相册
                if (config.Enablealbum == 1 && apb != null)
                {
                    sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username));
                }
                #endregion
                if (config.Enablemall == 1) //开启普通模式
                {
                    OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forumname, -1, "");
                }

                if (sb.Length > 0)
                {
                    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>");
                    SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid), sb.ToString());
                }
                else
                {
                    SetShowBackLink(false);

                    if (config.Enablemall == 1 && forum.Modnewposts == 1 && useradminid != 1)
                    {
                        if (useradminid != 1)
                        {
                            if (disablepost == 1)
                            {
                                if (goodsinfo.Displayorder == -3)
                                {
                                    SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但未上架. 您可到用户中心进行上架操作!");
                                }
                                else
                                {
                                    SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid),
                                                     "发布商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回 " + forumname + "</a>)<br />");
                                }
                            }
                            else
                            {
                                SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但需要经过审核才可以显示. 返回商品列表");
                            }
                        }
                        else
                        {
                            SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 返回商品列表");
                        }
                    }
                    else
                    {
                        if (goodsinfo.Displayorder == -3)
                        {
                            SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但未上架. 您可到用户中心进行上架操作!");
                        }
                        else
                        {
                            SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid),
                                             "发布商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回</a>)<br />");
                        }
                    }
                }

                ForumUtils.WriteCookie("postmessage", "");
            }

            topicattachscorefield = 0;
        }
示例#13
0
        private string condition = ""; //查询条件


        protected override void ShowPage()
        {
            if (config.Enablemall == 0) //未启用交易模式
            {
                AddErrLine("系统未开启交易模式, 当前页面暂时无法访问!");
                return;
            }
            else
            {
                goodscategoryfid = Discuz.Mall.GoodsCategories.GetGoodsCategoryWithFid();
            }

            forumnav      = "";
            forumallowrss = 0;
            if (categoryid <= 0)
            {
                AddErrLine("无效的商品分类ID");
                return;
            }

            if (config.Enablemall == 2) //开启高级模式
            {
                AddLinkRss("mallgoodslist.aspx?categoryid=" + categoryid, "商品列表");
                AddErrLine("当前页面在开启商城(高级)模式下无法访问, 系统将会重定向到商品列表页面!");
                return;
            }

            goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(categoryid);
            if (goodscategoryinfo != null && goodscategoryinfo.Categoryid > 0)
            {
                forumid = GoodsCategories.GetCategoriesFid(goodscategoryinfo.Categoryid);
            }
            else
            {
                AddErrLine("无效的商品分类ID");
                return;
            }

            ///得到广告列表
            ///头部
            headerad   = Advertisements.GetOneHeaderAd("", forumid);
            footerad   = Advertisements.GetOneFooterAd("", forumid);
            pagewordad = Advertisements.GetPageWordAd("", forumid);
            doublead   = Advertisements.GetDoubleAd("", forumid);
            floatad    = Advertisements.GetFloatAd("", forumid);
            mediaad    = Advertisements.GetMediaAd(templatepath, "", forumid);

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

            if (admingroupinfo != null)
            {
                this.disablepostctrl = admingroupinfo.Disablepostctrl;
            }

            if (forumid == -1)
            {
                AddLinkRss("tools/rss.aspx", "最新商品");
                AddErrLine("无效的商品分类ID");
                return;
            }
            else
            {
                forum = Forums.GetForumInfo(forumid);
                // 检查是否具有版主的身份
                if (useradminid > 0)
                {
                    ismoder = Moderators.IsModer(useradminid, userid, forumid);
                }

                #region 对搜索条件进行检索

                string orderStr = "goodsid";

                if (DNTRequest.GetString("search").Trim() != "") //进行指定查询
                {
                    //所在城市信息
                    cond = DNTRequest.GetInt("locus_2", -1);
                    if (cond < 1)
                    {
                        condition = "";
                    }
                    else
                    {
                        locus     = Locations.GetLocusByLID(cond);
                        condition = "AND [lid] = " + cond;
                    }

                    //排序的字段
                    order = DNTRequest.GetInt("order", -1);
                    switch (order)
                    {
                    case 2:
                        orderStr = "expiration";     //到期日
                        break;

                    case 1:
                        orderStr = "price";     //商品价格
                        break;

                    default:
                        orderStr = "goodsid";
                        break;
                    }

                    if (DNTRequest.GetInt("direct", -1) == 0)
                    {
                        direct = 0;
                    }
                }

                #endregion

                if (forum == null)
                {
                    if (config.Rssstatus == 1)
                    {
                        AddLinkRss("tools/rss.aspx", Utils.EncodeHtml(config.Forumtitle) + " 最新商品");
                    }

                    AddErrLine("不存在的商品分类ID");
                    return;
                }


                //当版块有外部链接时,则直接跳转
                if (forum.Redirect != null && forum.Redirect != string.Empty)
                {
                    System.Web.HttpContext.Current.Response.Redirect(forum.Redirect);
                    return;
                }

                if (forum.Istrade <= 0)
                {
                    AddErrLine("当前版块不允许商品交易");
                    forumnav = "";
                    return;
                }

                if (forum.Fid < 1)
                {
                    if (config.Rssstatus == 1 && forum.Allowrss == 1)
                    {
                        AddLinkRss("tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新商品");
                    }

                    AddErrLine("不存在的商品分类ID");
                    return;
                }
                if (config.Rssstatus == 1)
                {
                    AddLinkRss("tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新商品");
                }

                forumname     = forum.Name;
                pagetitle     = Utils.RemoveHtml(forum.Name);
                subforumcount = forum.Subforumcount;
                forumnav      = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
                navhomemenu   = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);

                //更新页面Meta中的Description项, 提高SEO友好性
                UpdateMetaInfo(config.Seokeywords, forum.Description, config.Seohead);

                // 是否显示版块密码提示 1为显示, 0不显示
                showforumlogin = 1;
                // 如果版块未设密码
                if (forum.Password == "")
                {
                    showforumlogin = 0;
                }
                else
                {
                    // 如果检测到相应的cookie正确
                    if (Utils.MD5(forum.Password) == ForumUtils.GetCookie("forum" + forumid.ToString() + "password"))
                    {
                        showforumlogin = 0;
                    }
                    else
                    {
                        // 如果用户提交的密码正确则保存cookie
                        if (forum.Password == DNTRequest.GetString("forumpassword"))
                        {
                            ForumUtils.WriteCookie("forum" + forumid.ToString() + "password", Utils.MD5(forum.Password));
                            showforumlogin = 0;
                        }
                    }
                }

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


                ////判断是否有发主题的权限
                if (userid > -1 && Forums.AllowPostByUserID(forum.Permuserlist, userid))
                {
                    canposttopic = true;
                }

                if (forum.Postperm == null || forum.Postperm == string.Empty) //权限设置为空时,根据用户组权限判断
                {
                    // 验证用户是否有发表交易的权限
                    if (usergroupinfo.Allowtrade == 1)
                    {
                        canposttopic = true;
                    }
                }
                else if (Forums.AllowPost(forum.Postperm, usergroupid))
                {
                    canposttopic = true;
                }

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

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

                //得到子分类JSON格式
                subcategoriesjson = GoodsCategories.GetSubCategoriesJson(categoryid);
                //得到当前用户请求的页数
                pageid = DNTRequest.GetInt("page", 1);
                //获取主题总数
                goodscount = Goods.GetGoodsCount(categoryid, condition);

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

                if (gpp <= 0)
                {
                    gpp = 16;
                }

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

                if (forum.Layer > 0)
                {
                    //获取总页数
                    pagecount = goodscount % gpp == 0 ? goodscount / gpp : goodscount / gpp + 1;
                    if (pagecount == 0)
                    {
                        pagecount = 1;
                    }

                    if (pageid > pagecount)
                    {
                        pageid = pagecount;
                    }

                    goodslist = Goods.GetGoodsInfoList(categoryid, gpp, pageid, condition, orderStr, direct);

                    ForumUtils.WriteCookie("referer", string.Format("showgoodslist.aspx?categoryid={0}&page={1}&order={2}&direct={3}&locus2={4}&search={5}", categoryid.ToString(), pageid.ToString(), orderStr, direct, cond, DNTRequest.GetString("search")));

                    //得到页码链接
                    if (DNTRequest.GetString("search") == "")
                    {
                        if (categoryid == 0)
                        {
                            if (config.Aspxrewrite == 1)
                            {
                                pagenumbers = Utils.GetStaticPageNumbers(pageid, pagecount, "showgoodslist-" + categoryid.ToString(), config.Extname, 8);
                            }
                            else
                            {
                                pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showgoodslist.aspx?categoryid=" + categoryid.ToString(), 8);
                            }
                        }
                        else //当有类型条件时
                        {
                            pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showgoodslist.aspx?categoryid=" + categoryid, 8);
                        }
                    }
                    else
                    {
                        pagenumbers = Utils.GetPageNumbers(pageid, pagecount,
                                                           "showgoodslist.aspx?search=" + DNTRequest.GetString("search") + "&order=" + 2 + "&direct=" + direct + "&categoryid=" + categoryid + "&locus_2=" + cond, 8);
                    }
                }
            }


            forumlistboxoptions = Caches.GetForumListBoxOptionsCache();

            OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, forumname, -1, "");


            showforumonline = false;
            onlineiconlist  = Caches.GetOnlineGroupIconList();
            if (forumtotalonline < config.Maxonlinelist || 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;
            }

            ForumUtils.UpdateVisitedForumsOptions(forumid);
            visitedforumsoptions = ForumUtils.GetVisitedForumsOptions(config.Visitedforums);
            //因为目前还未提供RSS功能,所以下面两项为0
            forumallowrss = 0;
        }
示例#14
0
文件: showforum.cs 项目: xiongeee/BBX
        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);
        }