Пример #1
0
        /// <summary>
        /// 帖子分页列表
        /// </summary>
        /// <param name="page_size">页面大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="totalcount">总记录数</param>
        /// <returns>DateTable</returns>
        public DataTable get_post_list(int Top, string strwhere, string filedOrder)
        {
            DataTable dt     = new DataTable();
            string    _where = "id>0";

            if (!string.IsNullOrEmpty(strwhere))
            {
                _where += " and " + strwhere;
            }
            dt = new BLL.forum_posts().GetList(Top, _where, filedOrder).Tables[0];
            return(dt);
        }
Пример #2
0
        /// <summary>
        /// 帖子分页列表
        /// </summary>
        /// <param name="page_size">页面大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="totalcount">总记录数</param>
        /// <returns>DateTable</returns>
        public DataTable get_post_list(int board_id, int page_size, int page_index, string strwhere, out int totalcount)
        {
            DataTable dt     = new DataTable();
            string    _where = "id>0";

            if (!string.IsNullOrEmpty(strwhere))
            {
                _where += " and " + strwhere;
            }
            dt = new BLL.forum_posts().GetList(board_id, page_size, page_index, _where, "is_top desc,reply_time desc,add_time desc", out totalcount).Tables[0];
            return(dt);
        }
Пример #3
0
        private void set_lock(HttpContext context)
        {
            //检查用户是否登录
            DTcms.Model.users umodel = new DTcms.Web.UI.BasePage().GetUserInfo();
            if (umodel == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"请登录后再提交!\"}");
                return;
            }

            StringBuilder strTxt = new StringBuilder();

            BLL.forum_posts   bll   = new BLL.forum_posts();
            Model.forum_posts model = new Model.forum_posts();

            int    post_id  = DTRequest.GetFormInt("postid");
            string optip    = DTRequest.GetFormString("optip");
            string opremark = DTRequest.GetFormString("opremark");

            model = bll.GetModel(post_id);


            //检查是否是版主
            if (!IsModerator(model.board_id, umodel.id))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,你无权进行此操作!\"}");
                return;
            }

            string strSet = "is_lock=0";

            if (model.is_lock == 0)
            {
                strSet = "is_lock=1";
            }

            bll.UpdateField(post_id, strSet);

            //发送短信息
            string postusername = new DTcms.BLL.users().GetModel(model.user_id).user_name;

            new DTcms.BLL.user_message().Add(1, string.Empty, postusername, "您发布的帖子被管理员进行操作", "您的帖子被管理员进行 " + optip + " 操作,原因:" + opremark);
            new DTcms.Web.UI.ManagePage().AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "锁定帖子:" + opremark); //记录日志

            context.Response.Write("{\"status\": 1, \"msg\": \"恭喜您,操作成功!\"}");
            return;
        }
Пример #4
0
        private void reply(HttpContext context)
        {
            //检查用户是否登录
            DTcms.Model.users umodel = new DTcms.Web.UI.BasePage().GetUserInfo();
            if (umodel == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"请登录后再提交!\"}");
                return;
            }
            BLL.forum_posts   bll   = new BLL.forum_posts();
            Model.forum_posts model = new Model.forum_posts();

            string _title   = DTRequest.GetFormString("txtTitle");
            string _content = DTRequest.GetFormString("txtContent");
            int    board_id = DTRequest.GetFormInt("txtBoardID");
            int    post_id  = DTRequest.GetFormInt("txtPostID");


            int    _userid = umodel.id;
            string _userip = System.Web.HttpContext.Current.Request.UserHostAddress;

            model.class_layer    = 2;
            model.title          = Utils.DropHTML(_title);
            model.content        = _content;
            model.user_id        = _userid;
            model.user_ip        = _userip;
            model.board_id       = board_id;
            model.parent_post_id = post_id;
            model.post_type      = 2;//回帖


            Model.forum_posts pmodel = bll.GetModel(post_id);
            pmodel.reply_time    = DateTime.Now;
            pmodel.reply_user_id = _userid;
            pmodel.reply_count  += 1;

            if (bll.Add(model) > 0 && bll.Update(pmodel))
            {
                context.Response.Write("{\"status\": 1, \"msg\": \"恭喜您,回帖成功!\"}");
                return;
            }
            context.Response.Write("{\"status\": 0, \"msg\": \"对不起,保存过程中发生错误!\"}");
            return;
        }
Пример #5
0
        /// <summary>
        /// 重写虚方法,此方法在Init事件执行
        /// </summary>
        protected override void InitPage()
        {
            action   = DTRequest.GetQueryString("action");
            board_id = DTRequest.GetQueryInt("board_id");
            post_id  = DTRequest.GetQueryInt("post_id");

            if (action == "edit")
            {
                Model.forum_posts post = new BLL.forum_posts().GetModel(post_id);

                //判断权限
                if (!new ajax().IsModerator(board_id, userModel.id) && userModel.id != post.user_id)
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("对不起,你无权编辑此帖!!")));
                    return;
                }

                title    = post.title;
                content  = post.content;
                board_id = post.board_id;
                post_id  = post.id;
            }


            if (action == "reply")
            {
                Model.forum_posts post = new BLL.forum_posts().GetModel(post_id);

                title = "回复:" + post.title;
            }

            rurl = linkurl("forumpostlist", board_id);
            if (HttpContext.Current.Request.Url != null && HttpContext.Current.Request.UrlReferrer != null)
            {
                string currUrl = HttpContext.Current.Request.Url.ToString().ToLower();         //当前页面
                string refUrl  = HttpContext.Current.Request.UrlReferrer.ToString().ToLower(); //上一页面
                string regPath = linkurl("register").ToLower();                                //注册页面
                if (currUrl != refUrl && refUrl.IndexOf(regPath) == -1)
                {
                    rurl = HttpContext.Current.Request.UrlReferrer.ToString();
                }
            }
        }
Пример #6
0
        private void edit(HttpContext context)
        {
            //检查用户是否登录
            DTcms.Model.users umodel = new DTcms.Web.UI.BasePage().GetUserInfo();
            if (umodel == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"请登录后再提交!\"}");
                return;
            }
            BLL.forum_posts bll      = new BLL.forum_posts();
            string          _title   = DTRequest.GetFormString("txtTitle");
            string          _content = DTRequest.GetFormString("txtContent");
            int             post_id  = DTRequest.GetFormInt("txtPostID");

            if (post_id == 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"参数不正确!\"}");
                return;
            }
            Model.forum_posts model = bll.GetModel(post_id);

            //判断权限
            if (!IsModerator(model.board_id, umodel.id) && model.user_id != umodel.id)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,你无权编辑此帖!\"}");
                return;
            }

            model.title   = Utils.DropHTML(_title);
            model.content = _content;

            if (bll.Update(model))
            {
                context.Response.Write("{\"status\": 1, \"msg\": \"编辑帖子成功!\"}");
                return;
            }
            context.Response.Write("{\"status\": 0, \"msg\": \"对不起,保存过程中发生错误!\"}");
            return;
        }
Пример #7
0
        private void del(HttpContext context)
        {
            //检查用户是否登录
            DTcms.Model.users umodel = new DTcms.Web.UI.BasePage().GetUserInfo();
            if (umodel == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"请登录后再提交!\"}");
                return;
            }

            BLL.forum_posts   bll   = new BLL.forum_posts();
            Model.forum_posts model = new Model.forum_posts();
            int    post_id          = DTRequest.GetFormInt("postid");
            string optip            = DTRequest.GetFormString("optip");
            string opremark         = DTRequest.GetFormString("opremark");

            model = bll.GetModel(post_id);

            //检查是否是版主
            if (!IsModerator(model.board_id, umodel.id))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"当前用户无权执行此操作!\"}");
                return;
            }

            if (bll.Delete(post_id))
            {
                //发送短信息
                string postusername = new DTcms.BLL.users().GetModel(model.user_id).user_name;
                new DTcms.BLL.user_message().Add(1, string.Empty, postusername, "您发布的帖子被管理员进行操作", "您的帖子被管理员进行 " + optip + " 操作,原因:" + opremark);
                new DTcms.Web.UI.ManagePage().AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除帖子:" + opremark); //记录日志

                context.Response.Write("{\"status\": 1, \"msg\": \"恭喜您,删除帖子成功!\"}");
                return;
            }
            context.Response.Write("{\"status\": 0, \"msg\": \"对不起,保存过程中发生错误!\"}");
            return;
        }
Пример #8
0
        private void move(HttpContext context)
        {
            //检查用户是否登录
            DTcms.Model.users umodel = new DTcms.Web.UI.BasePage().GetUserInfo();
            if (umodel == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"请登录后再操作!\"}");
                return;
            }
            BLL.forum_posts   bll   = new BLL.forum_posts();
            Model.forum_posts model = new Model.forum_posts();

            BLL.forum_board   bbll   = new BLL.forum_board();
            Model.forum_board bmodel = new Model.forum_board();

            int    post_id    = DTRequest.GetFormInt("postid");
            int    to_boardid = DTRequest.GetFormInt("toboardid");
            string opremark   = DTRequest.GetString("opremark");

            if (post_id == 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"参数不正确!\"}");
                return;
            }

            model = bll.GetModel(post_id);
            if (model.parent_post_id != 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"非主题贴不可移动!\"}");
                return;
            }

            int postcount  = 0;
            int replycount = 0;
            int oldboardid = model.board_id;


            //检查是否是版主
            if (!IsModerator(model.board_id, umodel.id))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"当前用户无权执行此操作!\"}");
                return;
            }

            DataTable dt = bll.GetList(0, "id=" + post_id + " or parent_post_id=" + post_id, "id desc").Tables[0];

            foreach (DataRow dr in dt.Rows)
            {
                if (int.Parse(dr["parent_post_id"].ToString()) == 0)
                {
                    postcount  += 1;
                    replycount += 1;
                }
                else
                {
                    replycount += 1;
                }
                bll.UpdateField(int.Parse(dr["id"].ToString()), "board_id=" + to_boardid);
            }

            bmodel = bbll.GetModel(oldboardid);
            bmodel.subject_count -= postcount;
            bmodel.post_count    -= replycount;
            bbll.Update(bmodel);

            bmodel = bbll.GetModel(to_boardid);
            bmodel.subject_count += postcount;
            bmodel.post_count    += replycount;
            bbll.Update(bmodel);

            new DTcms.Web.UI.ManagePage().AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "移动帖子:" + opremark); //记录日志

            context.Response.Write("{\"status\": 1, \"msg\": \"恭喜你,移动主题成功!\"}");
            return;
        }