如何将PHP防止SQL注入的通用方法改写成长尾?

2026-04-05 16:4013阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计152个文字,预计阅读时间需要1分钟。

如何将PHP防止SQL注入的通用方法改写成长尾?

phpfunction inject_check($sql_str) { return eregi('select|insert|and|or|update|delete|/\*|union|into|load_file|outfile', $sql_str);}

function verify_id($id=null) { if (!$id) { exit('没有提供参数!'); } elseif (!isset($id)) { exit('未定义的参数!'); }}

如何将PHP防止SQL注入的通用方法改写成长尾?

function inject_check($sql_str) { return eregi('select|insert|and|or|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile', $sql_str); } function verify_id($id=null) { if(!$id) { exit('没有提交参数!'); } elseif(inject_check($id)) { exit('提交的参数非法!'); } elseif(!is_numeric($id)) { exit('提交的参数非法!'); } $id = intval($id); return $id; } function str_check( $str ) { if(!get_magic_quotes_gpc()) { $str = addslashes($str); // 进行过滤 } $str = str_replace("_", "\_", $str); $str = str_replace("%", "\%", $str); return $str; } function post_check($post) { if(!get_magic_quotes_gpc()) { $post = addslashes($post); } $post = str_replace("_", "\_", $post); $post = str_replace("%", "\%", $post); $post = nl2br($post); $post = htmlspecialchars($post); return $post; }

本文共计152个文字,预计阅读时间需要1分钟。

如何将PHP防止SQL注入的通用方法改写成长尾?

phpfunction inject_check($sql_str) { return eregi('select|insert|and|or|update|delete|/\*|union|into|load_file|outfile', $sql_str);}

function verify_id($id=null) { if (!$id) { exit('没有提供参数!'); } elseif (!isset($id)) { exit('未定义的参数!'); }}

如何将PHP防止SQL注入的通用方法改写成长尾?

function inject_check($sql_str) { return eregi('select|insert|and|or|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile', $sql_str); } function verify_id($id=null) { if(!$id) { exit('没有提交参数!'); } elseif(inject_check($id)) { exit('提交的参数非法!'); } elseif(!is_numeric($id)) { exit('提交的参数非法!'); } $id = intval($id); return $id; } function str_check( $str ) { if(!get_magic_quotes_gpc()) { $str = addslashes($str); // 进行过滤 } $str = str_replace("_", "\_", $str); $str = str_replace("%", "\%", $str); return $str; } function post_check($post) { if(!get_magic_quotes_gpc()) { $post = addslashes($post); } $post = str_replace("_", "\_", $post); $post = str_replace("%", "\%", $post); $post = nl2br($post); $post = htmlspecialchars($post); return $post; }