项目中没有用PDO,由于get_magic_quotes_gpc、mysql_real_escape_string已经弃用了,只能这么防了yi
/**
* 防SQL注入处理
*/
if (!function_exists('check_input')) {
function check_input($str)
{
//防注入
$inject_check = preg_match('/select|insert|update|delete|\'|\\*|\*|\.\.\/|\.\/|\<!--|union|into|load_file|outfile/i', $str);
if ($inject_check) {
return false;
}
$contents = addslashes($str);
$contents = str_replace("_", "\_", $contents); // 把 '_'过滤掉
$contents = str_replace("%", "\%", $contents); // 把 '%'过滤掉
return $contents;
}
}