對用戶傳入的變量進行轉義操作處理,摘自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);}