/**
* Character filtering
* $santype 1: Stripped of HTML, XML, and PHP tags,
* 2: Peel HTML, XML, and PHP tags, convert characters to HTML entities, encode double quotes and single quotes
* 3: Strip HTML, XML, and PHP tags, add backslash single quotation mark (') Double quotation mark (') backslash (\) NULL before specified predefined character
* 4: Used to clean up data retrieved from a database or HTML form (stripped of HTML, XML, and PHP tags)
* 6: Add backslash single quotation mark (') double quote (') backslash (\) NULL before specified predefined character
*
* */
function sanitize ($var, $santype = 1, $allowable _tags = ") {
if ($santype = = 1) {return strip_tags ($var, $allowable _tags = ");}
ElseIf ($santype = = 2) {return htmlentities (Strip_tags ($var, $allowable _tags), ent_quotes, ' UTF-8 ');}
ElseIf ($santype = = 3) {
Return Addslashes (Strip_tags ($var, $allowable _tags));
}
ElseIf ($santype = = 4) {
Return Stripslashes (Preg_replace ('/< ([^>]+) >/es ', ' < '. sanitize (' \\1 ', 5). ' > ' ", Strip_tags ($var, $allowable _tags)));
}
ElseIf ($santype = = 5) {
Return preg_replace ('/\son\w+\s*=/is ', ', $var);
}
ElseIf ($santype = = 6) {
Return addslashes ($var);
}
}
Excerpted from Adamboy
http://www.bkjia.com/PHPjc/478337.html www.bkjia.com true http://www.bkjia.com/PHPjc/478337.html techarticle /** * Character filtering * $santype 1: Strip HTML, XML and PHP tags, * 2: Peel HTML, XML and PHP tags, convert characters to HTML entities, encode double quotes and single quotes * 3 ...