public ActionResult FastComment() { string articleID = Request["articleID"]; string commentContent = Request["commentContent"]; if (string.IsNullOrEmpty(commentContent)) { return(Json(new { code = -2, message = "请输入回复内容!" }, JsonRequestBehavior.AllowGet)); } DateTime?lastDate = null; if (Session["lastDate"] != null) { lastDate = Convert.ToDateTime(Session["lastDate"]); } string articleUserID = Utility.ArticleBll.GetarticleUserID(articleID); if (isOwner(articleUserID) || lastDate == null || (DateTime.Now.Subtract(lastDate.Value).TotalSeconds > 60)) { Blogs.Entity.blog_tb_comment model = new Entity.blog_tb_comment(); int floor = Utility.CommentBll.GetMaxFloor(articleID); model.floor = floor + 1; model.commentIP = Utility.GetClientIP(HttpContext); model.commentContent = "<img src=\"" + commentContent + "\" />"; //html过滤 //快速回复不需要审核 model.commentState = 3; model.userID = Utility.UserID; model.userName = Utility.UserName; model.articleID = Convert.ToInt32(articleID); Session["lastDate"] = DateTime.Now; Utility.CommentBll.Insert(model); return(Json(new { code = 1, message = "操作成功" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { code = -3, message = (60 - (int)(DateTime.Now.Subtract(lastDate.Value).TotalSeconds) + "秒内不能重复回复!") }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Comment() { string commentContent = Request["commentContent"]; string articleID = Request["articleID"]; if (string.IsNullOrEmpty(commentContent)) { return(Json(new { code = -1, message = "请输入回复内容!" }, JsonRequestBehavior.AllowGet)); } Blogs.Entity.blog_tb_blog blog = Utility.BlogBll.GetEntity(base.BlogID); if (blog.IsCloseComment) { return(Json(new { code = -999, message = "系统已经关闭评论!" }, JsonRequestBehavior.AllowGet)); } if (!Utility.CommentBll.IsAllowCommentContent(commentContent)) { return(Json(new { code = -1, message = "输入的内容有危险性!" }, JsonRequestBehavior.AllowGet)); } DateTime?lastDate = null; if (Session["lastDate"] != null) { lastDate = Convert.ToDateTime(Session["lastDate"]); } int articleCommentLimit = Utility.ArticleBll.GetArticleCommentLimit(articleID); string articleUserID = Utility.ArticleBll.GetarticleUserID(articleID); if (Utility.CommentBll.isDisableComment(articleCommentLimit) && !isOwner(articleUserID)) { return(Json(new { code = -4, message = "该文章禁止回复!" }, JsonRequestBehavior.AllowGet)); } if (Utility.CommentBll.isDisabledAnonymousComment(articleCommentLimit) && !isOwner(articleUserID)) { return(Json(new { code = -5, message = "该文章不允许匿名回复,请登录后回复!" }, JsonRequestBehavior.AllowGet)); } if (isOwner(articleUserID) || lastDate == null || (DateTime.Now.Subtract(lastDate.Value).TotalSeconds > 60)) { Blogs.Entity.blog_tb_comment model = new Entity.blog_tb_comment(); model.commentContent = commentContent; //html过滤 //非自己回复需要审核 if (!isOwner(articleUserID)) { model.commentState = 0; } int floor = Utility.CommentBll.GetMaxFloor(articleID); model.commentIP = Utility.GetClientIP(HttpContext); model.floor = floor + 1; model.commentText = Request["commentText"]; model.articleID = Convert.ToInt32(articleID); model.userID = Utility.UserID; model.userName = Utility.UserName; Utility.CommentBll.Insert(model); Session["lastDate"] = DateTime.Now; string message = "发布成功"; if (Utility.CommentBll.isVerifyComment(articleCommentLimit)) { message = "发布成功,需要审核后才会显示"; } return(Json(new { code = 1, message = message }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { code = -3, message = (60 - (int)(DateTime.Now.Subtract(lastDate.Value).TotalSeconds) + "秒内不能重复回复!") }, JsonRequestBehavior.AllowGet)); } }