API - XOOPS 2.5.11 Beta 2
By monxoops.fr
Request Class Reference
Inheritance diagram for Request:

Static Public Member Functions

static getMethod ()
 
static getVar ($name, $default=null, $hash='default', $type='none', $mask=0)
 
static getInt ($name, $default=0, $hash='default')
 
static getFloat ($name, $default=0.0, $hash='default')
 
static getBool ($name, $default=false, $hash='default')
 
static getWord ($name, $default='', $hash='default')
 
static getCmd ($name, $default='', $hash='default')
 
static getString ($name, $default='', $hash='default', $mask=0)
 
static getArray ($name, $default=array(), $hash='default')
 
static getText ($name, $default='', $hash='default')
 
static getUrl ($name, $default='', $hash='default')
 
static getPath ($name, $default='', $hash='default')
 
static getEmail ($name, $default='', $hash='default')
 
static getIP ($name, $default='', $hash='default')
 
static getHeader ($headerName, $default='')
 
static hasVar ($name, $hash='default')
 
static setVar ($name, $value=null, $hash='method', $overwrite=true)
 
static get ($hash='default', $mask=0)
 
static set ($array, $hash='method', $overwrite=true)
 

Data Fields

const MASK_NO_TRIM = 1
 
const MASK_ALLOW_RAW = 2
 
const MASK_ALLOW_HTML = 4
 

Static Protected Member Functions

static cleanVar ($var, $mask=0, $type=null)
 
static cleanVars ($var, $mask=0, $type=null)
 
static stripSlashesRecursive ($value)
 

Member Function Documentation

◆ cleanVar()

static cleanVar (   $var,
  $mask = 0,
  $type = null 
)
staticprotected

Clean up an input variable.

Parameters
mixed$varThe input variable.
int$maskFilter 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$typeThe variable type. See FilterInput::clean().
Returns
string

◆ cleanVars()

static cleanVars (   $var,
  $mask = 0,
  $type = null 
)
staticprotected

Clean up an array of variables.

Parameters
mixed$varThe input variable.
int$maskFilter bit mask. See Request::cleanVar()
string$typeThe variable type. See FilterInput::clean().
Returns
string

◆ get()

static get (   $hash = 'default',
  $mask = 0 
)
static

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
Parameters
string$hashto get (POST, GET, FILES, METHOD)
int$maskFilter mask for the variable
Returns
mixed Request hash

◆ getArray()

static getArray (   $name,
  $default = array(),
  $hash = 'default' 
)
static

Fetches and returns an array

Parameters
string$nameVariable name
mixed$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Returns
array

◆ getBool()

static getBool (   $name,
  $default = false,
  $hash = 'default' 
)
static

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.

Parameters
string$nameVariable name
bool$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Returns
bool Requested variable

◆ getCmd()

static getCmd (   $name,
  $default = '',
  $hash = 'default' 
)
static

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

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

Parameters
string$nameVariable name
string$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Returns
string Requested variable

◆ getEmail()

static getEmail (   $name,
  $default = '',
  $hash = 'default' 
)
static

Fetches and returns an email address

Parameters
string$nameVariable name
string$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Returns
string email address or default if invalid

◆ getFloat()

static getFloat (   $name,
  $default = 0.0,
  $hash = 'default' 
)
static

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.

Parameters
string$nameVariable name
float$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Returns
float Requested variable

◆ getHeader()

static getHeader (   $headerName,
  $default = '' 
)
static

get request header

Parameters
string$headerNamename of header to retrieve, case insensitive
string | null$defaultdefault to return if named header is not found
Returns
string header value or default if header was not found
Here is the caller graph for this function:

◆ getInt()

static getInt (   $name,
  $default = 0,
  $hash = 'default' 
)
static

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.

Parameters
string$nameVariable name
int$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Returns
int Requested variable

◆ getIP()

static getIP (   $name,
  $default = '',
  $hash = 'default' 
)
static

Fetches and returns an IP address

Parameters
string$nameVariable name
string$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Returns
string IP address or default if invalid

◆ getMethod()

static getMethod ( )
static

Gets the request method

Returns
string

◆ getPath()

static getPath (   $name,
  $default = '',
  $hash = 'default' 
)
static

Fetches and returns a file (or web) path

Parameters
string$nameVariable name
string$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Returns
string Requested variable

◆ getString()

static getString (   $name,
  $default = '',
  $hash = 'default',
  $mask = 0 
)
static

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.

Parameters
string$nameVariable name
string$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
int$maskFilter mask for the variable
Returns
string Requested variable
Here is the caller graph for this function:

◆ getText()

static getText (   $name,
  $default = '',
  $hash = 'default' 
)
static

Fetches and returns raw text

Parameters
string$nameVariable name
string$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Returns
string Requested variable

◆ getUrl()

static getUrl (   $name,
  $default = '',
  $hash = 'default' 
)
static

Fetches and returns a web url

Parameters
string$nameVariable name
string$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Returns
string Requested variable

◆ getVar()

static getVar (   $name,
  $default = null,
  $hash = 'default',
  $type = 'none',
  $mask = 0 
)
static

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
Parameters
string$nameVariable name
mixed$defaultDefault value if the variable does not exist
string$hashSource of variable value (POST, GET, FILES, COOKIE, METHOD)
string$typeReturn type for the variable (INT, FLOAT, BOOLEAN, WORD, ALPHANUM, CMD, BASE64, STRING, ARRAY, PATH, NONE) For more information see FilterInput::clean().
int$maskFilter mask for the variable
Returns
mixed Requested variable

◆ getWord()

static getWord (   $name,
  $default = '',
  $hash = 'default' 
)
static

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.

Parameters
string$nameVariable name
string$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Returns
string Requested variable

◆ hasVar()

static hasVar (   $name,
  $hash = 'default' 
)
static

See if a variable exists in one of the request hashes

Parameters
string$namevariable to look for
string$hashhash to check
Returns
boolean True if hash has an element 'name', otherwise false

◆ set()

static set (   $array,
  $hash = 'method',
  $overwrite = true 
)
static

Sets a request variable

Parameters
array$arrayAn associative array of key-value pairs
string$hashThe request variable to set (POST, GET, FILES, METHOD)
boolean$overwriteIf true and an existing key is found, the value is overwritten, otherwise it is ignored
Returns
void

◆ setVar()

static setVar (   $name,
  $value = null,
  $hash = 'method',
  $overwrite = true 
)
static

Set a variable in one of the request variables

Parameters
string$nameName
string$valueValue
string$hashHash
boolean$overwriteBoolean
Returns
string Previous value

◆ stripSlashesRecursive()

static stripSlashesRecursive (   $value)
staticprotected

Strips slashes recursively on an array

Parameters
string | array$valuestring of Array of (nested arrays of) strings
Returns
array The input array with stripslashes applied to it

Field Documentation

◆ MASK_ALLOW_HTML

const MASK_ALLOW_HTML = 4

◆ MASK_ALLOW_RAW

const MASK_ALLOW_RAW = 2

◆ MASK_NO_TRIM

const MASK_NO_TRIM = 1

Available masks for cleaning variables


The documentation for this class was generated from the following file: