request
class request implements request_interface
All application input is accessed through this class.
It provides a method to disable access to input data through super globals. This should force MOD authors to read about data validation.
Properties
protected array | $super_globals | ||
protected array | $original_request | ||
protected bool | $super_globals_disabled | ||
protected array | $input | ||
protected type_cast_helper_interface | $type_cast_helper |
Methods
Initialises the request class, that means it stores all input data in $input input and then calls \phpbb\request\deactivated_super_global \phpbb\request\deactivated_super_global
Getter for $super_globals_disabled
Disables access of super globals specified in $super_globals.
Enables access of super globals specified in $super_globals if they were disabled by disable_super_globals disable_super_globals.
This function allows overwriting or setting a value in one of the super global arrays.
Central type safe input handling function.
Get a variable, but without trimming strings.
Get a variable without trimming strings and without escaping.
Shortcut method to retrieve SERVER variables.
Shortcut method to retrieve the value of client HTTP headers.
Shortcut method to retrieve $_FILES variables
Checks whether a certain variable was sent via POST.
Checks whether a certain variable is set in one of the super global arrays.
Checks whether the current request is an AJAX request (XMLHttpRequest)
Checks if the current request is happening over HTTPS.
Returns all variable names for a given super global
Helper function used by variable() and untrimmed_variable().
Returns the original array of the requested super global
Escape a string variable.
Details
at line 60
__construct(type_cast_helper_interface $type_cast_helper = null, $disable_super_globals = true)
Initialises the request class, that means it stores all input data in $input input and then calls \phpbb\request\deactivated_super_global \phpbb\request\deactivated_super_global
at line 91
bool
super_globals_disabled()
Getter for $super_globals_disabled
at line 100
disable_super_globals()
Disables access of super globals specified in $super_globals.
This is achieved by overwriting the super globals with instances of \phpbb\request\deactivated_super_global \phpbb\request\deactivated_super_global
at line 118
enable_super_globals()
Enables access of super globals specified in $super_globals if they were disabled by disable_super_globals disable_super_globals.
This is achieved by making the super globals point to the data stored within this class in $input input.
at line 146
overwrite(string $var_name, mixed $value, string $super_global = \phpbb\request\request_interface::REQUEST)
This function allows overwriting or setting a value in one of the super global arrays.
Changes which are performed on the super globals directly will not have any effect on the results of other methods this class provides. Using this function should be avoided if possible! It will consume twice the the amount of memory of the value
at line 190
mixed
variable(string|array $var_name, mixed $default, bool $multibyte = false, string $super_global = \phpbb\request\request_interface::REQUEST)
Central type safe input handling function.
All variables in GET or POST requests should be retrieved through this function to maximise security.
at line 214
mixed
untrimmed_variable(string|array $var_name, mixed $default, bool $multibyte = false, string $super_global = \phpbb\request\request_interface::REQUEST)
Get a variable, but without trimming strings.
Same functionality as variable(), except does not run trim() on strings. This method should be used when handling passwords.
at line 222
mixed
raw_variable(string|array $var_name, mixed $default, string $super_global = \phpbb\request\request_interface::REQUEST)
Get a variable without trimming strings and without escaping.
This method MUST NOT be used with queries. Same functionality as variable(), except does not run trim() on strings and does not escape input. This method should only be used when the raw input is needed without any escaping, i.e. for database password during the installation.
at line 275
mixed
server(string|array $var_name, mixed $default = '')
Shortcut method to retrieve SERVER variables.
Also fall back to getenv(), some CGI setups may need it (probably not, but whatever).
at line 299
mixed
header(string|array $header_name, mixed $default = '')
Shortcut method to retrieve the value of client HTTP headers.
at line 313
array
file(string $form_name)
Shortcut method to retrieve $_FILES variables
at line 328
bool
is_set_post(string $name)
Checks whether a certain variable was sent via POST.
To make sure that a request was sent using POST you should call this function on at least one variable.
at line 343
bool
is_set(string $var, string $super_global = \phpbb\request\request_interface::REQUEST)
Checks whether a certain variable is set in one of the super global arrays.
at line 353
bool
is_ajax()
Checks whether the current request is an AJAX request (XMLHttpRequest)
at line 363
bool
is_secure()
Checks if the current request is happening over HTTPS.
at line 379
array
variable_names(string $super_global = \phpbb\request\request_interface::REQUEST)
Returns all variable names for a given super global
at line 407
protected mixed
_variable(string|array $var_name, mixed $default, bool $multibyte = false, string $super_global = \phpbb\request\request_interface::REQUEST, bool $trim = true)
Helper function used by variable() and untrimmed_variable().
at line 427
array
get_super_global(string $super_global = \phpbb\request\request_interface::REQUEST)
Returns the original array of the requested super global
at line 435
string|array
escape($var, bool $multibyte)
Escape a string variable.