and other possibilities To introduce malicious content or code that maliciously changes the display layout, if you do not need to insert flash, etc., you can also add filtering"/<(/?)(script|i?frame|style|html|body|titl"/> and other possibilities To introduce malicious content or code that maliciously changes the display layout, if you do not need to insert flash, etc., you can also add filtering"/<(/?)(script|i?frame|style|html|body|titl">

Home >Backend Development >PHP Tutorial >hktm php filters dangerous html code

hktm php filters dangerous html code

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 08:38:36982browse

The following is the program code:

Copy the code The code is as follows:


function uhtml($str)
{
$farr = array(
"/s+/", //Filter excess blanks
//Filter <script> and other codes that may introduce malicious content or maliciously change the display layout. If you do not need to insert flash, etc., you can also add filtering of <object><BR>"/<(/?)(script|i?frame|style |html|body|title|link|meta|?|%)([^>]*?)>/isU", <BR>"/(<[^>]*)on[a-zA-Z ]+s*=([^>]*>)/isU",//Filter the on event of javascript <BR>); <BR>$tarr = array( <BR>" ", <BR>"<123>",//If you want Directly clear unsafe tags, you can leave them blank here <BR>"12", <BR>); <BR>$str = preg_replace( $farr,$tarr,$str); <BR>return $str; <BR>} <BR></script>

The above introduces hktm php filtering dangerous html code, including hktm content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn