Php malicious code filtering function _ PHP Tutorial

Source: Internet
Author: User
Php malicious code filtering function. Php malicious code filtering function PublicFunctionDecodeFilter (html, filter) htmlLCase (html) filtersplit (filter,) ForEachiInfilterSelectCaseiCaseSCRIPT removes all client php malicious code filtering functions

Public Function DecodeFilter (html, filter)
Html = LCase (html)
Filter = split (filter ,",")
For Each I In filter
Select Case I
Case "SCRIPT" 'removes all client scripts such as javascept, vbscript, jscript, js, vbs, event ,...
Html = exeRE ("(javascript | jscript | vbscript | vbs):", "#", html)
Html = exeRE (" ] *> "," ", Html)
Html = exeRE ("on (mouse | exit | error | click | key)", "", html)
Case "TABLE": 'Remove TABLE


Html = exeRE (" ] *> "," ", Html)
Html = exeRE (" ] *> "," ", Html)
Html = exeRE (" ] *> "," ", Html)
Html = exeRE (" ] *> "," ", Html)
Html = exeRE (" ] *> "," ", Html)
Case "CLASS" 'Remove style class CLASS = ""
Html = exeRE ("(<[^>] +) class = [^ | ^>] * ([^>] *>)", "$1 $2 ", html)
Case "STYLE" 'Remove style STYLE = ""
Html = exeRE ("(<[^>] +) style =" "[^" "] *" "([^>] *> )", "$1 $2", html)
Html = exeRE ("(<[^>] +) style = '[^'] * '([^>] *>)", "$1 $2 ", html)
Case "IMG" 'Remove style = ""
Html = exeRE (" ] *> "," ", Html)
Case "XML" 'remove XML
Html = exeRE ("<\\? Xml [^>] *> "," ", html)
Case "NAMESPACE" 'remove NAMESPACE
Html = exeRE ("<\/? [A-z] +: [^>] *> "," ", html)
Case "FONT" 'remove fonts
Html = exeRE (" ] *> "," ", Html)
Html = exeRE (" ] *> "," ", Html)
Html = exeRE (" ] *> "," ", Html)
Html = exeRE (" ] *> "," ", Html)
Case "MARQUEE" 'remove subtitles
Html = exeRE (" ] *> "," ", Html)
Case "OBJECT" 'removes objects
Html = exeRE (" ] *> "," ", Html)
Html = exeRE (" ] *> "," ", Html)
'HTML = exeRE (" ] *> "," ", Html)
Case "EMBED"
Html = exeRE (" ] *> "," ", Html)
Case "DIV" 'removes objects
Html = exeRE (" ]) *> "," $1 ", html)
Html = exeRE (" ]) *> "," $1 ", html)
Case "ONLOAD" 'Remove style = ""
Html = exeRE ("(<[^>] +) onload =" "[^" "] *" "([^>] *> )", "$1 $2", html)
Html = exeRE ("(<[^>] +) onload = '[^'] * '([^>] *>)", "$1 $2 ", html)
Case "ONCLICK" 'Remove style = ""
Html = exeRE ("(<[^>] +) onclick =" "[^" "] *" "([^>] *> )", "$1 $2", html)
Html = exeRE ("(<[^>] +) onclick = '[^'] * '([^>] *>)", "$1 $2 ", html)
Case "ONDBCLICK" 'Remove style = ""
Html = exeRE ("(<[^>] +) ondbclick =" "[^" "] *" "([^>] *> )", "$1 $2", html)
Html = exeRE ("(<[^>] +) ondbclick = '[^'] * '([^>] *>)", "$1 $2 ", html)

End Select
Next
'HTML = Replace (html ," <")
'HTML = Replace (html ," <")
'HTML = Replace (html ," <")
DecodeFilter = html
End Function

Http://www.bkjia.com/PHPjc/629754.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/629754.htmlTechArticlephp malicious code filter Function Public Function DecodeFilter (html, filter) html = LCase (html) filter = split (filter ,,) for Each I In filter Select Case I Case script' remove all clients...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.