glFusion Wiki

Site Tools


glfusion:development:api:sanitize_class:filtervar

sanitize::filterVar

(glFusion SVN)

filterVar – Filters and returns a variable.

Description

filterVar( $type, $key, $A, $default )

Filters and returns a variable.

Parameters

type

Type of data to retrieve:
  * INTEGER
  * FLOAT / DOUBLE
  * STRICT
  * PLAIN / TEXT / PLAINTEXT
  * HTML
  * RAW
  * BOOLEAN / BOOL
  * URL
  * SQL
  * FILENAME
Type Filtering Description
INTEGER The data returned will be numeric, if non-numeric data is found (i.e.; ABC) 0 will be returned
FLOAT The data returned will be numeric, of type float. If non-numeric data is found, 0 will be returned
STRICT Data will be stripped of any tags (i.e.; <script>)
Data will be stripped of any JavaScript
The following characters will terminate the string (' “ ` ; , \)
PLAIN The data will be stripped of any tags (i.e.; <script>)
All HTML characters will be translated to their corresponding HTML entities
HTML The data will be filtered through the HTML Filter
RAW No data filtering is performed
BOOLEAN Always returns a 0 or 1
URL URL is checked to ensure the protocol (i.e.; http or ftp) is allowed
SQL Data is escaped and prepared for use in SQL query
FILENAME Any .. are removed from the filename, only a-z, 0-9, A-Z, and _ (underscore) are allowed in the filename

key

Array key in the $A array to filter

Pass only key to filter a single variable

mode

Type of data; post, get, request, env, cookie. Must specify in
order of precedence. This can be an array i.e.; array('get','post') 
would check $_GET first, if not found then it would check $_POST.

default

Default value to return if key not found in data array.

Return Value

The filtered data.

Data type of the return value will depend on the type requested.

Example

$comment = $inputHandler->filterVar('html',$comment,'','');

This example will filter the variable $comment through the HTML filter.

Notes

Pass only $key to filter a single variable.

See Also

glfusion/development/api/sanitize_class/filtervar.txt · Last modified: 2017/04/12 21:15 (external edit)

Page Tools