PHP Класс CI_Input, ci-phpunit-test

Pre-processes global input data for security
Автор: ExpressionEngine Dev Team
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_allow_get_array boolean If set to FALSE, then $_GET will be set to an empty array.
$_enable_csrf boolean Enables a CSRF cookie token to be set. Set automatically based on config setting.
$_enable_xss boolean Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered. Set automatically based on config setting.
$_input_stream array Parsed from php://input at runtime
$_raw_input_stream string Holds a cache of php://input contents
$_standardize_newlines boolean If set to TRUE, then newlines are standardized.
$headers array List of all HTTP request headers
$ip_address string IP address of the current user
$security
$uni

Открытые методы

Метод Описание
__construct ( ) : void Class constructor
__get ( string $name ) : mixed Magic __get()
cookie ( mixed $index = NULL, boolean $xss_clean = NULL ) : mixed Fetch an item from the COOKIE array
get ( mixed $index = NULL, boolean $xss_clean = NULL ) : mixed Fetch an item from the GET array
get_post ( string $index, boolean $xss_clean = NULL ) : mixed Fetch an item from GET data with fallback to POST
get_request_header ( string $index, boolean $xss_clean = FALSE ) : string | null Get Request Header
input_stream ( string $index = NULL, boolean $xss_clean = NULL ) : mixed Fetch an item from the php://input stream
ip_address ( ) : string Fetch the IP Address
is_ajax_request ( ) : boolean Is AJAX request?
is_cli_request ( ) : boolean Is CLI request?
method ( boolean $upper = FALSE ) : string Get Request Method
post ( mixed $index = NULL, boolean $xss_clean = NULL ) : mixed Fetch an item from the POST array
post_get ( string $index, boolean $xss_clean = NULL ) : mixed Fetch an item from POST data with fallback to GET
request_headers ( boolean $xss_clean = FALSE ) : array Request Headers
server ( mixed $index, boolean $xss_clean = NULL ) : mixed Fetch an item from the SERVER array
set_cookie ( string | mixed[] $name, string $value = '', integer $expire = '', string $domain = '', string $path = '/', string $prefix = '', boolean $secure = FALSE, boolean $httponly = FALSE ) : void Set cookie
user_agent ( $xss_clean = NULL ) : string | null Fetch User Agent string
valid_ip ( string $ip, string $which = '' ) : boolean Validate IP Address

Защищенные методы

Метод Описание
_clean_input_data ( string | string[] $str ) : string Clean Input Data
_clean_input_keys ( string $str, boolean $fatal = TRUE ) : string | boolean Clean Keys
_fetch_from_array ( &$array, mixed $index = NULL, boolean $xss_clean = NULL ) : mixed Fetch from array
_sanitize_globals ( ) : void Sanitize Globals

Описание методов

__construct() публичный Метод

Determines whether to globally enable the XSS processing and whether to allow the $_GET array.
public __construct ( ) : void
Результат void

__get() публичный Метод

Allows read access to protected properties
public __get ( string $name ) : mixed
$name string
Результат mixed

_clean_input_data() защищенный Метод

Internal method that aids in escaping data and standardizing newline characters to PHP_EOL.
protected _clean_input_data ( string | string[] $str ) : string
$str string | string[] Input string(s)
Результат string

_clean_input_keys() защищенный Метод

Internal method that helps to prevent malicious users from trying to exploit keys we make sure that keys are only named with alpha-numeric text and a few other items.
protected _clean_input_keys ( string $str, boolean $fatal = TRUE ) : string | boolean
$str string Input string
$fatal boolean Whether to terminate script exection or to return FALSE if an invalid key is encountered
Результат string | boolean

_fetch_from_array() защищенный Метод

Internal method used to retrieve values from global arrays.
protected _fetch_from_array ( &$array, mixed $index = NULL, boolean $xss_clean = NULL ) : mixed
$index mixed Index for item to be fetched from $array
$xss_clean boolean Whether to apply XSS filtering
Результат mixed

_sanitize_globals() защищенный Метод

Internal method serving for the following purposes: - Unsets $_GET data, if query strings are not enabled - Cleans POST, COOKIE and SERVER data - Standardizes newline characters to PHP_EOL
protected _sanitize_globals ( ) : void
Результат void

get() публичный Метод

Fetch an item from the GET array
public get ( mixed $index = NULL, boolean $xss_clean = NULL ) : mixed
$index mixed Index for item to be fetched from $_GET
$xss_clean boolean Whether to apply XSS filtering
Результат mixed

get_post() публичный Метод

Fetch an item from GET data with fallback to POST
public get_post ( string $index, boolean $xss_clean = NULL ) : mixed
$index string Index for item to be fetched from $_GET or $_POST
$xss_clean boolean Whether to apply XSS filtering
Результат mixed

get_request_header() публичный Метод

Returns the value of a single member of the headers class member
public get_request_header ( string $index, boolean $xss_clean = FALSE ) : string | null
$index string Header name
$xss_clean boolean Whether to apply XSS filtering
Результат string | null The requested header on success or NULL on failure modified by ci-phpunit-test

input_stream() публичный Метод

Useful when you need to access PUT, DELETE or PATCH request data.
public input_stream ( string $index = NULL, boolean $xss_clean = NULL ) : mixed
$index string Index for item to be fetched
$xss_clean boolean Whether to apply XSS filtering
Результат mixed

ip_address() публичный Метод

Determines and validates the visitor's IP address.
public ip_address ( ) : string
Результат string IP address

is_ajax_request() публичный Метод

Test to see if a request contains the HTTP_X_REQUESTED_WITH header.
public is_ajax_request ( ) : boolean
Результат boolean

is_cli_request() публичный Метод

Test to see if a request was made from the command line.
Устаревший: 3.0.0 Use is_cli() instead
public is_cli_request ( ) : boolean
Результат boolean

method() публичный Метод

Return the request method
public method ( boolean $upper = FALSE ) : string
$upper boolean Whether to return in upper or lower case (default: FALSE)
Результат string

post() публичный Метод

Fetch an item from the POST array
public post ( mixed $index = NULL, boolean $xss_clean = NULL ) : mixed
$index mixed Index for item to be fetched from $_POST
$xss_clean boolean Whether to apply XSS filtering
Результат mixed

post_get() публичный Метод

Fetch an item from POST data with fallback to GET
public post_get ( string $index, boolean $xss_clean = NULL ) : mixed
$index string Index for item to be fetched from $_POST or $_GET
$xss_clean boolean Whether to apply XSS filtering
Результат mixed

request_headers() публичный Метод

Request Headers
public request_headers ( boolean $xss_clean = FALSE ) : array
$xss_clean boolean Whether to apply XSS filtering
Результат array

server() публичный Метод

Fetch an item from the SERVER array
public server ( mixed $index, boolean $xss_clean = NULL ) : mixed
$index mixed Index for item to be fetched from $_SERVER
$xss_clean boolean Whether to apply XSS filtering
Результат mixed

user_agent() публичный Метод

Fetch User Agent string
public user_agent ( $xss_clean = NULL ) : string | null
Результат string | null User Agent string or NULL if it doesn't exist

valid_ip() публичный Метод

Validate IP Address
public valid_ip ( string $ip, string $which = '' ) : boolean
$ip string IP address
$which string IP protocol: 'ipv4' or 'ipv6'
Результат boolean

Описание свойств

$_allow_get_array защищенное свойство

If set to FALSE, then $_GET will be set to an empty array.
protected bool $_allow_get_array
Результат boolean

$_enable_csrf защищенное свойство

Enables a CSRF cookie token to be set. Set automatically based on config setting.
protected bool $_enable_csrf
Результат boolean

$_enable_xss защищенное свойство

Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered. Set automatically based on config setting.
protected bool $_enable_xss
Результат boolean

$_input_stream защищенное свойство

Parsed from php://input at runtime
См. также: CI_Input::input_stream()
protected array $_input_stream
Результат array

$_raw_input_stream защищенное свойство

Holds a cache of php://input contents
protected string $_raw_input_stream
Результат string

$_standardize_newlines защищенное свойство

If set to TRUE, then newlines are standardized.
protected bool $_standardize_newlines
Результат boolean

$headers защищенное свойство

List of all HTTP request headers
protected array $headers
Результат array

$ip_address защищенное свойство

IP address of the current user
protected string $ip_address
Результат string

$security защищенное свойство

protected $security

$uni защищенное свойство

protected $uni