コード例 #1
0
        public void NewTopic()
        {
            int id = ctx.GetInt("boardId");

            ForumBoard board = getTree().GetById(id);

            if (board == null)
            {
                echo(alang("exBoardNotFound"));
                return;
            }
            if (!SecurityHelper.Check(this, board))
            {
                return;
            }

            List <ForumBoard> pathboards = getTree().GetPath(board.Id);

            set("location", ForumLocationUtil.GetTopicAdd(pathboards, ctx));

            bindAddForm(id);

            set("uploadLink", to(new UploaderController().UploadForm) + "?boardId=" + board.Id);
            set("batchUploadLink", to(new UploaderController().SaveFlashUpload) + "?boardId=" + board.Id);
            set("authJson", ctx.web.GetAuthJson());

            // swf上传跨域问题
            set("jsPath", sys.Path.DiskJs);
        }
コード例 #2
0
        public override void CheckPermission()
        {
            if (ctx.viewer.IsLogin == false)
            {
                if (ctx.utils.isAjax)
                {
                    echoText(lang("exPlsLogin"));
                }
                else
                {
                    redirectLogin();
                }
                return;
            }

            int        boardId = ctx.GetInt("boardId");
            ForumBoard board   = boardService.GetById(boardId, ctx.owner.obj);

            if (board == null)
            {
                echo("版块不存在");
                return;
            }
            ctx.SetItem("forumBoard", board);

            if (ctx.viewer.IsAdministrator())
            {
                return;
            }

            SecurityHelper.Check(this, board);
        }
コード例 #3
0
        public void Show(int id)
        {
            String guid = ctx.Get("id");

            Attachment attachment = attachmentService.GetById(id, guid);

            if (attachment == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            // 权限控制
            ForumTopic topic = topicService.GetById(attachment.TopicId, ctx.owner.obj);

            if (SecurityHelper.Check(this, topic.ForumBoard) == false)
            {
                return;
            }

            attachmentService.AddHits(attachment);

            // 检查盗链
            if (isDownloadValid() == false)
            {
                echoRedirect(alang("exDownload"));
                return;
            }

            // 转发
            redirectUrl(attachment.FileUrl);
        }
コード例 #4
0
        public void Create()
        {
            if (ForumValidator.IsIntervalShort(ctx))
            {
                echoError("对不起,您发布太快,请稍等一会儿再发布");
                return;
            }

            int boardId = ctx.GetInt("boardId");

            ForumBoard board = boardService.GetById(boardId, ctx.owner.obj);

            if (board == null)
            {
                echo(alang("exBoardNotFound"));
                return;
            }
            if (!SecurityHelper.Check(this, board))
            {
                return;
            }

            ForumTopic topic = ForumValidator.ValidateTopic(ctx);

            if (ctx.HasErrors)
            {
                echoError();
                return;
            }

            if (ctx.PostIsCheck("saveContentPic") == 1)
            {
                topic.Content = wojilu.Net.PageLoader.ProcessPic(topic.Content, null);
            }

            topic.ForumBoard = new ForumBoard(boardId);
            Result result = topicService.CreateTopic(topic, (User)ctx.viewer.obj, ctx.owner.obj, (IApp)ctx.app.obj);

            if (result.HasErrors)
            {
                errors.Join(result);
                echoError();
                return;
            }

            saveUploadedAttachments(topic);

            if (ctx.HasErrors)
            {
                echoText(errors.ErrorsHtml);
                return;
            }

            echoRedirect(lang("opok"), alink.ToAppData(topic));
            ForumValidator.AddCreateTime(ctx);
        }
コード例 #5
0
        public override void CheckPermission()
        {
            // 1) login
            if (ctx.viewer.IsLogin == false)
            {
                redirectLogin();
                return;
            }

            if (ctx.viewer.IsAdministrator())
            {
                return;
            }

            // 2) data exist
            ForumTopic topic       = null;
            IPost      currentData = null;

            if (ctx.controller.GetType() == typeof(PostController))
            {
                ForumPost post = postService.GetById(ctx.route.id, ctx.owner.obj);
                if (post == null)
                {
                    echoRedirect(lang("exDataNotFound") + "(ForumPost)");
                    return;
                }
                currentData = post;
                topic       = topicService.GetById(post.TopicId, ctx.owner.obj);
            }
            else
            {
                topic       = topicService.GetById(ctx.route.id, ctx.owner.obj);
                currentData = topic;
            }


            if (topic == null)
            {
                echoRedirect(lang("exDataNotFound") + "_ForumTopic");
                return;
            }

            // 3) self edit
            if (currentData.Creator.Id == ctx.viewer.Id)
            {
                return;
            }

            // 4) admin permission
            SecurityHelper.Check(this, topic.ForumBoard);
        }
コード例 #6
0
        public override void CheckPermission()
        {
            this.boardsPath = getTree().GetPath(ctx.route.id);

            if (this.boardsPath.Count == 0)
            {
                echoRedirect(alang("exBoardNotFound"));
                return;
            }

            ForumBoard board = getTree().GetById(ctx.route.id);

            this.fb = board;
            SecurityHelper.Check(this, fb);
        }
コード例 #7
0
        private Boolean hasPermission(int id)
        {
            this.boardsPath = getTree().GetPath(id);

            ForumBoard board = getTree().GetById(id);

            this.fb = board;

            if (this.boardsPath.Count == 0)
            {
                echo(alang("exBoardNotFound"));
                return(false);
            }

            return(SecurityHelper.Check(this, fb));
        }
コード例 #8
0
        public void Show(int id)
        {
            String guid = ctx.Get("id");

            Attachment attachment = attachmentService.GetById(id, guid);

            if (attachment == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            // 权限控制
            ForumTopic topic = topicService.GetById(attachment.TopicId, ctx.owner.obj);

            if (SecurityHelper.Check(this, topic.ForumBoard) == false)
            {
                return;
            }

            // 积分不够不能下载
            User user = ctx.viewer.obj as User;

            if (getUserDownloadMoney(user) < getDownloadRequirement())
            {
                echoRedirect("对不起,您的积分不够");
                return;
            }

            // 增加下载记录,扣除用户的下载币
            attachmentService.AddHits(attachment, ctx.viewer.obj as User);

            // 检查盗链
            if (isDownloadValid() == false)
            {
                echoRedirect(alang("exDownload"));
                return;
            }

            // 转发
            redirectUrl(attachment.FileUrl);
        }
コード例 #9
0
        public override void CheckPermission()
        {
            // 1) login
            if (ctx.viewer.IsLogin == false)
            {
                redirectLogin();
                return;
            }

            int        boardId = ctx.GetInt("boardId");
            ForumBoard board   = boardService.GetById(boardId, ctx.owner.obj);

            if (board == null)
            {
                echoRedirect(lang("exDataNotFound") + "(ForumBoard)");
                return;
            }

            SecurityHelper.Check(this, board);
        }
コード例 #10
0
        public override void CheckPermission()
        {
            ForumPost post = postService.GetById(ctx.route.id, ctx.owner.obj);

            if (post == null)
            {
                echo(alang("exPostNotFound"));
                return;
            }

            ForumBoard board = getTree().GetById(post.ForumBoardId);

            if (board == null)
            {
                echo(alang("exBoardNotFound"));
                return;
            }

            SecurityHelper.Check(this, board);
        }
コード例 #11
0
        public override void CheckPermission()
        {
            ForumTopic topic = topicService.GetById(ctx.route.id, ctx.owner.obj);

            if (topic == null)
            {
                echo(alang("exTopicNotFound"));
                return;
            }

            // 判断阅读权限
            if (topic.ReadPermission > 0 && haveReadPermission(topic) == false)
            {
                echo(alang("exReadPermission"));
                return;
            }

            ForumBoard board = topic.ForumBoard;

            SecurityHelper.Check(this, board);
        }
コード例 #12
0
        public void NewQ()
        {
            int id = ctx.GetInt("boardId");

            ForumBoard board = getTree().GetById(id);

            if (board == null)
            {
                echo(alang("exBoardNotFound"));
                return;
            }
            if (!SecurityHelper.Check(this, board))
            {
                return;
            }

            List <ForumBoard> pathboards = getTree().GetPath(board.Id);

            set("location", ForumLocationUtil.GetQuestionAdd(pathboards, ctx));

            bindAddForm(id);
            set("uploadLink", to(new UploaderController().UploadForm) + "?boardId=" + board.Id);
        }