PHP基本防SQL注入函数与安全过滤函数

function sql_check($Sql_Str) {//自动过滤Sql的注入语句。
    $check=preg_match('/select|insert|update|delete|'|\\*|*|../|./|union|into|load_file|outfile/i',$Sql_Str);
    if ($check) {
        echo '<script language="JavaScript">alert("系统警告:nn请不要尝试在参数中包含非法字符尝试注入!");</script>';
        exit();
    }else{
        return $Sql_Str;
    }
}
function safe($s){ //安全过滤函数
    if(get_magic_quotes_gpc()){ $s=stripslashes($s); }
    $s=MySQL_real_escape_string($s);
    return $s;
}
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容