<?php$str=preg_replace ("/\s+/", " ", $str); //Filter Excess carriage return $str=preg_replace ("/<[ ]+/ Si "," < ", $str); //filter <__ (with spaces behind" < ") $str =preg_replace ("/<\!–.*?–>/si "," ", $str) //comment $str =preg_replace ("/< (\!. *?) >/si "," ", $str); //filter Doctype$str=preg_replace ("/< (\/?html.*?) >/si "," ", $str); //Filter HTML tag $str=preg_replace ("/< (\/?br.*?) >/si "," ", $str); //filter br label $str=preg_replace ("/< (\/?head.*?) >/si "," ", $str); //Filter head tag $str=preg_replace ("/< (\/?meta.*?) >/si "," ", $str); //filter meta tag $str=preg_replace ("/< (\/?body.*?) >/si "," ", $str); //Filter Body tag $str=preg_replace ("/< (\/?link.*?) >/si "," ", $str); //Filter Link Tag $str=preg_replace ("/< (\/?form.*?) >/si "," ", $str); //Filter Form label $str=preg_replace ("/cookie/si "," Cookie ", $str); //Filter Cookie Tag $str=preg_ Replace ("/< (applet.*?)" > (. *?) < (\/applet.*?) >/si "," ", $str); //Filter Applet label $str=preg_replace ("/< (\/?applet.*?) >/si "," ", $str); //Filter AppletLabel $str=preg_replace ("/< (style.*?) > (. *?) < (\/style.*?) >/si "," ", $str); //filter style tag $str=preg_replace ("/< (\/?style.*?) >/si "," ", $str); //filter style tag $str=preg_replace ("/< (title.*?) > (. *?) < (\/title.*?) >/si "," ", $str); //Filter title Tag $str=preg_replace ("/< (\/?title.*?) >/si "," ", $str); //Filter title Tag $str=preg_replace ("/< (object.*?) > (. *?) < (\/object.*?) >/si "," ", $str); //filter the OBJECT tag $str=preg_replace ("/< (\/?objec.*?) >/si "," ", $str); //filter the OBJECT tag $str=preg_replace ("/< (noframes.*?) > (. *?) < (\/noframes.*?) >/si "," ", $str); //Filter noframes label $str=preg_replace ("/< (\/?noframes.*?) >/si "," ", $str); //Filter noframes label $str=preg_replace ("/< (i?frame.*?) > (. *?) < (\/i?frame.*?) >/si "," ", $str); //Filter Frame label $str=preg_replace ("/< (\/?i?frame.*?) >/si "," ", $str); //Filter Frame label $str=preg_replace ("/< (script.*?) > (. *?) < (\/script.*?) >/si "," ", $str); //Filter Script tag $str=preg_replace ("/< (\/?script.*?) >/si ", "", $str); //Filter Script tag $str=preg_replace ("/javascript/si", "JavaScript", $str); //Filter Script Tag $str=preg_ Replace ("/vbscript/si", "VBScript", $str), //filter script tag $str=preg_replace ("/on ([a-z]+) \s*=/si", "on\\1=", $str ); //Filter Script tag $str=preg_replace ("/&#/si", "the", "$str); //Filter Script Tag,?>
PHP Filter Common Tags