当前位置:首页 > PHP教程 > php函数 > 列表

php用户自定过滤非法sql注入字符串函数

发布:smiling 来源: PHP粉丝网  添加日期:2014-08-25 11:24:17 浏览: 评论:0 
  1. function uc_addslashes($string, $force = 0, $strip = false) { 
  2.  !defined('magic_quotes_gpc') && define('magic_quotes_gpc', get_magic_quotes_gpc()); 
  3.  if(!magic_quotes_gpc || $force) { 
  4.   if(is_array($string)) { 
  5.    foreach($string as $key => $val) { 
  6.     $string[$key] = uc_addslashes($val, $force, $strip); 
  7.    } 
  8.   } else { 
  9.    $string = addslashes($strip ? strips教程lashes($string) : $string); 
  10.   } 
  11.  } 
  12.  return $string; 
  13. } 
  14.  
  15. if(!function_exists('daddslashes')) { 
  16.  function daddslashes($string, $force = 0) { 
  17.   return uc_addslashes($string, $force); 
  18.  } 
  19. } 
  20.  
  21. //php 过滤函数应用实例phpfensi.com 
  22.  
  23. $get = $_get; 
  24. $g = uc_addslashes($get, $force = 0, $strip = false); 
  25.  
  26. //过滤post提交数据 
  27.  
  28. $post =  $_post; 
  29. $p = uc_addslashes($post, $force = 0, $strip = false); 

Tags: php字符串 php非法sql注入

分享到: