10 defined(
'JPATH_PLATFORM') or die;
49 public static function getURI()
52 return $uri->toString(array(
'path',
'query'));
64 public static function getMethod()
66 $method = strtoupper($_SERVER[
'REQUEST_METHOD']);
101 public static function getVar($name, $default = null, $hash =
'default', $type =
'none', $mask = 0)
104 $hash = strtoupper($hash);
105 if ($hash ===
'METHOD')
107 $hash = strtoupper($_SERVER[
'REQUEST_METHOD']);
109 $type = strtoupper($type);
110 $sig = $hash . $type . $mask;
139 if (isset(
$GLOBALS[
'_JREQUEST'][$name][
'SET.' . $hash]) && (
$GLOBALS[
'_JREQUEST'][$name][
'SET.' . $hash] ===
true))
142 $var = (isset($input[$name]) && $input[$name] !== null) ? $input[$name] : $default;
143 $var = self::_cleanVar($var, $mask, $type);
145 elseif (!isset(
$GLOBALS[
'_JREQUEST'][$name][$sig]))
147 if (isset($input[$name]) && $input[$name] !== null)
150 $var = self::_cleanVar($input[$name], $mask, $type);
152 $GLOBALS[
'_JREQUEST'][$name][$sig] = $var;
154 elseif ($default !== null)
157 $var = self::_cleanVar($default, $mask, $type);
166 $var =
$GLOBALS[
'_JREQUEST'][$name][$sig];
189 public static function getInt($name, $default = 0, $hash =
'default')
191 return self::getVar($name, $default, $hash,
'int');
210 public static function getUInt($name, $default = 0, $hash =
'default')
212 return self::getVar($name, $default, $hash,
'uint');
232 public static function getFloat($name, $default = 0.0, $hash =
'default')
234 return self::getVar($name, $default, $hash,
'float');
253 public static function getBool($name, $default =
false, $hash =
'default')
255 return self::getVar($name, $default, $hash,
'bool');
275 public static function getWord($name, $default =
'', $hash =
'default')
277 return self::getVar($name, $default, $hash,
'word');
298 public static function getCmd($name, $default =
'', $hash =
'default')
300 return self::getVar($name, $default, $hash,
'cmd');
321 public static function getString($name, $default =
'', $hash =
'default', $mask = 0)
324 return (
string) self::getVar($name, $default, $hash,
'string', $mask);
341 public static function setVar($name, $value = null, $hash =
'method', $overwrite =
true)
344 if (!$overwrite && array_key_exists($name, $_REQUEST))
346 return $_REQUEST[$name];
350 $GLOBALS[
'_JREQUEST'][$name] = array();
353 $hash = strtoupper($hash);
354 if ($hash ===
'METHOD')
356 $hash = strtoupper($_SERVER[
'REQUEST_METHOD']);
359 $previous = array_key_exists($name, $_REQUEST) ? $_REQUEST[$name] : null;
364 $_GET[$name] = $value;
365 $_REQUEST[$name] = $value;
368 $_POST[$name] = $value;
369 $_REQUEST[$name] = $value;
372 $_COOKIE[$name] = $value;
373 $_REQUEST[$name] = $value;
376 $_FILES[$name] = $value;
379 $_ENV[
'name'] = $value;
382 $_SERVER[
'name'] = $value;
387 $GLOBALS[
'_JREQUEST'][$name][
'SET.' . $hash] =
true;
388 $GLOBALS[
'_JREQUEST'][$name][
'SET.REQUEST'] =
true;
420 public static function get($hash =
'default', $mask = 0)
422 $hash = strtoupper($hash);
424 if ($hash ===
'METHOD')
426 $hash = strtoupper($_SERVER[
'REQUEST_METHOD']);
460 $result = self::_cleanVar($input, $mask);
478 public static function set($array, $hash =
'default', $overwrite =
true)
480 foreach ($array as $key => $value)
482 self::setVar($key, $value, $hash, $overwrite);
498 public static function checkToken($method =
'post')
500 if ($method ==
'default')
525 protected static function _cleanVar($var, $mask = 0, $type = null)
528 if (!($mask & 1) && is_string($var))
543 $var = $safeHtmlFilter->clean($var, $type);
550 $var = $noHtmlFilter->clean($var, $type);