文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>php 防sql注入过滤代码

php 防sql注入过滤代码

时间:2010-12-02  来源:秩名

我们提供了三个函数不来过滤一些特殊的字符,主要是利用php教程把sql敏感字符串给过滤掉了,好了下面来看看这款代码吧。有需要的朋友拿去看看。

function phps ql_show($str){
$str = stripslashes($str);
$str = str_replace("\", "", $str);
$str = str_replace("/", "/", $str);
$str = str_replace(" ", " ", $str);
$str = str_replace(",", ",", $str);
return $str;
}


function phpsql_post($str){
$str = stripslashes($str);
$str = str_replace("|", "|", $str);
$str = str_replace("<", "&#60;", $str);
$str = str_replace(">", "&#62;", $str);
$str = str_replace("&nbsp;", "&#32;", $str);
$str = str_replace(" ", "&#32;", $str);
$str = str_replace("(", "&#40;", $str);
$str = str_replace(")", "&#41;", $str);
$str = str_replace("`", "&#96;", $str);
//$str = str_replace("'", "&#39;", $str);
$str = str_replace('"', "&#34;", $str);
$str = str_replace(",", "&#44;", $str);
$str = str_replace("$", "&#36;", $str);
$str = str_replace("", "&#92;", $str);
$str = str_replace("/", "&#47;", $str);
return $str;
}


function phpsql_replace($str){
$str = stripslashes($str);
$str = str_replace("'", "&#39;", $str);
return $str;
}
 

标签分类: PHP

相关阅读 更多 +
排行榜 更多 +
夕鸟

夕鸟

生活实用 下载
partyplay

partyplay

聊天通讯 下载
婚礼纪

婚礼纪

生活实用 下载