您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

两段简单的PHP防SQL注入代码_PHP教程

2024/6/17 20:26:36发布26次查看
介绍两种方法吧,首先请把以下代码保存为safe.php放在网站根目录下,然后在每个php文件前加include(/safe.php);即可:
php防注入代码方法一:
$value) { if (eregi($value,$strfiltrate)) { return true; } } return false;}//合并$_post 和 $_getif(function_exists(array_merge)){ $arrpostandget=array_merge($http_post_vars,$http_get_vars);}else{ foreach($http_post_vars as $key=>$value) { $arrpostandget[]=$value; } foreach($http_get_vars as $key=>$value) { $arrpostandget[]=$value; }}//验证开始foreach($arrpostandget as $key=>$value){ if (funstringexist($value,$arrfiltrate)) { echo ; if (emptyempty($strgourl)) { echo ; } else { echo ; } exit; }}?>
php防注入代码方法二:
$get_var){if (is_numeric($get_var)) {$get[strtolower($get_key)] = get_int($get_var);} else {$get[strtolower($get_key)] = get_str($get_var);}}/* 过滤所有post过来的变量 */foreach ($_post as $post_key=>$post_var){ if (is_numeric($post_var)) { $post[strtolower($post_key)] = get_int($post_var); } else { $post[strtolower($post_key)] = get_str($post_var); }}/* 过滤函数 *///整型过滤函数function get_int($number){ return intval($number);}//字符串型过滤函数function get_str($string){ if (!get_magic_quotes_gpc()) { return addslashes($string); } return $string;}?>
http://www.bkjia.com/phpjc/752508.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/752508.htmltecharticle介绍两种方法吧,首先请把以下代码保存为safe.php放在网站根目录下,然后在每个php文件前加include(/safe.php);即可: php防注入代码方法一:...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product