JRequest

JRequest Class

deprecated

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.

since

1.5

deprecated

1.7 Get the JInput object from the application instead

package

Joomla.Legacy

Methods

_cleanVar

Clean up an input variable.

_cleanVar(mixed $var, integer $mask, string $type = null) : mixed
static deprecated
since

1.5

deprecated

1.7

Arguments

$var

mixedThe input variable.

$mask

integerFilter 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

stringThe variable type {@see JFilterInput::clean()}.

Response

mixedSame as $var

checkToken

Checks for a form token in the request.

checkToken(string $method = 'post') : boolean
static deprecated

Use in conjunction with JHtml::_('form.token').

since

1.5

deprecated

1.7 Use JSession::checkToken() instead. Note that 'default' has to become 'request'.

Arguments

$method

stringThe request method in which to look for the token key.

Response

booleanTrue if found and valid, false otherwise.

get

Fetches and returns a request array.

get(string $hash = 'default', integer $mask) : mixed
static deprecated

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

since

1.5

deprecated

1.7 Use JInput::get()

see \JInput

Arguments

$hash

stringto get (POST, GET, FILES, METHOD).

$mask

integerFilter mask for the variable.

Response

mixedRequest 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, boolean $default = false, string $hash = 'default') : boolean
static deprecated

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

since

1.5

deprecated

1.7

Arguments

$name

stringVariable name.

$default

booleanDefault value if the variable does not exist.

$hash

stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).

Response

booleanRequested variable.

getCmd

Cmd (Word and Integer) filter

getCmd(string $name, string $default = '', string $hash = 'default') : string
static deprecated

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.

since

1.5

deprecated

1.7

Arguments

$name

stringVariable name

$default

stringDefault value if the variable does not exist

$hash

stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)

Response

stringRequested 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, float $default = 0.0, string $hash = 'default') : float
static deprecated

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

since

1.5

deprecated

1.7

Arguments

$name

stringVariable name.

$default

floatDefault value if the variable does not exist.

$hash

stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).

Response

floatRequested 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, integer $default, string $hash = 'default') : integer
static deprecated

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

since

1.5

deprecated

1.7

Arguments

$name

stringVariable name.

$default

integerDefault value if the variable does not exist.

$hash

stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).

Response

integerRequested variable.

getMethod

Gets the request method.

getMethod() : string
static deprecated
since

1.5

deprecated

1.7 Use JInput::getMethod() instead

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
static deprecated

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

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

since

1.5

deprecated

1.7

Arguments

$name

stringVariable name

$default

stringDefault value if the variable does not exist

$hash

stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)

$mask

integerFilter mask for the variable

Response

stringRequested 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, integer $default, string $hash = 'default') : integer
static deprecated

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

since

1.7

deprecated

1.7

Arguments

$name

stringVariable name.

$default

integerDefault value if the variable does not exist.

$hash

stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).

Response

integerRequested variable.

getUri

Gets the full request path.

getUri() : string
static deprecated
since

1.5

deprecated

1.7

Response

string

getVar

Fetches and returns a given variable.

getVar(string $name, mixed $default = null, string $hash = 'default', string $type = 'none', integer $mask) : mixed
static deprecated

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

1.5

deprecated

1.7 Use JInput::get()

Arguments

$name

stringVariable name.

$default

mixedDefault value if the variable does not exist.

$hash

stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).

$type

stringReturn type for the variable, for valid values see {@link JFilterInput::clean()}.

$mask

integerFilter mask for the variable.

Response

mixedRequested 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
static deprecated

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

since

1.5

deprecated

1.7

Arguments

$name

stringVariable name.

$default

stringDefault value if the variable does not exist.

$hash

stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).

Response

stringRequested variable.

set

Sets a request variable.

set(array $array, string $hash = 'default', boolean $overwrite = true) : void
static deprecated
since

1.5

deprecated

1.7 Use JInput::set()

Arguments

$array

arrayAn associative array of key-value pairs.

$hash

stringThe request variable to set (POST, GET, FILES, METHOD).

$overwrite

booleanIf 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
static deprecated
since

1.5

deprecated

1.7

Arguments

$name

stringName

$value

stringValue

$hash

stringHash

$overwrite

booleanBoolean

Response

stringPrevious value