//添加禁用词 public ActionResult AddContent(FormCollection form) { string msg = form["msg"]; msg = msg.Trim(); string[] words = msg.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (string str in words) { string[] word = str.Split('='); ForbiddenList forbid = new ForbiddenList(); forbid.WordPattern = word[0]; forbid.Id = Guid.NewGuid(); if (word[1] == "{BANNED}") { forbid.IsForbid = true; } else if (word[1] == "{MOD}") { forbid.IsMod = true; } else { forbid.ReplaceWord = word[1]; } ForbiddenListBll.Add(forbid); } return(Content("ok")); }
public ActionResult BannedDel(Guid id) { ForbiddenList b = new ForbiddenList() { Id = id }; if (ForbiddenListBll.Delete(b)) { return(Content("ok")); } else { return(Content("no")); } }
public ActionResult BannedList() { string name = Request["name"]; int pageSize = Request["rows"] == null ? 20 : int.Parse(Request["rows"]); int pageIndex = Request["page"] == null ? 1 : int.Parse(Request["page"]); int total = 0; var allWords = ForbiddenListBll.LoadEntities(w => true); if (!string.IsNullOrEmpty(name)) { allWords = allWords.Where(w => w.WordPattern.Contains(name)); } total = allWords.Count(); allWords = allWords.OrderByDescending(w => w.Id).Skip(pageSize * (pageIndex - 1)).Take(pageSize); var result = new { total = total, rows = allWords.ToList() }; return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult AddNewsReplyMsg() { string ip = Request["ip"]; string msg = Request["msg"]; string guid = Request["userId"]; var user = Common.CacheHelper.Get(guid) as PersonalUser; int userId = 0; if (user != null) { userId = user.Id; } if (ForbiddenListBll.CheckBannd(msg)) { return(Content("banned,提示:您所输入的信息包含禁用词!")); } if (BlackListIPBll.CheckBlackListIp(ip)) { return(Content("ipNo,提示:您所在地IP已被受限!暂不能发表评论!如需操作,联系爽赞网管理人员")); } else { LeaveMsg levaemsg = new LeaveMsg() { PersonalUserId = userId, IP = ip, City = Request["city"], Msg = msg, MsgNum = null, InTime = DateTime.Now, ReplyId = int.Parse(Request["replyId"]), //变化点 UserRaidersId = int.Parse(Request["raidersId"]) //变化点 }; if (LeaveMsgBll.Add(levaemsg) != null) { return(Content("ok,恭喜:评论提交成功")); } else { return(Content("no,提示:评论提交失败!")); } } }