This article mainly introduces the principle of word filtering in ucenter, and analyzes the related SQL field definitions and filtering functions of words in ucenter in the form of examples. It involves PHP regular replacement and related operation skills of strings and arrays. Friends in need You can refer to it. I hope to be helpful.
This article analyzes the word filtering principle in ucenter. Share it with everyone for your reference, the details are as follows:
Filter word list:
id | admin | find | replacement | findpattern |
UCenterAdminist | Access | 大 | /visit/is | |
UCenterAdminist | 4655 | 45 | /4655/is | |
UCenterAdminist | fdsaf | dfsa | /fdsaf /is | |
UCenterAdminist | 有chances | at | /有chances/is |
//private
function _get_badwords() {
$data = $this->db->fetch_all("SELECT * FROM ".UC_DBTABLEPRE."badwords");
$return = array();
if(is_array($data)) {
foreach($data as $k => $v) {
$return['findpattern'][$k] = $v['findpattern'];
$return['replace'][$k] = $v['replacement'];
}
}
return $return;
}
$_CACHE['badwords'] = $this->base->cache('badwords');
if($_CACHE['badwords']['findpattern']) {
$subject = @preg_replace($_CACHE['badwords']['findpattern'], $_CACHE['badwords']['replace'], $subject);
$message = @preg_replace($_CACHE['badwords']['findpattern'], $_CACHE['badwords']['replace'], $message);
}
PHP generates text-based Morse code
php text replacement specified times
##php processes repeated lines in text documentsThe above is the detailed content of Detailed explanation of word filtering principle in ucenter. For more information, please follow other related articles on the PHP Chinese website!