Php security filtering code

Source: Internet
Author: User


<? Php
/**
* @ Name date safe class 0.1
* @ Author kevin xu
* @ Copyright kenvin E-mail: gincn@cn.cashboxparty.com MSN: gincn@live.cn
*/
Interface dateSafe {
Function gincn ();
}
Class safe extends doSafe implements dateSafe
{
Public $ safe;
Function _ construct ($ safe)
{
Parent: :__ construct ($ safe); // call the parent class constructor. The error is returned by javachen.
$ This-> safe = $ safe;
}
Function gincn ()
{
$ This-> safe = parent: xss ($ this-> safe );
$ This-> safe = parent: SQL ($ this-> safe );
Return $ this-> safe;
}
}
Class doSafe
{
Protected $ str;
Function _ construct ($ str)
{
$ This-> str = $ str;
}
Function xss ()
{
$ This-> str = trim ($ this-> str); // clear space characters
$ This-> str = nl2br ($ this-> str); // convert the linefeed to <br/>
$ This-> str = strip_tags ($ this-> str); // filter HTML tags in text
$ This-> str = htmlspecialchars ($ this-> str); // converts the content in the text to an HTML Entity
$ This-> str = addslashes ($ this-> str); // Add character escaping
Return $ this-> str;
}
Function SQL ()
{
$ This-> str = mysql_escape_string ($ this-> str );
Return $ this-> str;
}
}

?>

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.