PHP关键字过滤的函数
程序员文章站
2022-03-03 10:21:23
...
/**
* 关键字过滤
*/
function keyfilter($content){
$config = Config::get('memcache.1700');
$this->memcache = new \Memcache;
$this->memcache->connect($config['host'], $config['port']);
$data = $this->memcache->get('keyfilter');
if ($data)
$data = json_decode($data, true);
if (empty($data)) {
$result = Db::table('web_badkeys')->where("status = 1")->select();
foreach ($result AS $key => $val) {
$data[] = '/'.$val['title'].'/';
}
$this->memcache->set('keyfilter', json_encode($data));
}
$content = preg_replace($data, '**', $content);
return $content;
}
上一篇: vue 路由跳转三种方法 总结
下一篇: 白名单