Copy codeThe 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 );
}