php防止sql注入之過(guò)濾分頁(yè)參數(shù)實(shí)例
本文實(shí)例講述了php防止sql注入中過(guò)濾分頁(yè)參數(shù)的方法。分享給大家供大家參考。具體分析如下:
就網(wǎng)絡(luò)安全而言,在網(wǎng)絡(luò)上不要相信任何輸入信息,對(duì)于任何輸入信息我們都必須進(jìn)行參數(shù)過(guò)濾。對(duì)此,我們先來(lái)看看下面的實(shí)例:
$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'] = '第一頁(yè)';
$config ['last_link'] = '最后一頁(yè)';
$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.'頁(yè)-留言本-防SQL注入測(cè)試';
}
else{
$data ['title'] = '留言本-防SQL注入測(cè)試';
}
$data ['liuyan'] = $this->ly->getLy ( $pernum, $currentnum );
其中:
$currentnum = is_numeric($this->uri->segment ( 3 ))?(intval($this->uri->segment ( 3 ) - 1)) * $pernum;
這兩句判斷了參數(shù)是否為數(shù)字。防止非法字符輸入。
希望本文所述對(duì)大家的PHP程序設(shè)計(jì)有所幫助。
- php中addslashes函數(shù)與sql防注入
- php SQL防注入代碼集合
- php防止sql注入簡(jiǎn)單分析
- PHP中防止SQL注入方法詳解
- php中$_GET與$_POST過(guò)濾sql注入的方法
- PHP中怎樣防止SQL注入分析
- PHP防范SQL注入的具體方法詳解(測(cè)試通過(guò))
- PHP開發(fā)中常見的安全問(wèn)題詳解和解決方法(如Sql注入、CSRF、Xss、CC等)
- php中sql注入漏洞示例 sql注入漏洞修復(fù)
- php防止sql注入示例分析和幾種常見攻擊正則表達(dá)式
- php防止sql注入代碼實(shí)例
- PHP MYSQL注入攻擊需要預(yù)防7個(gè)要點(diǎn)
- php防止SQL注入詳解及防范
- 淺析php過(guò)濾html字符串,防止SQL注入的方法
- php簡(jiǎn)單實(shí)現(xiàn)sql防注入的方法
相關(guān)文章
php 強(qiáng)制下載文件實(shí)現(xiàn)代碼
php 強(qiáng)制下載文件實(shí)現(xiàn)代碼。需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2013-10-10
PHPMailer的主要功能特點(diǎn)和簡(jiǎn)單使用說(shuō)明
本篇文章主要是對(duì)PHPMailer的主要功能特點(diǎn)和簡(jiǎn)單使用說(shuō)明進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-02-02
php定義一個(gè)參數(shù)帶有默認(rèn)值的函數(shù)實(shí)例分析
這篇文章主要介紹了php定義一個(gè)參數(shù)帶有默認(rèn)值的函數(shù),實(shí)例分析了php參數(shù)帶有默認(rèn)值的函數(shù)使用技巧,需要的朋友可以參考下2015-03-03

