<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/><?PHPHeader(' content-type:text/html; Charset=utf-8 ');functionContent_replace ($show _content){ $search=Array( "' <script[^>]*?>.*?</script> ' si ',//Filter Script Tags"' <iframe[^>]*?>.*?</iframe> ' si ',//Filter IFRAME Tags"' <style[^>]*?>.*?</style> ' si ',//Filter Style Tags"' <[\/\!] *span[^<>]*?> ' Si ',//filtering span Markers"' <[\/\!] *strong[^<>]*?> ' Si ', "' <[\/\!] *span[^<]*?> ' Si ',//filtering span Markers"' <[\/\!] *br[^<>]*?> ' Si ',//Filter BR Mark"' <[\/\!] *img[^<>]*?> ' Si ',//filtering img Tags"' <[\/\!] *input[^<>]*?> ' Si ',//Filter Input Tags"' <[\/\!] *font[^<>]*?> ' Si ',//Filter Font Tags"' <[\/\!] *textarea[^<>]*?> ' Si ',//Filter TextArea marks"' <[\/\!] *form[^<>]*?> ' Si ',//Filter Form Tags"' <[\/\!] *a[^<>]*?> ' Si ',//filter a tag, if you want to filter the word in the link, you must write it down in the filter rule. "' <[\/\!] *div[^<>]*?> ' Si ',//Filter div Tags"' <[\/\!] *tbody[^<>]*?> ' Si ',//Filter Table Tags"' <[\/\!] *table[^<>]*?> ' Si ',//Filter Table Tags"' <[\/\!] *tr[^<>]*?> ' Si ',//Filter Table Tags"' <[\/\!] *td[^<>]*?> ' Si ',//Filter Table Tags"' <[\/\!] *p[^<>]*?> ' Si ',//Filter P Mark"' <[\/\!] *o:p[^<>]*?> ' Si ',//Filter O:p marks"' <[\?\!] *xml:[^<>]*?> ' Si ',//Filter xml: Tags"' <[\/\!] *select[^<>]*?> ' Si ',//Filter Select Tags"' <[\/\!] *option[^<>]*?> ' Si ',//Filter Option Tag"' <[\/\!] *v:[^<>]*?> ' Si ',//Filter V: Mark"' <[\/\!] *o:[^<>]*?> ' Si ',//filter O: Mark"' Target= ([^\s>]*) |method= ([^\s>]*) |action= ([^\s>]*] |rows= ([^\s>]*) |cols= ([^\s>]*] |type= ([^\s >]*) |href= ([^\s>]*) |src= ([^\s>]*] |id= ([^\s>]*) |class= ([^\s>]*) |name= ([^\s>]*] |align= ([^\s >]*) |cellpadding= ([^\s>]*) |cellspacing= ([^\s>]*) |border= ([^\s>]*] |bordercolor= ([^\s>]*) | Background= ([^\s>]*) |bgcolor= ([^\s>]*) ' Si ", "' (\d+); ' E ", ); $replace=Array(",", "," "," "," "," ",", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Chr (\\1)"); $show _content=Preg_replace($search,$replace,$show _content); $show _content=Preg_replace("/style=[" \ "]* ([^ ' \"]*) [' \ ']*/is ', "",$show _content); $show _content=Str_replace("\ r \ n", "",$show _content);//Remove line breaks in HTML $show _content=Str_replace("<span", "",$show _content);//Remove line breaks in HTML $show _content=Str_replace(" ", "",$show _content);//Remove line breaks in HTML$show _content=Str_replace(" ", "",$show _content);//Remove line breaks in HTMLreturn $show _content; }//Chinese character intercept functionfunctionCNSUBSTR ($string,$sublen,$a=0){ if($string= = "'){ return false; } $string= Changeyinhaocom ($string, ' Out '); $sum= 0; for($i= 0;$i<strlen($string) ;$i++){ if(Ord($string{$i}) > 127) { $s.=$string{$i} .$string{++$i} .$string{++$i}; $sum++; Continue; } Else { $s.=$string{$i}; $sum++; Continue; } } if($sublen>=$sum) { return $string; } $s= ""; $index= 0; for($i= 0;$i<$sublen;$i++) { if(Ord($string{$index}) > 127) { $s.=$string{$index} .$string{++$index} .$string{++$index}; $index++; Continue; } Else { $s.=$string{$index}; $index++; Continue; } } if($a===0){ $s.="..."; }Else{ $s.=$a; } return $s;}functionChangeyinhaocom ($content,$flag){ if($flag= = "in"){ $content=Str_replace("\" "," " ",$content); $content=Str_replace("'", "& #39;",$content); } if($flag= = "Out"){ $content=Str_replace(""", "\" ",$content); $content=Str_replace("& #39;", "'",$content); } return $content;}//Calling Methods$str= ' This is a long string I'm going to intercept it ';EchoCnsubstr (Content_replace ($str), 5);Echo $res;
Encode-intercept Chinese-remove HTML characters