2 /***************************************************************************
3 * Copyright (C) 2003-2011 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
24 public static function _get($key, $default)
26 return isset($_REQUEST[$key]) ?
$_REQUEST[$key] : $default;
29 public static function has($key)
31 return isset($_REQUEST[$key]);
34 public static function kill($key)
36 unset($_REQUEST[$key]);
39 public static function v($key, $default = null
)
41 return Env
::_get($key, $default);
44 public static function s($key, $default = '')
46 return (string)Env
::_get($key, $default);
49 public static function t($key, $default = '')
51 return trim(Env
::s($key, $default));
54 public static function blank($key, $strict = false
)
56 if (!Env
::has($key)) {
59 $var = $strict ? Env
::s($key) : Env
::t($key);
63 public static function b($key, $default = false
)
65 return (bool
)Env
::_get($key, $default);
68 public static function i($key, $default = 0)
70 $i = to_integer(Env
::_get($key, $default));
71 return $i === false ?
$default : $i;
74 public static function l(array $keys)
76 return array_map(array('Env', 'v'), $keys);
79 public static function set($key, $value)
81 $_REQUEST[$key] =& $value;
84 public static function bootstrap($key, $value)
86 if (!Env
::has($key)) {
87 Env
::set($key, $value);
94 public static function _get($key, $default)
96 return isset($_POST[$key]) ?
$_POST[$key] : $default;
99 public static function has($key)
101 return isset($_POST[$key]);
104 public static function kill($key)
109 public static function v($key, $default = null
)
111 return Post
::_get($key, $default);
114 public static function b($key, $default = false
)
116 return (bool
)Post
::_get($key, $default);
119 public static function s($key, $default = '')
121 return (string)Post
::_get($key, $default);
124 public static function t($key, $default = '')
126 return trim(Post
::s($key, $default));
129 public static function blank($key, $strict = false
)
131 if (!Post
::has($key)) {
134 $var = $strict ? Post
::s($key) : Post
::t($key);
138 public static function i($key, $default = 0)
140 $i = to_integer(Post
::_get($key, $default));
141 return $i === false ?
$default : $i;
144 public static function l(array $keys)
146 return array_map(array('Post', 'v'), $keys);
149 public static function set($key, $value)
151 $_POST[$key] =& $value;
154 public static function bootstrap($key, $value)
156 if (!Post
::has($key)) {
157 Post
::set($key, $value);
164 public static function _get($key, $default)
166 return isset($_GET[$key]) ?
$_GET[$key] : $default;
169 public static function has($key)
171 return isset($_GET[$key]);
174 public static function kill($key)
179 public static function v($key, $default = null
)
181 return Get
::_get($key, $default);
184 public static function b($key, $default = false
)
186 return (bool
)Get
::_get($key, $default);
189 public static function s($key, $default = '')
191 return (string)Get
::_get($key, $default);
194 public static function t($key, $default = '')
196 return trim(Get
::s($key, $default));
199 public static function blank($key, $strict = false
)
201 if (!Get
::has($key)) {
204 $var = $strict ? Get
::s($key) : Get
::t($key);
208 public static function i($key, $default = 0)
210 $i = to_integer(Get
::_get($key, $default));
211 return $i === false ?
$default : $i;
214 public static function l(array $keys)
216 return array_map(array('Get', 'v'), $keys);
219 public static function set($key, $value)
221 $_GET[$key] =& $value;
224 public static function bootstrap($key, $value)
226 if (!Get
::has($key)) {
227 Get
::set($key, $value);
234 public static function _get($key, $default)
237 $key = $globals->cookie_ns
. $key;
238 return isset($_COOKIE[$key]) ?
$_COOKIE[$key] : $default;
241 public static function has($key)
244 $key = $globals->cookie_ns
. $key;
245 return isset($_COOKIE[$key]);
248 public static function kill($key)
251 $key = $globals->cookie_ns
. $key;
252 setcookie($key, '', time() - 3600, $globals->cookie_path
);
253 unset($_COOKIE[$key]);
256 public static function set($key, $value, $days, $secure = false
) {
258 $key = $globals->cookie_ns
. $key;
259 if (!$secure ||
@$_SERVER['HTTPS']) {
260 setcookie($key, $value, time() +
86400 * $days, $globals->cookie_path
, '',
262 $_COOKIE[$key] = $value;
266 public static function v($key, $default = null
)
268 return Cookie
::_get($key, $default);
271 public static function s($key, $default = '')
273 return (string)Cookie
::_get($key, $default);
276 public static function t($key, $default = '')
278 return trim(Cookie
::s($key, $default));
281 public static function blank($key, $strict = false
)
283 if (!Cookie
::has($key)) {
286 $var = $strict ? Cookie
::s($key) : Cookie
::t($key);
290 public static function b($key, $default = false
)
292 return (bool
)Cookie
::_get($key, $default);
295 public static function i($key, $default = 0)
297 $i = to_integer(Cookie
::_get($key, $default));
298 return $i === false ?
$default : $i;
301 public static function l(array $keys)
303 return array_map(array('Cookie', 'v'), $keys);
307 function fix_gpc_magic(&$item, $key) {
308 if (is_array($item)) {
309 array_walk($item, 'fix_gpc_magic');
311 $item = stripslashes($item);
315 if (ini_get('magic_quotes_gpc') && empty($DONT_FIX_GPC)) {
316 array_walk($_GET, 'fix_gpc_magic');
317 array_walk($_POST, 'fix_gpc_magic');
318 array_walk($_COOKIE, 'fix_gpc_magic');
319 array_walk($_REQUEST, 'fix_gpc_magic');
322 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: