php防止sql注入之過濾分頁參數(shù)實例
更新時間:2014年11月03日 10:30:43 投稿:shichen2014
這篇文章主要介紹了php防止sql注入中過濾分頁參數(shù)的方法,實例展示了針對分頁參數(shù)的數(shù)值判斷問題,是非常具有實用價值的技巧,需要的朋友可以參考下
本文實例講述了php防止sql注入中過濾分頁參數(shù)的方法。分享給大家供大家參考。具體分析如下:
就網(wǎng)絡(luò)安全而言,在網(wǎng)絡(luò)上不要相信任何輸入信息,對于任何輸入信息我們都必須進行參數(shù)過濾。對此,我們先來看看下面的實例:
復(fù)制代碼 代碼如下:
$this->load->library ( 'pagination' );
$config ['base_url'] = site_url () . '/guest/show';
$config ['total_rows'] = $c;
$config ['per_page'] = $pernum = 15;
$config ['uri_segment'] = 3;
$config ['use_page_numbers'] = TRUE;
$config ['first_link'] = '第一頁';
$config ['last_link'] = '最后一頁';
$config ['num_links'] = 5;
$this->pagination->initialize ( $config );
if (! $this->uri->segment ( 3 )) {
$currentnum = 0;
} else {
$currentnum = is_numeric($this->uri->segment ( 3 ))?(intval($this->uri->segment ( 3 ) - 1)) * $pernum:0;
}
$current_page=is_numeric($this->uri->segment ( 3 ))?intval($this->uri->segment ( 3 )):1;
if($current_page){
$data ['title'] = '第'.$current_page.'頁-留言本-防SQL注入測試';
}
else{
$data ['title'] = '留言本-防SQL注入測試';
}
$data ['liuyan'] = $this->ly->getLy ( $pernum, $currentnum );
$config ['base_url'] = site_url () . '/guest/show';
$config ['total_rows'] = $c;
$config ['per_page'] = $pernum = 15;
$config ['uri_segment'] = 3;
$config ['use_page_numbers'] = TRUE;
$config ['first_link'] = '第一頁';
$config ['last_link'] = '最后一頁';
$config ['num_links'] = 5;
$this->pagination->initialize ( $config );
if (! $this->uri->segment ( 3 )) {
$currentnum = 0;
} else {
$currentnum = is_numeric($this->uri->segment ( 3 ))?(intval($this->uri->segment ( 3 ) - 1)) * $pernum:0;
}
$current_page=is_numeric($this->uri->segment ( 3 ))?intval($this->uri->segment ( 3 )):1;
if($current_page){
$data ['title'] = '第'.$current_page.'頁-留言本-防SQL注入測試';
}
else{
$data ['title'] = '留言本-防SQL注入測試';
}
$data ['liuyan'] = $this->ly->getLy ( $pernum, $currentnum );
其中:
復(fù)制代碼 代碼如下:
$current_page=is_numeric($this->uri->segment ( 3 ))?intval($this->uri->segment ( 3 )):1;
$currentnum = is_numeric($this->uri->segment ( 3 ))?(intval($this->uri->segment ( 3 ) - 1)) * $pernum;
$currentnum = is_numeric($this->uri->segment ( 3 ))?(intval($this->uri->segment ( 3 ) - 1)) * $pernum;
這兩句判斷了參數(shù)是否為數(shù)字。防止非法字符輸入。
希望本文所述對大家的PHP程序設(shè)計有所幫助。
您可能感興趣的文章:
- php中addslashes函數(shù)與sql防注入
- php SQL防注入代碼集合
- php防止sql注入簡單分析
- PHP中防止SQL注入方法詳解
- php中$_GET與$_POST過濾sql注入的方法
- PHP中怎樣防止SQL注入分析
- PHP防范SQL注入的具體方法詳解(測試通過)
- PHP開發(fā)中常見的安全問題詳解和解決方法(如Sql注入、CSRF、Xss、CC等)
- php中sql注入漏洞示例 sql注入漏洞修復(fù)
- php防止sql注入示例分析和幾種常見攻擊正則表達式
- php防止sql注入代碼實例
- PHP MYSQL注入攻擊需要預(yù)防7個要點
- php防止SQL注入詳解及防范
- 淺析php過濾html字符串,防止SQL注入的方法
- php簡單實現(xiàn)sql防注入的方法
相關(guān)文章
PHP+jquery+ajax實現(xiàn)即時聊天功能實例
這篇文章主要介紹了PHP+jquery+ajax實現(xiàn)即時聊天功能的方法,實例分析了php聊天功能的信息無刷新提交方法,以及信息發(fā)送處理等功能,具有一定的參考借鑒價值,需要的朋友可以參考下2014-12-12
php mysql like 實現(xiàn)多關(guān)鍵詞搜索的方法
下面小編就為大家?guī)硪黄猵hp mysql like 實現(xiàn)多關(guān)鍵詞搜索的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-10-10
PHP5.6新增加的可變函數(shù)參數(shù)用法分析
這篇文章主要介紹了PHP5.6新增加的可變函數(shù)參數(shù)用法,結(jié)合具體實例形式分析了PHP5.6可變函數(shù)參數(shù)的具體用法與相關(guān)注意事項,需要的朋友可以參考下2017-08-08
PHP+MySQL之Insert Into數(shù)據(jù)插入用法分析
這篇文章主要介紹了PHP+MySQL之Insert Into數(shù)據(jù)插入用法,實例分析了php+mysql基于Insert Into語句實現(xiàn)數(shù)據(jù)插入的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-09-09
jQuery+PHP+ajax實現(xiàn)微博加載更多內(nèi)容列表功能
這篇文章主要介紹了jQuery+PHP+ajax實現(xiàn)微博加載更多內(nèi)容列表功能,對于微博開發(fā)來說非常實用,需要的朋友可以參考下2014-06-06

