/**
* PHP提交过滤函数
*
* @param
* @arrange 512-笔记网: jb51.cc
**/
function filter($text)
{
//完全过滤注释
$text = preg_replace('/<!--?.*-->/','',$text);
//完全过滤js
$text = preg_replace('/<script?.*\/script>/',$text);
//过滤危险的属性,如:过滤on事件lang js
while (preg_match('/(<[^><]+)( lang|action|background|codebase|dynsrc|lowsrc)[^><]+/i',$text,$mat)) {
$text = str_replace($mat[0],$mat[1],$text);
}
while (preg_match('/(<[^><]+)(window\.|javascript:|js:|about:|file:|document\.|vbs:|cookie)([^><]*)/i',$mat[1] . $mat[3],$text);
}
//过滤多余html
$text = preg_replace('/<\/?(html|head|meta|link|base|basefont|body|bgsound|script|form|iframe|frame|frameset|applet|id|ilayer|layer|name|script|xml)[^><]*>/i',$text);
//反转换
$text = str_replace('[','<',$text);
$text = str_replace(']','>',$text);
$text = str_replace('|','',$text);
return $text;
}
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。