Well, for PHP developers, a PHP SQL anti-injection and character filtering and a variety of filter code OH.
Well, for PHP developers, a PHP SQL anti-injection and character filtering and a variety of filter code OH.
= = anti-injection automatic filtering [post-activation program low efficiency]========================================================================================= =
/*
function Inject_checks ($sql _str) {return eregi (' select|insert|update|delete| ' | /*|*|.. /|. /|union|into|load_file|outfile ', $sql _str);}
foreach ($_request as $value) {if (Inject_checks ($value)) {echo ""; exit;}}
*/
= = Anti-note [Inject_check ($sql _str)]================================================================================ ==========
function Inject_check ($sql _str) {
if (eregi (' Select|insert|update|delete|union|into|load_file|outfile ', $sql _str)) {echo ""; exit;}
return $sql _str;
}
= = Character filter [Safe_convert ($string)]==============================================================================
function Safe_convert ($string) {//words Filter
if (GET_MAGIC_QUOTES_GPC ()) {//escape character plus backslash
$string =htmlspecialchars ($string, ent_quotes); Turn special characters into HTML string formats such as "&" to "&"
$string =str_replace ("<", "<", $string); Replace
$string =str_replace (">", ">", $string); Replace
$string =str_replace ("\", ' \ ', $string); Replace
} else {
$string =addslashes ($string); Escape character plus backslash//$string =stripslashes ($string); Remove backslashes
$string =str_replace ("\ \", ' \ ', $string);
}
$string =str_replace ("R", "
", $string); Line break
$string =str_replace ("n", "", $string); Space
$string =str_replace ("T", "", $string); Space
$string =str_replace ("", "", $string); Space
$string =str_replace (' | ', ' | ', $string); Conflicts with the classification system are replaced
$string =str_replace ("& #96;", "'", $string); Replace
$string =str_replace ("& #92;", "\", $string); Replace
return $string;
}
= = Character anti-filter [Unsafe_convert ($string)]============================================================================ ==
function Unsafe_convert ($string) {//words Filter
$string =str_replace ("\" "," "", $string); Replace
return $string;
}
= = Character filter [filter ($string)]===================================================================================== =======
function Filter ($string) {//words filter
Include ("filter.php");//Glossary filter List
foreach ($badwords as $badword) {
if (Stristr ($string, $badword) ==true) {echo ""; exit;}
}
return $string;
}
http://www.bkjia.com/PHPjc/629745.html www.bkjia.com true http://www.bkjia.com/PHPjc/629745.html techarticle well, for PHP developers, a PHP SQL anti-injection and character filtering and a variety of filter code OH. Okay, for PHP developers, a PHP SQL anti-injection and character filtering and a variety of filtering ...