1
你把run/function.php中的filter2函数加一句代码:
//过滤函数2
function filter2($text){
$text=filter_html($text);
$text=preg_replace('/<\?.*\?>/sU','',$text);
$text=preg_replace('/<\!--.*-->/sU','',$text);
$text=preg_replace('/<\!DOCTYPE[^>]*>/i','',$text);
while(preg_match('/<p(.+)<\/p>/isU',$text,$mat)){
$text=str_replace($mat[0],'<div'.$mat[1].'</div>',$text);
unset($mat);
}
$text=preg_replace('/<(p|dt|dd)[^>]*>|<\/(p|li|dt|dd)>/i','<br>',$text); //可单个使用的标记处理
$text=preg_replace('/<li[^>]*>/i','<br>●',$text);
$text=preg_replace('/<\/?(html|head|meta|link|base|body|title|style|script|noscript|form|iframe|frame|frameset|noframes)[^>]*>/i','',$text);
while(preg_match('/(<[^>]+)( title| alt| id| name| lang| class| onfinish| onmouse| onexit| onerror| onclick| onkey| onload| onchange| onfocus| onblur)\s*=\s*(("[^">]+")|(\'[^\'>]+\')|[^\s>]+)([^>]*>)/i',$text,$mat)){
$text=str_replace($mat[0],$mat[1].' '.$mat[6],$text);
unset($mat);
}
while(preg_match('/(<[^>]+)(window\.|javascript:|js:|about:|file:|document\.|vbs:|cookie)([^>]*)/i',$text,$mat)){
$text=str_replace($mat[0],$mat[1].' '.$mat[3],$text);
unset($mat);
}
$text=preg_replace('/<(w?br(\s\/)?)>/i','[]',$text);
while(preg_match('/<([a-z]+)[^>\[\]]*>[^><]*<\/\]]+)([^\]]*\])/i',$text,$mat)){
$text=str_replace($mat[0],$mat[1].'|'.$mat[3].'|'.$mat[4],$text);
unset($mat);
}
while(preg_match('/(\[[^"\'\]]*)("|\')([^\]]*\])/i',$text,$mat)){
$text=str_replace($mat[0],$mat[1].$mat[3],$text);
unset($mat);
}
$text=str_replace('<','<',$text);
$text=str_replace('>','>',$text);
$text=str_replace('\"','"',$text);
$text=str_replace('"','"',$text);
$text=str_replace('\'',''',$text);
$text=str_replace('[','<',$text);
$text=str_replace(']','>',$text);
$text=str_replace('|','"',$text);
$text=filter_badwords($text); //2.2版加入过滤词汇功能
return $text;
}