想要完成PHPCMS会员投稿和后台发布内容敏感词替换操作必须在原来的代码上做修改,否则在后台违禁词管理那里添加了也没有用
打开PHPcms\modules\content\content文件的add();
//敏感词替换操作开始 $this->badword_model = pc_base::load_model('badword_model'); $badword_array=$this->badword_model->select(); if(!empty($badword_array)){ foreach($badword_array as $key_index=>$badword_one){ $_POST['info']['title']=str_replace($badword_one['badword'],$badword_one['replaceword'],$_POST['info']['title']); $_POST['info']['content']=str_replace($badword_one['badword'],$_POST['info']['content']); } } //敏感词替换结束2、会员投稿内容进行敏感词替换
打开PHPcms\modules\member\content文件的publish()
直接在$id = $this->content_db->add_content($info);的前面加入
//敏感词替换操作开始 $this->badword_model = pc_base::load_model('badword_model'); $badword_array=$this->badword_model->select(); if(!empty($badword_array)){ foreach($badword_array as $key_index=>$badword_one){ $info['title']=str_replace($badword_one['badword'],$info['title']); $info['content']=str_replace($badword_one['badword'],$info['content']); } } //敏感词替换结束3、会员投稿内容修改敏感词替换
打开PHPcms\modules\member\content文件的edit()
直接在$this->content_db->edit_content($_POST['info'],$id);的前面加入
//敏感词替换操作开始 $this->badword_model = pc_base::load_model('badword_model'); $badword_array=$this->badword_model->select(); if(!empty($badword_array)){ foreach($badword_array as $key_index=>$badword_one){ $_POST['info']['title']=str_replace($badword_one['badword'],$_POST['info']['content']); } } //敏感词替换结束注意事项