国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

directory search
Array Array Helper Benchmarking Benchmarking Class Caching Caching Driver Calendaring Calendaring Class CAPTCHA CAPTCHA Helper Config Config Class Cookie Cookie Helper Database Connecting to your Database Custom Function Calls Database Caching Class Database Configuration Database Forge Class Database Metadata Database Quick Start: Example Code Database Reference Database Utility Class DB Driver Reference Generating Query Results Queries Query Builder Class Query Helper Methods Transactions Date Date Helper Directory Directory Helper Download Download Helper Email Email Class Email Helper Encrypt Encrypt Class Encryption Encryption Library File File Helper File Uploading File Uploading Class Form Form Helper Form Validation Form Validation FTP FTP Class Functions compatibility_functions common_functions HTML HTML Helper HTML Table HTML Table Class Image Manipulation Image Manipulation Class Inflector Inflector Helper Input Input Class Javascript Javascript Class Language Language Class Language Helper Loader Loader Class Migrations Migrations Class Number Number Helper Output Output Class Pagination Pagination Class Path Path Helper Security Security Class Security Helper Session Session Library Shopping Cart Shopping Cart Class Smiley Smiley Helper String String Helper Template Parser Template Parser Class Text Text Helper Trackback Trackback Class Typography Typography Class Typography Helper Unit Testing Unit Testing Class URI URL User Agent XML XML-RPC and XML-RPC Server Zip Encoding Zip Encoding Class XML-RPC and XML-RPC Server Classes XML Helper User Agent Class URL Helper URI Class
characters

輸入類有兩個(gè)目的:

  1. 它預(yù)處理全局輸入數(shù)據(jù)以確保安全。

  2. 它提供了一些輔助方法來(lái)獲取輸入數(shù)據(jù)并對(duì)其進(jìn)行預(yù)處理。

注意

該類由系統(tǒng)自動(dòng)初始化,因此不需要手動(dòng)執(zhí)行。

  • 輸入過(guò)濾

    • 安全篩選

    • XSS過(guò)濾

  • 訪問(wèn)表單數(shù)據(jù)

    • 使用POST,GET,COOKIE或SERVER數(shù)據(jù)

    • 使用php://輸入流

  • 類參考

輸入過(guò)濾

安全篩選

當(dāng)調(diào)用新的控制器時(shí),將自動(dòng)調(diào)用安全過(guò)濾方法。它執(zhí)行以下操作:

  • 如果$config['allow_get_array']為FALSE(默認(rèn)值為T(mén)RUE),則會(huì)銷毀全局GET數(shù)組。

  • 銷毀register_globals處于打開(kāi)狀態(tài)的所有全局變量。

  • 過(guò)濾GET / POST / COOKIE數(shù)組鍵,僅允許字母數(shù)字(和其他幾個(gè)字符)。

  • 提供XSS(跨站腳本攻擊)過(guò)濾。這可以在全球啟用,或根據(jù)要求啟用。

  • 將換行符標(biāo)準(zhǔn)化為PHP_EOL(在基于UNIX的操作系統(tǒng)中為\ n,在Windows下為\ r \ n)。這是可配置的。

XSS過(guò)濾

Input類可以自動(dòng)過(guò)濾輸入以防止跨站腳本攻擊。如果您希望篩選器在每次遇到POST或COOKIE數(shù)據(jù)時(shí)自動(dòng)運(yùn)行,您可以通過(guò)打開(kāi)application / config / config.php文件并設(shè)置它來(lái)啟用它:

$config['global_xss_filtering'] = TRUE;

有關(guān)在您的應(yīng)用程序中使用XSS Filtering的信息,請(qǐng)參閱Security類文檔。

重要

'global_xss_filtering'設(shè)置為DEPRECATED,僅用于向后兼容的目的。應(yīng)該在輸出上執(zhí)行XSS轉(zhuǎn)義,而不是輸入

訪問(wèn)表單數(shù)據(jù)

使用POST,GET,COOKIE或SERVER數(shù)據(jù)

CodeIgniter帶有助手方法,可以讓你獲取POST,GET,COOKIE或SERVER項(xiàng)目。使用提供的方法而不是直接獲取項(xiàng)目的主要優(yōu)點(diǎn)$_POST['something']是方法將檢查項(xiàng)目是否設(shè)置,如果不是,則返回NULL。這使您可以方便地使用數(shù)據(jù),而不必先測(cè)試項(xiàng)目是否存在。換句話說(shuō),通常你可能會(huì)這樣做:

$something = isset($_POST['something']) ? $_POST['something'] : NULL;

使用CodeIgniter的內(nèi)置方法,您可以簡(jiǎn)單地執(zhí)行此操作:

$something = $this->input->post('something');

主要方法是:

  • $this->input->post()

  • $this->input->get()

  • $this->input->cookie()

  • $this->input->server()

Using the php://input stream

如果你想利用PUT,DELETE,PATCH或其他奇特的請(qǐng)求方法,它們只能通過(guò)一個(gè)特殊的輸入流來(lái)訪問(wèn),它只能被讀取一次。這不像從$_POST數(shù)組讀取那樣簡(jiǎn)單,因?yàn)樗鼤?huì)一直存在,并且您可以嘗試訪問(wèn)多個(gè)變量,而不必關(guān)心在所有POST數(shù)據(jù)中只能有一個(gè)鏡頭。

CodeIgniter會(huì)為你處理這個(gè)問(wèn)題,你可以隨時(shí)從php://輸入流中讀取數(shù)據(jù),只需使用$raw_input_stream屬性:

$this->input->raw_input_stream;

另外,如果輸入流像$ _POST一樣進(jìn)行表單編碼,則可以通過(guò)調(diào)用input_stream()方法來(lái)訪問(wèn)其值:

$this->input->input_stream('key');

類似于其他方法,如get()post(),如果未找到所請(qǐng)求的數(shù)據(jù),它會(huì)返回NULL,你也可以決定是否通過(guò)運(yùn)行數(shù)據(jù)xss_clean()通過(guò)傳遞一個(gè)布爾值作為第二個(gè)參數(shù):

$this->input->input_stream('key', TRUE); // XSS Clean$this->input->input_stream('key', FALSE); // No XSS filter

注意

您可以利用method()以了解您是否正在讀取PUT,DELETE或PATCH數(shù)據(jù)。

類參考

class CI_Input$raw_input_stream

只讀屬性將返回php://輸入數(shù)據(jù)原樣。

該屬性可以多次讀取。

post([$index = NULL[, $xss_clean = NULL]])

參數(shù):

$ index(mixed) -  POST參數(shù)名稱$ xss_clean(bool) - 是否應(yīng)用XSS過(guò)濾

返回:

$ _POST如果沒(méi)有提供參數(shù),否則POST值如果找到,否則返回NULL

返回類型:

  • $ indexmixed) -  POST參數(shù)名稱

  • $ xss_cleanbool) - 是否應(yīng)用XSS過(guò)濾

Returns:  $\_POST if no parameters supplied, otherwise the POST value if found or NULL if not
Return type:  mixed
第一個(gè)參數(shù)將包含您正在查找的POST項(xiàng)目的名稱:

$this->input->post('some_data');

如果您嘗試檢索的項(xiàng)目不存在,則該方法返回NULL。

第二個(gè)可選參數(shù)允許您通過(guò)XSS過(guò)濾器運(yùn)行數(shù)據(jù)。通過(guò)將第二個(gè)參數(shù)設(shè)置為布爾TRUE或?qū)⑵湓O(shè)置$config['global_xss_filtering']為T(mén)RUE 來(lái)啟用它。

$this->input->post('some_data', TRUE);

要返回一個(gè)沒(méi)有任何參數(shù)的所有POST項(xiàng)目調(diào)用的數(shù)組。

要返回所有POST項(xiàng)目并將它們傳遞給XSS篩選器,請(qǐng)將第一個(gè)參數(shù)設(shè)置為NULL,同時(shí)將第二個(gè)參數(shù)設(shè)置為布爾值TRUE。

$this->input->post(NULL, TRUE); // returns all POST items with XSS filter $this->input->post(NULL, FALSE); // returns all POST items without XSS filter

要返回多個(gè)POST參數(shù)的數(shù)組,請(qǐng)將所有必需的鍵作為數(shù)組傳遞。

$this->input->post(array('field1', 'field2'));

在這里應(yīng)用相同的規(guī)則,為了檢索啟用了XSS過(guò)濾的參數(shù),將第二個(gè)參數(shù)設(shè)置為布爾TRUE。

$this->input->post(array('field1', 'field2'), TRUE);

get([$index = NULL[, $xss_clean = NULL]])

參數(shù):

$ index(mixed) -  GET參數(shù)名稱$ xss_clean(bool) - 是否應(yīng)用XSS過(guò)濾

返回:

$ _GET如果沒(méi)有提供參數(shù),否則GET值如果找到,否則返回NULL

返回類型:

  • $ indexmixed) -  GET參數(shù)名稱

  • $ xss_cleanbool) - 是否應(yīng)用XSS過(guò)濾

Returns:  $\_GET if no parameters supplied, otherwise the GET value if found or NULL if not
Return type:  mixed
This method is identical to `post()`, only it fetches GET data.

$this->input->get('some_data', TRUE);

不帶任何參數(shù)返回所有GET項(xiàng)目數(shù)組的調(diào)用。

要返回所有GET項(xiàng)并將它們傳遞給XSS篩選器,請(qǐng)將第一個(gè)參數(shù)設(shè)置為NULL,同時(shí)將第二個(gè)參數(shù)設(shè)置為布爾值TRUE。

$ this-> input-> get(NULL,TRUE); //返回帶有XSS過(guò)濾器的所有GET項(xiàng)目$ this-> input-> get(NULL,F(xiàn)ALSE); //返回所有沒(méi)有XSS過(guò)濾的GET項(xiàng)目

要返回多個(gè)GET參數(shù)的數(shù)組,請(qǐng)將所有必需的鍵作為數(shù)組傳遞。

$this->input->get(array('field1', 'field2'));

在這里應(yīng)用相同的規(guī)則,為了檢索啟用了XSS過(guò)濾的參數(shù),將第二個(gè)參數(shù)設(shè)置為布爾TRUE。

$this->input->get(array('field1', 'field2'), TRUE);

post_get($index[, $xss_clean = NULL])

參數(shù):

$ index(string) -  POST / GET參數(shù)名稱$ xss_clean(bool) - 是否應(yīng)用XSS過(guò)濾

返回:

如果找到POST / GET值,則返回NULL

返回類型:

  • $ indexstring) -  POST / GET參數(shù)名稱

  • $ xss_cleanbool) - 是否應(yīng)用XSS過(guò)濾

Returns:  POST/GET value if found, NULL if not
Return type:  mixed
This method works pretty much the same way as `post()` and `get()`, only combined. It will search through both POST and GET streams for data, looking in POST first, and then in GET:

$this->input->post_get('some_data', TRUE);

get_post($index[, $xss_clean = NULL])

參數(shù):

$ index(string) -  GET / POST參數(shù)名稱$ xss_clean(bool) - 是否應(yīng)用XSS過(guò)濾

返回:

如果找到GET / POST值,則返回NULL

返回類型:

  • $ indexstring) -  GET / POST參數(shù)名稱

  • $ xss_cleanbool) - 是否應(yīng)用XSS過(guò)濾

Returns:  GET/POST value if found, NULL if not
Return type:  mixed
This method works the same way as `post_get()` only it looks for GET data first.

$this->input->get_post(‘some_data’, TRUE);  Note

此方法用于post_get()表現(xiàn)得很像,但它的行為在CodeIgniter 3.0中發(fā)生了變化。

cookie([$index = NULL[, $xss_clean = NULL]])

參數(shù):

$ index(混合) -  COOKIE名稱$ xss_clean(bool) - 是否應(yīng)用XSS過(guò)濾

返回:

如果沒(méi)有提供參數(shù),則返回$ _COOKIE,否則返回COOKIE值,否則返回NULL

返回類型:

  • $ index混合) -  COOKIE名稱

  • $ xss_cleanbool) - 是否應(yīng)用XSS過(guò)濾

Returns:  $\_COOKIE if no parameters supplied, otherwise the COOKIE value if found or NULL if not
Return type:  mixed
This method is identical to `post()` and `get()`, only it fetches cookie data:

$this->input->cookie('some_cookie'); $this->input->cookie('some_cookie, TRUE); // with XSS filter

要返回多個(gè)Cookie值的數(shù)組,請(qǐng)將所有必需的鍵作為數(shù)組傳遞。

$this->input->cookie(array('some_cookie', 'some_cookie2'));

注意

與Cookie幫助器函數(shù)不同get_cookie(),此方法不會(huì)預(yù)先配置您的配置$config['cookie_prefix']值。

server($index[, $xss_clean = NULL])

參數(shù):

$ index(mixed) - 值名稱$ xss_clean(bool) - 是否應(yīng)用XSS過(guò)濾

返回:

如果找到$ _SERVER項(xiàng)目值,則返回NULL

返回類型:

  • $ index混合) - 值名稱

  • $ xss_cleanbool) - 是否應(yīng)用XSS過(guò)濾

Returns:  $\_SERVER item value if found, NULL if not
Return type:  mixed
This method is identical to the `post()`, `get()` and `cookie()` methods, only it fetches server data (`$_SERVER`):

$this->input->server('some_data');

要返回多個(gè)$_SERVER值的數(shù)組,請(qǐng)將所有必需的鍵作為數(shù)組傳遞。

$this->input->server(array('SERVER_PROTOCOL', 'REQUEST_URI'));

input_stream([$index = NULL[, $xss_clean = NULL]])

參數(shù):

$ index(mixed) - 鍵名$ xss_clean(bool) - 是否應(yīng)用XSS過(guò)濾

返回:

輸入流數(shù)組,如果沒(méi)有提供參數(shù),否則指定的值如果找到,否則返回NULL

返回類型:

  • $ index混合) - 密鑰名稱

  • $ xss_cleanbool) - 是否應(yīng)用XSS過(guò)濾

Returns:  Input stream array if no parameters supplied, otherwise the specified value if found or NULL if not
Return type:  mixed
This method is identical to `get()`, `post()` and `cookie()`, only it fetches the _php://input_ stream data.

set_cookie($name = ''[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = NULL[, $httponly = NULL]]]]]]])

參數(shù):

$ name(字符串) -  Cookie值$ expire(int) -  Cookie過(guò)期時(shí)間(以秒為單位)$ domain(字符串) -  Cookie域$ path(字符串) -  Cookie路徑$ prefix (字符串) -  Cookie名稱前綴$ secure(bool) - 是否僅通過(guò)HTTPS傳輸cookie $ httponly(bool) - 是否僅允許HTTP請(qǐng)求訪問(wèn)Cookie(無(wú)JavaScript)

返回類型:

void

  • $ name混合) -  Cookie名稱或參數(shù)數(shù)組

  • $ value字符串) -  Cookie值

  • $ expireint) - 以秒為單位的Cookie過(guò)期時(shí)間

  • $域字符串) -  Cookie域

  • $ pathstring) -  Cookie路徑

  • $ prefix字符串) -  Cookie名稱前綴

  • $ securebool) - 是否僅通過(guò)HTTPS傳輸cookie

  • $ httponlybool) - 是否僅允許HTTP請(qǐng)求訪問(wèn)cookie(無(wú)JavaScript)

Return type:  void
Sets a cookie containing the values you specify. There are two ways to pass information to this method so that a cookie can be set: Array Method, and Discrete Parameters:

數(shù)組方法

使用這種方法,將關(guān)聯(lián)數(shù)組傳遞給第一個(gè)參數(shù):

$cookie = array(         'name'   => 'The Cookie Name',         'value'  => 'The Value',         'expire' => '86500',         'domain' => '.some-domain.com',         'path'   => '/',         'prefix' => 'myprefix_',         'secure' => TRUE );  $this->input->set_cookie($cookie);

筆記

只有名字和價(jià)值是必需的。要?jiǎng)h除cookie,將其設(shè)置為過(guò)期空白。

到期時(shí)間以為單位設(shè)置,并將添加到當(dāng)前時(shí)間。不要包含時(shí)間,而只需要從現(xiàn)在起您希望cookie有效的秒數(shù)。如果過(guò)期設(shè)置為零,則只有在瀏覽器處于打開(kāi)狀態(tài)時(shí),cookie才會(huì)持續(xù)。

無(wú)論網(wǎng)站的請(qǐng)求方式如何,對(duì)于站點(diǎn)級(jí)的Cookie,請(qǐng)將您的網(wǎng)址添加到以句點(diǎn)開(kāi)頭的網(wǎng),如下所示:.your-domain.com

由于該方法設(shè)置了根路徑,因此通常不需要該路徑。

只有當(dāng)您需要避免與服務(wù)器上其他名稱相同的cookie發(fā)生名稱沖突時(shí),才需要前綴。

僅Http安全標(biāo)志,省略時(shí),將默認(rèn)為您$config['cookie_httponly']$config['cookie_secure']設(shè)置。

離散參數(shù)

如果您愿意,可以通過(guò)使用各個(gè)參數(shù)傳遞數(shù)據(jù)來(lái)設(shè)置Cookie:

$ this-> input-> set_cookie($ name,$ value,$ expire,$ domain,$ path,$ prefix,$ secure);

ip_address()

返回:

訪問(wèn)者的IP地址或“0.0.0.0”,如果無(wú)效

返回類型:

valid_ip($ip[, $which = ''])

參數(shù):

$ ip(string) -  IP地址$ which(string) -  IP協(xié)議('ipv4'或'ipv6')

返回:

如果地址有效則為T(mén)RUE,否則為FALSE

返回類型:

布爾

  • $ ip字符串) -  IP地址

  • $ whichstring) -  IP協(xié)議('ipv4'或'ipv6')

Returns:  TRUE if the address is valid, FALSE if not
Return type:  bool
Takes an IP address as input and returns TRUE or FALSE (boolean) depending on whether it is valid or not.

注意

上面的$ this-> input-> ip_address()方法自動(dòng)驗(yàn)證IP地址。

if ( ! $this->input->valid_ip($ip)) {         echo 'Not Valid'; } else {         echo 'Valid'; }

接受可選的第二個(gè)字符串參數(shù)'ipv4'或'ipv6'來(lái)指定IP格式。這兩種格式的默認(rèn)檢查。

user_agent([$xss_clean = NULL])

返回:

用戶代理字符串,如果未設(shè)置,則為NULL

參數(shù):

$ xss_clean(bool) - 是否應(yīng)用XSS過(guò)濾

返回類型:

  • $ xss_cleanbool) - 是否應(yīng)用XSS過(guò)濾

Return type:  mixed
Returns the user agent string (web browser) being used by the current user, or NULL if it’s not available.

echo $this->input->user_agent();

有關(guān)從用戶代理字符串提取信息的方法,請(qǐng)參閱用戶代理類。

request_headers([$xss_clean = FALSE])

參數(shù):

$ xss_clean(bool) - 是否應(yīng)用XSS過(guò)濾

返回:

一組HTTP請(qǐng)求標(biāo)頭

返回類型:

排列

  • $ xss_cleanbool) - 是否應(yīng)用XSS過(guò)濾

Returns:  An array of HTTP request headers
Return type:  array
Returns an array of HTTP request headers. Useful if running in a non-Apache environment where [apache\_request\_headers()](https://php.net/apache_request_headers) will not be supported.

$headers = $this->input->request_headers();

get_request_header($index[, $xss_clean = FALSE])

參數(shù):

$ index(string) -  HTTP請(qǐng)求頭名稱$ xss_clean(bool) - 是否應(yīng)用XSS過(guò)濾

返回:

HTTP請(qǐng)求標(biāo)頭或NULL,如果未找到

返回類型:

  • $ indexstring) -  HTTP請(qǐng)求標(biāo)題名稱

  • $ xss_cleanbool) - 是否應(yīng)用XSS過(guò)濾

返回:HTTP請(qǐng)求標(biāo)頭或NULL,如果未找到
Return type:  string
Returns a single member of the request headers array or NULL if the searched header is not found.

$this->input->get_request_header('some-header', TRUE);

is_ajax_request()

返回:

如果它是Ajax請(qǐng)求則為T(mén)RUE,否則為FALSE

返回類型:

布爾

is_cli_request()

返回:

如果是CLI請(qǐng)求則為T(mén)RUE,否則為FALSE

返回類型:

布爾

method([$upper = FALSE])

參數(shù):

$ upper(bool) - 是否以大寫(xiě)或小寫(xiě)形式返回請(qǐng)求方法名稱

返回:

HTTP請(qǐng)求方法

返回類型:

  • $ upperbool) - 是否以大寫(xiě)或小寫(xiě)形式返回請(qǐng)求方法名稱

Returns:  HTTP request method
Return type:  string
Returns the `$_SERVER['REQUEST_METHOD']`, with the option to set it in uppercase or lowercase.

echo $this->input->method(TRUE); // Outputs: POST echo $this->input->method(FALSE); // Outputs: post echo $this->input->method(); // Outputs: post

Previous article: Next article: