protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { string msg = Request["msg"]; msg = msg.Trim(); string[] words = msg.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); BLL.Articel_WordsManager bll = new BLL.Articel_WordsManager(); foreach (string str in words) { string[] word = str.Split('='); Model.Articel_Words model = new Model.Articel_Words(); model.WordPattern = word[0]; if (word[1] == "{BANNED}") { model.IsForbid = true; } else if (word[1] == "{MOD}") { model.IsMod = true; } else { model.ReplaceWord = word[1]; } bll.Add(model); } } }
private void AddComment(HttpContext context) { string msg = context.Request["msg"]; //判断禁用词. BLL.Articel_WordsManager articelBll = new BLL.Articel_WordsManager(); if (articelBll.CheckBannd(msg)) { context.Response.Write("no:评论中含有禁用词!!"); } else if (articelBll.CheckMod(msg)) //审查词过滤 { AddBookComment(context, msg); context.Response.Write("no:评论中含有审查词!!"); } else { //替换词过滤 msg = articelBll.CheckReplace(msg); AddBookComment(context, msg); } }