最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
经典php防注入函数代码
时间:2010-12-25 编辑:简简单单 来源:一聚教程网
php教程
/*************************
说明:
判断传递的变量中是否含有非法字符
如$_post、$_get
功能:
防注入
**************************/
//要过滤的非法字符 这个过滤的字符 还可以增加
$arrfiltrate=array("'",";","union");
//出错后要跳转的url,不填则默认前一页
$strgourl="";
//是否存在数组中的值
function funstringexist($strfiltrate,$arrfiltrate){
foreach ($arrfiltrate as $key=>$value){
if (eregi($value,$strfiltrate)){
return true;
}
}
return false;
}//合并$_post 和 $_get
if(function_exists(array_merge)){
$arrpostandget=array_merge($http_post_vars,$http_get_vars);
}else{
foreach($http_post_vars as $key=>$value){
$arrpostandget[]=$value;
}
foreach($http_get_vars as $key=>$value){
$arrpostandget[]=$value;
}
}//验证开始
foreach($arrpostandget as $key=>$value){
if (funstringexist($value,$arrfiltrate)){
echo "";
if (empty($strgourl)){
echo "";
}else{
echo "";
}
exit;
}
}
?>
-
上一个: ob_start 生成html页面代码
-
下一个: php查询ip所在地代码
相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24