对用户传入的变量进行转义操作处理,摘自ecshop。
/* 对用户传入的变量进行转义操作。*/
if (!get_magic_quotes_gpc()){
if (!empty($_GET)){$_GET = addslashes_deep($_GET);}
if (!empty($_POST)){$_POST = addslashes_deep($_POST);}
$_COOKIE = addslashes_deep($_COOKIE);
$_REQUEST = addslashes_deep($_REQUEST);
}
/* 递归方式的对变量中的特殊字符进行转义*/
function addslashes_deep($value){return empty($value)?$value:is_array($value) ? array_map('addslashes_deep', $value) : addslashes($value);}