php参数过滤
//参数过滤
$sVariablesOrder = ini_get( ‘variables_order‘ );
$request = array();
//过滤不安全数据
for ( $i = 0; $i < strlen( $sVariablesOrder ); $i++ ){
$cVariableFlat = strtolower( $sVariablesOrder[$i] );
switch ( $cVariableFlat ){
case ‘e‘:
$filtered = filter_input_array ( INPUT_ENV, FILTER_SANITIZE_SPECIAL_CHARS );
break;
case ‘g‘:
$filtered = filter_input_array ( INPUT_GET, FILTER_SANITIZE_SPECIAL_CHARS );
break;
case ‘p‘:
$filtered = filter_input_array ( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
break;
case ‘c‘:
$filtered = filter_input_array ( INPUT_COOKIE, FILTER_SANITIZE_SPECIAL_CHARS );
break;
case ‘s‘:
$filtered = filter_input_array ( INPUT_SERVER, FILTER_SANITIZE_SPECIAL_CHARS );
break;
}
if ( !empty( $filtered ) ){
$request = array_merge( $request, $filtered );
}
}
本文出自 “Smile” 博客,转载请与作者联系!
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。