X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fenv.php;h=7448a71254e3c5a7d6cb24bb51c388b71514c1c7;hb=0b8d276921e5d6905a976f1e070b2450e58ef051;hp=938596c5695a47380257044481040a0af05df472;hpb=5ddeb07cc787dd1dc3630a31f1528f5cc7c4d9b9;p=platal.git diff --git a/classes/env.php b/classes/env.php index 938596c..7448a71 100644 --- a/classes/env.php +++ b/classes/env.php @@ -41,6 +41,11 @@ class Env return Env::_get($key, $default); } + public static function s($key, $default = '') + { + return (string)Env::_get($key, $default); + } + public static function b($key, $default = false) { return (bool)Env::_get($key, $default); @@ -51,6 +56,11 @@ class Env $i = Env::_get($key, $default); return is_numeric($i) ? intval($i) : $default; } + + public static function l(array $keys) + { + return array_map(array('Env', 'v'), $keys); + } } class Post @@ -80,11 +90,21 @@ class Post return (bool)Post::_get($key, $default); } + public static function s($key, $default = '') + { + return (string)Post::_get($key, $default); + } + public static function i($key, $default = 0) { $i = Post::_get($key, $default); return is_numeric($i) ? intval($i) : $default; } + + public static function l(array $keys) + { + return array_map(array('Post', 'v'), $keys); + } } class Get @@ -114,11 +134,21 @@ class Get return (bool)Get::_get($key, $default); } + public static function s($key, $default = '') + { + return (string)Get::_get($key, $default); + } + public static function i($key, $default = 0) { $i = Get::_get($key, $default); return is_numeric($i) ? intval($i) : $default; } + + public static function l(array $keys) + { + return array_map(array('Get', 'v'), $keys); + } } class Cookie @@ -143,6 +173,11 @@ class Cookie return Cookie::_get($key, $default); } + public static function s($key, $default = '') + { + return (string)Cookie::_get($key, $default); + } + public static function b($key, $default = false) { return (bool)Cookie::_get($key, $default); @@ -153,6 +188,11 @@ class Cookie $i = Cookie::_get($key, $default); return is_numeric($i) ? intval($i) : $default; } + + public static function l(array $keys) + { + return array_map(array('Cookie', 'v'), $keys); + } } function fix_gpc_magic(&$item, $key) { @@ -162,13 +202,6 @@ function fix_gpc_magic(&$item, $key) { $item = stripslashes($item); } } -function fix_encoding(&$item, $key) { - if (is_array($item)) { - array_walk($item, 'fix_encoding'); - } elseif (preg_match('/[\x80-\x9f]/', $item)) { - $item = iconv('CP1252', 'ISO-8859-15//TRANSLIT', $item); - } -} if (ini_get('magic_quotes_gpc') && empty($DONT_FIX_GPC)) { array_walk($_GET, 'fix_gpc_magic'); @@ -176,7 +209,6 @@ if (ini_get('magic_quotes_gpc') && empty($DONT_FIX_GPC)) { array_walk($_COOKIE, 'fix_gpc_magic'); array_walk($_REQUEST, 'fix_gpc_magic'); } -array_walk($_POST, 'fix_encoding'); -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>