post and get 检查非法参数

来源:互联网 发布:苹果最新系统下载软件 编辑:程序博客网 时间:2024/06/08 04:15
//是否存在数组中的值
function FunStringExist($StrFiltrate,$ArrFiltrate){
foreach ($ArrFiltrate as $key=>$value){
if (preg_match("/".$value."/",$StrFiltrate)){
return true;
}
}
return false;
}




//验证开始
function str_check($ArrFiltrate=array()){
if(!isset($ArrFiltrate)){
$ArrFiltrate = array();
}
//合并$_POST 和 $_GET
$ArrPostAndGet = array();
foreach($_POST as $key=>$value){
$ArrPostAndGet[]=$value;
}
foreach($_GET as $key=>$value){
$ArrPostAndGet[]=$value;
}
foreach($ArrPostAndGet as $key=>$value){
if (FunStringExist($value,$ArrFiltrate)){
return false;
}else{
continue;
}
}
return true;

}


$ArrFiltrate=array("eval",";","'","\"","<",">","union");
if(!str_check($ArrFiltrate)){
echo make_json_app_response('1','存在非法参数');
exit;
}



0 0
原创粉丝点击