Write your own SQL injection detection function, you can effectively detect the user Post,get over the reference to filter, the need for a friend reference.
| The code is as follows |
Copy Code |
|
Detection of/*sql injected characters
* All user input data, post parameters, get parameters need to be detected
* Returns the keyword if there is a match to the keyword otherwise false
* This is not the same as the detection of sensitive characters
*/
function Filter_sql ($strData)
{
$strFilter = $blnFlag = $arrayFilter = ";
$strFilter = "' |and| (|)| Exec|insert|select|delete|update|count|*|%27|chr|mid|master|truncate|char|declare|union|or "; The characters that need to be filtered can be added by themselves, "|" is a delimiter
$blnFlag =false; Filter flag, if the filter is generated, then it is true
$arr =explode ("|", $strFilter);
$str = "";
foreach ($arr as $row)
{
$str. =preg_quote ($row). "|";
}
$str =trim ($str, "|");
if (Preg_match ('/'. $str. '/I ', $strData, $word))
{
return $word [0];
}
return false;
}
/*
Test
$string = "FASDF Union";
echo Filter_sql ($string);
*/
?> |
http://www.bkjia.com/PHPjc/629696.html www.bkjia.com true http://www.bkjia.com/PHPjc/629696.html techarticle write your own SQL injection detection function, you can effectively detect the user Post,get over the reference to filter, the need for a friend reference. Code to copy code like this? PHP/*sql injection ...