English
 电子信箱
 加入收藏

  威盾防火墙 >> 支持与下载 >> 技术文章 >> php防止sql注入之过滤分页参数实例

 

php防止sql注入之过滤分页参数实例

威盾防火墙 2014-11-14

 
这篇文章主要介绍了php防止sql注入中过滤分页参数的方法,实例展示了针对分页参数的数值判断问题,是非常具有实用价值的技巧,需要的朋友可以参考下

本文实例讲述了php防止sql注入中过滤分页参数的方法。分享给大家供大家参考。具体分析如下:

就网络安全而言,在网络上不要相信任何输入信息,对于任何输入信息我们都必须进行参数过滤。对此,我们先来看看下面的实例:

复制代码代码如下:
$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 );

其中:
复制代码代码如下:
$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;


相关内容: 最新内容:
“SQL2000数据库”运行在普通用户下所需的权限[2014-11-12]
Windows XP中配置PHP+IIS环境+mysql[2014-11-11]
PHP中防止SQL注入实现代码[2014-11-06]
黑客如何入侵装有SQL数据库的电脑主机[2014-11-06]
黑客教你SQL注入Access导出WebShell的方法[2014-11-06]
SQL注入攻击防护[2014-11-06]
对于防盗链机制的思考[2014-11-14]
加密网站地址——从根本解决盗连[2014-11-14]
天衣无缝:IIS与PHP水火也相容[2014-11-13]
Windows 2008 64位 实现iis7 +tomcat6的负载均衡[2014-11-13]
win2008 IIS7.5防盗链配置方法[2014-11-13]
前江洋大盗微博教人防盗[2014-11-13]