//是否存在数组中的值
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;
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;
}