JRequest
JRequest Class
This class serves to provide the Joomla Platform 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.
package |
Joomla.Platform |
---|---|
subpackage |
Environment |
since |
11.1 |
deprecated |
12.1 Get the JInput object from the application instead |
Methods
_cleanVar
Clean up an input variable.
_cleanVar(mixed $var, integer $mask, string $type = null) : mixed
deprecated |
12.1 |
---|---|
since |
11.1 |
Arguments
- $var
mixed
The input variable.- $mask
integer
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.- $type
string
The variable type {@see JFilterInput::clean()}.
Response
mixed
Same as $var
_stripSlashesRecursive
Strips slashes recursively on an array.
_stripSlashesRecursive(array $value) : array
deprecated |
12.1 |
---|---|
since |
11.1 |
Arguments
- $value
array
Array or (nested arrays) of strings.
Response
array
The input array with stripslashes applied to it.
checkToken
Checks for a form token in the request.
checkToken(string $method = 'post') : boolean
Use in conjunction with JHtml::_('form.token').
deprecated |
12.1 Use JSession::checkToken() instead. |
---|---|
since |
11.1 |
Arguments
- $method
string
The request method in which to look for the token key.
Response
boolean
True if found and valid, false otherwise.
clean
Cleans the request from script injection.
clean() : void
since |
11.1 |
---|---|
deprecated |
12.1 |
get
Fetches and returns a request array.
get(string $hash = 'default', integer $mask) : mixed
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
deprecated |
12.1 User JInput::get |
---|---|
see | \JInput |
since |
11.1 |
Arguments
- $hash
string
to get (POST, GET, FILES, METHOD).- $mask
integer
Filter mask for the variable.
Response
mixed
Request hash.
getBool
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().
getBool(string $name, string $default = false, string $hash = 'default') : boolean
See getVar() for more in-depth documentation on the parameters.
deprecated |
12.1 |
---|---|
since |
11.1 |
Arguments
- $name
string
Variable name.- $default
string
Default value if the variable does not exist.- $hash
string
Where the var should come from (POST, GET, FILES, COOKIE, METHOD).
Response
boolean
Requested variable.
getCmd
Cmd (Word and Integer0 filter
getCmd(string $name, string $default = '', string $hash = 'default') : string
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.
deprecated |
12.1 |
---|---|
since |
11.1 |
Arguments
- $name
string
Variable name- $default
string
Default value if the variable does not exist- $hash
string
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
Response
string
Requested variable
getFloat
Fetches and returns a given filtered variable. The float filter only allows digits and periods. This is currently only a proxy function for getVar().
getFloat(string $name, string $default = 0.0, string $hash = 'default') : float
See getVar() for more in-depth documentation on the parameters.
since |
11.1 |
---|---|
deprecated |
12.1 |
Arguments
- $name
string
Variable name.- $default
string
Default value if the variable does not exist.- $hash
string
Where the var should come from (POST, GET, FILES, COOKIE, METHOD).
Response
float
Requested variable.
getInt
Fetches and returns a given filtered variable. The integer filter will allow only digits and the - sign to be returned. This is currently only a proxy function for getVar().
getInt(string $name, string $default, string $hash = 'default') : integer
See getVar() for more in-depth documentation on the parameters.
since |
11.1 |
---|---|
deprecated |
12.1 |
Arguments
- $name
string
Variable name.- $default
string
Default value if the variable does not exist.- $hash
string
Where the var should come from (POST, GET, FILES, COOKIE, METHOD).
Response
integer
Requested variable.
getMethod
Gets the request method.
getMethod() : string
since |
11.1 |
---|---|
deprecated |
12.1 |
Response
string
getString
Fetches and returns a given filtered variable. The string filter deletes 'bad' HTML code, if not overridden by the mask.
getString(string $name, string $default = '', string $hash = 'default', integer $mask) : string
This is currently only a proxy function for getVar().
See getVar() for more in-depth documentation on the parameters.
since |
11.1 |
---|---|
deprecated |
12.1 |
Arguments
- $name
string
Variable name- $default
string
Default value if the variable does not exist- $hash
string
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)- $mask
integer
Filter mask for the variable
Response
string
Requested variable
getUInt
Fetches and returns a given filtered variable. The unsigned integer filter will allow only digits to be returned. This is currently only a proxy function for getVar().
getUInt(string $name, string $default, string $hash = 'default') : integer
See getVar() for more in-depth documentation on the parameters.
deprecated |
12.1 |
---|---|
since |
11.1 |
Arguments
- $name
string
Variable name.- $default
string
Default value if the variable does not exist.- $hash
string
Where the var should come from (POST, GET, FILES, COOKIE, METHOD).
Response
integer
Requested variable.
getURI
Gets the full request path.
getURI() : string
since |
11.1 |
---|---|
deprecated |
12.1 |
Response
string
getVar
Fetches and returns a given variable.
getVar(string $name, string $default = null, string $hash = 'default', string $type = 'none', integer $mask) : mixed
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
since |
11.1 |
---|---|
deprecated |
12.1 Use JInput::Get |
Arguments
- $name
string
Variable name.- $default
string
Default value if the variable does not exist.- $hash
string
Where the var should come from (POST, GET, FILES, COOKIE, METHOD).- $type
string
Return type for the variable, for valid values see {@link JFilterInput::clean()}.- $mask
integer
Filter mask for the variable.
Response
mixed
Requested variable.
getWord
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().
getWord(string $name, string $default = '', string $hash = 'default') : string
See getVar() for more in-depth documentation on the parameters.
since |
11.1 |
---|---|
deprecated |
12.1 |
Arguments
- $name
string
Variable name.- $default
string
Default value if the variable does not exist.- $hash
string
Where the var should come from (POST, GET, FILES, COOKIE, METHOD).
Response
string
Requested variable.
set
Sets a request variable.
set(array $array, string $hash = 'default', boolean $overwrite = true) : void
deprecated |
12.1 Use JInput::Set |
---|---|
see | \JInput::Set |
since |
11.1 |
Arguments
- $array
array
An associative array of key-value pairs.- $hash
string
The request variable to set (POST, GET, FILES, METHOD).- $overwrite
boolean
If true and an existing key is found, the value is overwritten, otherwise it is ignored.
setVar
Set a variable in one of the request variables.
setVar(string $name, string $value = null, string $hash = 'method', boolean $overwrite = true) : string
since |
11.1 |
---|---|
deprecated |
12.1 |
Arguments
- $name
string
Name- $value
string
Value- $hash
string
Hash- $overwrite
boolean
Boolean
Response
string
Previous value