Joomla! 1.5 API

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2011 Open Source Matters Inc and can be used in accordance with the Joomla! Electronic Documentation License. Some parts of this website may be subject to other licenses.

 Class JRequest

Description

JRequest Class

This class serves to provide the Joomla Framework with a common interface to access request variables. This includes $_POST, $_GET, and naturally $_REQUEST. Variables can be passed through an input filter to avoid injection or returned raw.

  • since: 1.5

Located in /joomla/environment/request.php (line 42)

Class JRequest   (Subpackage Environment)
Method Summary
Static method static void clean ()
Static method static mixed get ([string $hash = 'default'], [int $mask = 0])
Static method static bool getBool (string $name, [string $default = false], [string $hash = 'default'])
Static method static string getCmd (string $name, [string $default = ''], [string $hash = 'default'])
Static method static float getFloat (string $name, [string $default = 0.0], [string $hash = 'default'])
Static method static integer getInt (string $name, [string $default = 0], [string $hash = 'default'])
Static method static string getString (string $name, [string $default = ''], [string $hash = 'default'], [int $mask = 0])
Static method static mixed getVar (string $name, [string $default = null], [string $hash = 'default'], [string $type = 'none'], [int $mask = 0])
Static method static string getWord (string $name, [string $default = ''], [string $hash = 'default'])
Method boolean checkToken ([string $method = 'post'])
Method string getMethod ()
Method string getURI ()
Method void set (array $array, [string $hash = 'default'], [boolean $overwrite = true])
Method string setVar (string $name, [string $value = null], [string $hash = 'method'], [boolean $overwrite = true])
Method void _cleanArray ( &$array, [boolean $globalise = false], array $array)
Method void _cleanVar (mixed $var, [int $mask = 0], [string $type = null])
Method array _stripSlashesRecursive ( $value, array $array)
Methods
checkToken (line 435)

Checks for a form token in the request

Use in conjuction with JHTML::_( 'form.token' )

  • return: True if found and valid, false otherwise
boolean checkToken ([string $method = 'post'])
  • string $method: The request method in which to look for the token key
clean (line 461)

Cleans the request from script injection.

  • since: 1.5
void clean ()
get (line 364)

Fetches and returns a request array.

The default behaviour is fetching variables depending on the current request method: GET and HEAD will result in returning $_GET, POST and PUT will result in returning $_POST.

You can force the source by setting the $hash parameter:

post $_POST get $_GET files $_FILES cookie $_COOKIE env $_ENV server $_SERVER method via current $_SERVER['REQUEST_METHOD'] default $_REQUEST

  • return: Request hash
  • since: 1.5
mixed get ([string $hash = 'default'], int $mask)
  • string $hash: to get (POST, GET, FILES, METHOD)
  • int $mask: Filter mask for the variable
getBool (line 215)

Fetches and returns a given filtered variable. The bool filter will only return true/false bool values. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

  • return: Requested variable
  • since: 1.5
bool getBool (string $name, [string $default = false], [string $hash = 'default'])
  • string $name: Variable name
  • string $default: Default value if the variable does not exist
  • string $hash: Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
getCmd (line 253)

Fetches and returns a given filtered variable. The cmd filter only allows the characters [A-Za-z0-9.-_]. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

  • return: Requested variable
  • since: 1.5
string getCmd (string $name, [string $default = ''], [string $hash = 'default'])
  • string $name: Variable name
  • string $default: Default value if the variable does not exist
  • string $hash: Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
getFloat (line 196)

Fetches and returns a given filtered variable. The float filter only allows digits and periods. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

  • return: Requested variable
  • since: 1.5
float getFloat (string $name, [string $default = 0.0], [string $hash = 'default'])
  • string $name: Variable name
  • string $default: Default value if the variable does not exist
  • string $hash: Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
getInt (line 177)

Fetches and returns a given filtered variable. The integer filter will allow only digits to be returned. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

  • return: Requested variable
  • since: 1.5
integer getInt (string $name, string $default, [string $hash = 'default'])
  • string $name: Variable name
  • string $default: Default value if the variable does not exist
  • string $hash: Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
getMethod (line 60)

Gets the request method

string getMethod ()
getString (line 273)

Fetches and returns a given filtered variable. The string filter deletes 'bad' HTML code, if not overridden by the mask.

This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

  • return: Requested variable
  • since: 1.5
string getString (string $name, [string $default = ''], [string $hash = 'default'], int $mask)
  • string $name: Variable name
  • string $default: Default value if the variable does not exist
  • string $hash: Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
  • int $mask: Filter mask for the variable
getURI (line 49)

Gets the full request path

string getURI ()
getVar (line 94)

Fetches and returns a given variable.

The default behaviour is fetching variables depending on the current request method: GET and HEAD will result in returning an entry from $_GET, POST and PUT will result in returning an entry from $_POST.

You can force the source by setting the $hash parameter:

post $_POST get $_GET files $_FILES cookie $_COOKIE env $_ENV server $_SERVER method via current $_SERVER['REQUEST_METHOD'] default $_REQUEST

  • return: Requested variable
  • since: 1.5
mixed getVar (string $name, [string $default = null], [string $hash = 'default'], [string $type = 'none'], int $mask)
  • string $name: Variable name
  • string $default: Default value if the variable does not exist
  • string $hash: Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
  • string $type: Return type for the variable, for valid values see JFilterInput::clean()
  • int $mask: Filter mask for the variable
getWord (line 234)

Fetches and returns a given filtered variable. The word filter only allows the characters [A-Za-z_]. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

  • return: Requested variable
  • since: 1.5
string getWord (string $name, [string $default = ''], [string $hash = 'default'])
  • string $name: Variable name
  • string $default: Default value if the variable does not exist
  • string $hash: Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
set (line 420)

Sets a request variable

void set (array $array, [string $hash = 'default'], [boolean $overwrite = true])
  • array $array: An associative array of key-value pairs
  • string $hash: The request variable to set (POST, GET, FILES, METHOD)
  • boolean $overwrite: If true and an existing key is found, the value is overwritten, otherwise it is ingored
setVar (line 290)

Set a variabe in on of the request variables

  • return: Previous value
  • since: 1.5
  • access: public
string setVar (string $name, [string $value = null], [string $hash = 'method'], [boolean $overwrite = true])
  • string $name: Name
  • string $value: Value
  • string $hash: Hash
  • boolean $overwrite: Boolean
_cleanArray (line 516)

Adds an array to the GLOBALS array and checks that the GLOBALS variable is not being attacked

  • since: 1.5
  • access: protected
void _cleanArray ( &$array, [boolean $globalise = false], array $array)
  • array $array: Array to clean
  • boolean $globalise: True if the array is to be added to the GLOBALS
  • &$array
_cleanVar (line 548)

Clean up an input variable.

void _cleanVar (mixed $var, int $mask, [string $type = null])
  • mixed $var: The input variable.
  • int $mask: Filter bit mask. 1=no trim: If this flag is cleared and the input is a string, the string will have leading and trailing whitespace trimmed. 2=allow_raw: If set, no more filtering is performed, higher bits are ignored. 4=allow_html: HTML is allowed, but passed through a safe HTML filter first. If set, no more filtering is performed. If no bits other than the 1 bit is set, a strict filter is applied.
  • string $type: The variable type {@see JFilterInput::clean()}.
_stripSlashesRecursive (line 591)

Strips slashes recursively on an array

  • return: The input array with stripshlashes applied to it
  • access: protected
array _stripSlashesRecursive ( $value, array $array)
  • array $array: Array of (nested arrays of) strings
  • $value
Support Joomla!