标签: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” 博客,转载请与作者联系!
标签:php 参数 参数过滤
原文地址:http://nightwizard.blog.51cto.com/2181643/1532963