您的位置 首页 php

PHP编程如何去做防注入

各位朋友大家下午好!

今天给大家分享的是 PHP编程如何去做防注入!

这里就需要用到 一款 php防注入类库!

由于源码比较长,需要的可以私聊小编哦!

废话不多说,上源码!

<?php

/**

* 参数处理类

* @author JasonWei

*/

class Params

{

public $get = array();

public $post = array();

function __construct()

{

if (!emptyempty($_GET)) {

foreach ($_GET as $key => $val) {

if (is_numeric($val)) {

$this->get[$key] = $this->getInt($val);

} else {

$this->get[$key] = $this->getStr($val);

}

}

}

if (!emptyempty($_POST)) {

foreach ($_POST as $key => $val) {

if (is_numeric($val)) {

$this->post[$key] = $this->getInt($val);

} else {

$this->post[$key] = $this->getStr($val);

}

}

}

}

public function getInt($ number )

{

return intval($number);

}

public function getStr($string)

{

if (!get_magic_quotes_gpc()) {

$string = addslashes($string);

}

return $string;

}

public function checkInject($string)

{

return eregi(‘select|insert|update|delete|/*|*|../|./|union|into|load_file|outfile’, $string);

}

public function verifyId($id = null)

{

if (!$id || $this->checkInject($id) || !is_numeric($id)) {

$id = false;

} else {

$id = intval($id);

}//开源代码phpfensi. com

return $id;

}

}

?>

文章来源:智云一二三科技

文章标题:PHP编程如何去做防注入

文章地址:https://www.zhihuclub.com/79378.shtml

关于作者: 智云科技

热门文章

网站地图