PhpHtmlReplace input filter security function. Copy the code as follows: $ rptype0 indicates that only the html tag is replaced. $ rptype1 indicates that the html tag is replaced and consecutive white spaces are removed. $ rptype2 indicates that the html tag is replaced at the same time.
The code is as follows:
// $ Rptype = 0 indicates that only the html tag is replaced.
// $ Rptype = 1 indicates replacing the html tag and removing consecutive white spaces
// $ Rptype = 2 indicates replacing the html tag and removing all white spaces
// $ Rptype =-1 indicates that only the html dangerous tag is replaced.
Function HtmlReplace ($ str, $ rptype = 0)
{
$ Str = stripslashes ($ str );
If ($ rptype = 0)
{
$ Str = htmlspecialchars ($ str );
}
Else if ($ rptype = 1)
{
$ Str = htmlspecialchars ($ str );
$ Str = str_replace ("", '', $ str );
$ Str = ereg_replace ("[rnt] {1,}", '', $ str );
}
Else if ($ rptype = 2)
{
$ Str = htmlspecialchars ($ str );
$ Str = str_replace ("", '', $ str );
$ Str = ereg_replace ("[rnt]", '', $ str );
}
Else
{
$ Str = ereg_replace ("[rnt] {1,}", '', $ str );
$ Str = eregi_replace ('script', 'script', $ str );
$ Str = eregi_replace ("<[/] {0, 1} (link | meta | ifr | fra) [^>] *>", '', $ str );
}
Return addslashes ($ str );
}
The http://www.bkjia.com/PHPjc/322099.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/322099.htmlTechArticle code is as follows: // $ rptype = 0 indicates that only the html tag is replaced. // $ rptype = 1 indicates that the html tag is replaced and consecutive white spaces are removed. // $ rptype = 2 indicates that the html tag is replaced at the same time...