-
Notifications
You must be signed in to change notification settings - Fork 0
CI_Input
Input Class
Pre-processes global input data for security
- Class name: CI_Input
- Namespace:
protected string $ip_address = FALSE
IP address of the current user
- Visibility: protected
protected boolean $_allow_get_array = TRUE
Allow GET array flag
If set to FALSE, then $_GET will be set to an empty array.
- Visibility: protected
protected boolean $_standardize_newlines
Standardize new lines flag
If set to TRUE, then newlines are standardized.
- Visibility: protected
protected boolean $_enable_xss = FALSE
Enable XSS flag
Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered. Set automatically based on config setting.
- Visibility: protected
protected boolean $_enable_csrf = FALSE
Enable CSRF flag
Enables a CSRF cookie token to be set. Set automatically based on config setting.
- Visibility: protected
protected array $headers = array()
List of all HTTP request headers
- Visibility: protected
protected string $_raw_input_stream
Raw input stream data
Holds a cache of php://input contents
- Visibility: protected
protected array $_input_stream
Parsed input stream data
Parsed from php://input at runtime
- Visibility: protected
protected mixed $security
- Visibility: protected
protected mixed $uni
- Visibility: protected
void CI_Input::__construct()
Class constructor
Determines whether to globally enable the XSS processing and whether to allow the $_GET array.
- Visibility: public
mixed CI_Input::_fetch_from_array($array, mixed $index, boolean $xss_clean)
Fetch from array
Internal method used to retrieve values from global arrays.
- Visibility: protected
- $array mixed
- $index mixed - <p>Index for item to be fetched from $array</p>
- $xss_clean boolean - <p>Whether to apply XSS filtering</p>
mixed CI_Input::get(mixed $index, boolean $xss_clean)
Fetch an item from the GET array
- Visibility: public
- $index mixed - <p>Index for item to be fetched from $_GET</p>
- $xss_clean boolean - <p>Whether to apply XSS filtering</p>
mixed CI_Input::post(mixed $index, boolean $xss_clean)
Fetch an item from the POST array
- Visibility: public
- $index mixed - <p>Index for item to be fetched from $_POST</p>
- $xss_clean boolean - <p>Whether to apply XSS filtering</p>
mixed CI_Input::post_get(string $index, boolean $xss_clean)
Fetch an item from POST data with fallback to GET
- Visibility: public
- $index string - <p>Index for item to be fetched from $_POST or $_GET</p>
- $xss_clean boolean - <p>Whether to apply XSS filtering</p>
mixed CI_Input::get_post(string $index, boolean $xss_clean)
Fetch an item from GET data with fallback to POST
- Visibility: public
- $index string - <p>Index for item to be fetched from $_GET or $_POST</p>
- $xss_clean boolean - <p>Whether to apply XSS filtering</p>
mixed CI_Input::cookie(mixed $index, boolean $xss_clean)
Fetch an item from the COOKIE array
- Visibility: public
- $index mixed - <p>Index for item to be fetched from $_COOKIE</p>
- $xss_clean boolean - <p>Whether to apply XSS filtering</p>
mixed CI_Input::server(mixed $index, boolean $xss_clean)
Fetch an item from the SERVER array
- Visibility: public
- $index mixed - <p>Index for item to be fetched from $_SERVER</p>
- $xss_clean boolean - <p>Whether to apply XSS filtering</p>
mixed CI_Input::input_stream(string $index, boolean $xss_clean)
Fetch an item from the php://input stream
Useful when you need to access PUT, DELETE or PATCH request data.
- Visibility: public
- $index string - <p>Index for item to be fetched</p>
- $xss_clean boolean - <p>Whether to apply XSS filtering</p>
void CI_Input::set_cookie(string|array<mixed,mixed> $name, string $value, integer $expire, string $domain, string $path, string $prefix, boolean $secure, boolean $httponly)
Set cookie
Accepts an arbitrary number of parameters (up to 7) or an associative array in the first parameter containing all the values.
- Visibility: public
- $name string|array<mixed,mixed> - <p>Cookie name or an array containing parameters</p>
- $value string - <p>Cookie value</p>
- $expire integer - <p>Cookie expiration time in seconds</p>
- $domain string - <p>Cookie domain (e.g.: '.yourdomain.com')</p>
- $path string - <p>Cookie path (default: '/')</p>
- $prefix string - <p>Cookie name prefix</p>
- $secure boolean - <p>Whether to only transfer cookies via SSL</p>
- $httponly boolean - <p>Whether to only makes the cookie accessible via HTTP (no javascript)</p>
string CI_Input::ip_address()
Fetch the IP Address
Determines and validates the visitor's IP address.
- Visibility: public
boolean CI_Input::valid_ip(string $ip, string $which)
Validate IP Address
- Visibility: public
- $ip string - <p>IP address</p>
- $which string - <p>IP protocol: 'ipv4' or 'ipv6'</p>
string|null CI_Input::user_agent($xss_clean)
Fetch User Agent string
- Visibility: public
- $xss_clean mixed
void CI_Input::_sanitize_globals()
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
- Visibility: protected
string CI_Input::_clean_input_data(string|array<mixed,string> $str)
Clean Input Data
Internal method that aids in escaping data and standardizing newline characters to PHP_EOL.
- Visibility: protected
- $str string|array<mixed,string> - <p>Input string(s)</p>
string|boolean CI_Input::_clean_input_keys(string $str, boolean $fatal)
Clean 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.
- Visibility: protected
- $str string - <p>Input string</p>
- $fatal boolean - <p>Whether to terminate script exection or to return FALSE if an invalid key is encountered</p>
array CI_Input::request_headers(boolean $xss_clean)
Request Headers
- Visibility: public
- $xss_clean boolean - <p>Whether to apply XSS filtering</p>
string|null CI_Input::get_request_header(string $index, boolean $xss_clean)
Get Request Header
Returns the value of a single member of the headers class member
- Visibility: public
- $index string - <p>Header name</p>
- $xss_clean boolean - <p>Whether to apply XSS filtering</p>
boolean CI_Input::is_ajax_request()
Is AJAX request?
Test to see if a request contains the HTTP_X_REQUESTED_WITH header.
- Visibility: public
boolean CI_Input::is_cli_request()
Is CLI request?
Test to see if a request was made from the command line.
- Visibility: public
string CI_Input::method(boolean $upper)
Get Request Method
Return the request method
- Visibility: public
- $upper boolean - <p>Whether to return in upper or lower case (default: FALSE)</p>
mixed CI_Input::__get(string $name)
Magic __get()
Allows read access to protected properties
- Visibility: public
- $name string