Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int threadID = _Request.Get <int>("threadID", Method.Get, 0);

            if (threadID < 1)
            {
                ShowError(new InvalidParamError("threadID").Message);
            }

            thread = PostBOV5.Instance.GetThread(threadID);
            if (thread == null)
            {
                ShowError("该主题不存在或者已被删除!");
            }

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(thread.ForumID);

            if (thread.PostUserID != MyUserID && (!permission.Can(My, ForumPermissionSetNode.Action.AlwaysViewContents)))
            {
                if (!thread.IsBuyed(My))
                {
                    ShowError("您还没有购买此主题,不能查看购买记录!");
                }
            }

            TradePoint = ForumPointAction.Instance.GetUserPoint(thread.PostUserID, ForumPointValueType.SellThread, thread.ForumID);

            int pageNumber = _Request.Get <int>("page", Method.Get, 1);

            ExchangeList = PostBOV5.Instance.GetThreadExchanges(threadID, pageNumber, pageSize, out totalCount, out totalMoney);

            WaitForFillSimpleUsers <ThreadExchange>(ExchangeList);

            SetPager("list", null, pageNumber, pageSize, totalCount);
        }
Пример #2
0
        protected bool IsShieldedUser(PostV5 post)
        {
            if (UserBO.Instance.IsBanned(post.UserID, post.ForumID))
            {
                return(true);
            }

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);

            return(permission.Can(post.UserID, ForumPermissionSetNode.Action.DisplayContent) == false);
        }
Пример #3
0
        private void ProcessDownload3(HttpContext context, BasicThread thread, PostV5 post, int diskFileID)
        {
            Forum forum = ForumBO.Instance.GetForum(post.ForumID);
            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);

            if (false == permission.Can(userID, ForumPermissionSetNode.Action.ViewAttachment) && attachment.UserID != userID)
            {
                ShowErrorMessage(context, "您没有权限下载附件!", "您没有权限下载附件.gif");
                return;
            }

            if (!AlwaysViewContents(forum, post.UserID) && attachment.UserID != userID)//检查是否是出售的帖子
            {
                AuthUser user  = User.Current;
                bool     isBuy = false;
                if (user.BuyedThreads.TryGetValue(post.ThreadID, out isBuy))//缓存中获取
                {
                }
                if (!isBuy)
                {
                    if (thread.Price > 0)
                    {
                        if (post.PostType == MaxLabs.bbsMax.Enums.PostType.ThreadContent)
                        {
                            if (false == post.IsFreeDiskFileID(diskFileID) && false == post.IsFreeAttachmentID(attachment.AttachmentID))
                            {
                                if (!thread.IsOverSellDays(forum.ForumSetting) && !thread.IsBuyed(user))
                                {
                                    Context.ThrowError <CustomError>(new CustomError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!"));
                                    return;
                                    //Bbs3Globals.ShowError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!", 0);
                                }
                            }
                        }
                    }
                }
            }

            if (CheckPermission(forum.ForumSetting) || AlwaysViewContents(forum, attachment.UserID))
            {
                if (false == OutputFileByID(context, attachment.FileID, attachment.FileName, attachment.FileType, outputMode))
                {
                    ShowErrorMessage(context, "该附件不存在,可能被移动或被删除!", "文件不存在.gif");
                }
            }
            else
            {
                ShowErrorMessage(context, "你还没有购买此附件,不能下载!", "needpay.gif");
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int attachmentID = _Request.Get <int>("attachmentID", Method.Get, 0);

            if (attachmentID < 1)
            {
                ShowError(new InvalidParamError("attachmentID").Message);
            }

            attachment = PostBOV5.Instance.GetAttachment(attachmentID, false);
            if (attachment == null)
            {
                ShowError("该附件不存在或者已被删除!");
            }

            PostV5 post = PostBOV5.Instance.GetPost(attachment.PostID, false);

            if (post == null)
            {
                ShowError("该附件不存在或者已被删除!");
            }

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);

            if (post.UserID != MyUserID && (!permission.Can(My, ForumPermissionSetNode.Action.AlwaysViewContents)))
            {
                if (!attachment.IsBuyed(My))
                {
                    ShowError("您还没有购买此附件,不能查看购买记录!");
                }
            }

            TradePoint = ForumPointAction.Instance.GetUserPoint(post.UserID, ForumPointValueType.SellAttachment, post.ForumID);

            int pageNumber = _Request.Get <int>("page", Method.Get, 1);

            ExchangeList = PostBOV5.Instance.GetAttachmentExchanges(attachmentID, pageNumber, pageSize, out totalCount, out totalMoney);

            WaitForFillSimpleUsers <AttachmentExchange>(ExchangeList);

            SetPager("list", null, pageNumber, pageSize, totalCount);
        }
Пример #5
0
 protected bool Can(ForumPermissionSetNode.Action action)
 {
     return ForumPermission.Can(My, action);
 }
Пример #6
0
 public ForumPermissionSet()
 {
     Nodes = new ForumPermissionSetNodeCollection();
     ForumPermissionSetNode topNode = new ForumPermissionSetNode();
     Nodes.Add(topNode);
 }
Пример #7
0
        private void ProcessDownload(HttpContext context, string fileID)
        {
            PostV5 post  = PostBOV5.Instance.GetPost(attachment.PostID, false);
            Forum  forum = ForumBO.Instance.GetForum(post.ForumID);

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);

            //if (!forum.Permission.ViewAttachment && attachment.UserID != userID)
            if (false == permission.Can(userID, ForumPermissionSetNode.Action.ViewAttachment) && attachment.UserID != userID)
            {
                ShowErrorMessage(context, "您没有权限下载附件!", "您没有权限下载附件.gif");
                return;
            }

            if (!AlwaysViewContents(forum, post.UserID) && attachment.UserID != userID)//检查是否是出售的帖子
            {
                AuthUser user  = User.Current;
                bool     isBuy = false;
                if (user.BuyedThreads.TryGetValue(post.ThreadID, out isBuy))//缓存中获取
                {
                }
                if (!isBuy)
                {
                    BasicThread thread = PostBOV5.Instance.GetThread(post.ThreadID);
                    if (thread.Price > 0)
                    {
                        //Post firstPost = PostManager.GetThreadFirstPost(thread.ThreadID);
                        //if (firstPost != null && firstPost.PostID == post.PostID)//附件所在的帖子是主题的内容
                        if (post.PostType == MaxLabs.bbsMax.Enums.PostType.ThreadContent)
                        {
                            //if (!firstPost.FreeAttachmentIDs.Contains(attachment.AttachmentID))//attachment.DiskFileID))//不在[free]标签中
                            if (false == post.IsFreeAttachmentID(attachment.AttachmentID))
                            {
                                if (!thread.IsOverSellDays(forum.ForumSetting) && !thread.IsBuyed(user))
                                {
                                    Context.ThrowError <CustomError>(new CustomError("error", "该附件所在的帖子需要购买,您还没有购买该帖子,没有权限下载附件!"));
                                    //Bbs3Globals.ShowError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!", 0);
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            if (CheckPermission(forum.ForumSetting) || AlwaysViewContents(forum, attachment.UserID))
            {
                //if (!IOUtil.DownloadFile(context.Response, context.Request, filePath, attachment.FileName, true, false))
                if (false == OutputFileByID(context, fileID, attachment.FileName, attachment.FileType, outputMode))
                {
                    ShowErrorMessage(context, "该附件不存在,可能被移动或被删除!", "文件不存在.gif");
                    return;
                }
            }
            else
            {
                ShowErrorMessage(context, "你还没有购买此附件,不能下载!", "needpay.gif");
                return;
            }

            context.Response.End();
        }