2 /***************************************************************************
3 * Copyright (C) 2003-2004 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 ***************************************************************************/
28 function _get($key, $default)
30 return isset($_REQUEST[$key]) ?
$_REQUEST[$key] : $default;
38 return isset($_REQUEST[$key]);
46 unset($_REQUEST[$key]);
52 function get($key, $default='')
54 return (string)Env
::_get($key, $default);
58 // {{{ function &getMixed
60 function &getMixed($key, $default=null
)
62 return Env
::_get($key, $default);
66 // {{{ function getBool
68 function getBool($key, $default=false
)
70 return (bool
)Env
::_get($key, $default);
74 // {{{ function getInt
76 function getInt($key, $default=0)
78 $i = Env
::_get($key, $default);
79 return preg_match(',^[0-9]+$,', $i) ?
intval($i) : $default;
92 function _get($key, $default)
94 return isset($_POST[$key]) ?
$_POST[$key] : $default;
102 return isset($_POST[$key]);
116 function get($key, $default='')
118 return (string)Post
::_get($key, $default);
122 // {{{ function &getMixed
124 function &getMixed($key, $default=null
)
126 return Post
::_get($key, $default);
130 // {{{ function getBool
132 function getBool($key, $default=false
)
134 return (bool
)Post
::_get($key, $default);
138 // {{{ function getInt
140 function getInt($key, $default=0)
142 $i = Post
::_get($key, $default);
143 return preg_match(',^[0-9]+$,', $i) ?
intval($i) : $default;
156 function _get($key, $default)
158 return isset($_GET[$key]) ?
$_GET[$key] : $default;
166 return isset($_GET[$key]);
180 function get($key, $default='')
182 return (string)Get
::_get($key, $default);
186 // {{{ function &getMixed
188 function &getMixed($key, $default=null
)
190 return Get
::_get($key, $default);
194 // {{{ function getBool
196 function getBool($key, $default=false
)
198 return (bool
)Get
::_get($key, $default);
202 // {{{ function getInt
204 function getInt($key, $default=0)
206 $i = Get
::_get($key, $default);
207 return preg_match(',^[0-9]+$,', $i) ?
intval($i) : $default;
220 function _get($key, $default)
222 return isset($_SESSION[$key]) ?
$_SESSION[$key] : $default;
230 return isset($_SESSION[$key]);
238 unset($_SESSION[$key]);
244 function get($key, $default='')
246 return (string)Session
::_get($key, $default);
250 // {{{ function &getMixed
252 function &getMixed($key, $default=null
)
254 return Session
::_get($key, $default);
258 // {{{ function getBool
260 function getBool($key, $default=false
)
262 return (bool
)Session
::_get($key, $default);
266 // {{{ function getInt
268 function getInt($key, $default=0)
270 $i = Session
::_get($key, $default);
271 return preg_match(',^[0-9]+$,', $i) ?
intval($i) : $default;
284 function _get($key, $default)
286 return isset($_COOKIE[$key]) ?
$_COOKIE[$key] : $default;
294 return isset($_COOKIE[$key]);
302 unset($_COOKIE[$key]);
308 function get($key, $default='')
310 return (string)Cookie
::_get($key, $default);
314 // {{{ function &getMixed
316 function &getMixed($key, $default=null
)
318 return Cookie
::_get($key, $default);
322 // {{{ function getBool
324 function getBool($key, $default=false
)
326 return (bool
)Cookie
::_get($key, $default);
330 // {{{ function getInt
332 function getInt($key, $default=0)
334 $i = Cookie
::_get($key, $default);
335 return preg_match(',^[0-9]+$,', $i) ?
intval($i) : $default;
343 function fix_gpc_magic(&$item, $key) {
344 if (is_array($item)) {
345 array_walk($item, 'fix_gpc_magic');
347 $item = stripslashes($item);
351 function unfix_gpc_magic(&$item, $key) {
352 if (is_array($item)) {
353 array_walk($item, 'unfix_gpc_magic');
355 $item = addslashes($item);
359 if (ini_get("magic_quotes_gpc")) {
360 array_walk($_GET, 'fix_gpc_magic');
361 array_walk($_POST, 'fix_gpc_magic');
362 array_walk($_COOKIE, 'fix_gpc_magic');
363 array_walk($_REQUEST, 'fix_gpc_magic');
366 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: