PHP filters disabled characters before entering the database (PHP code function)

WBOY
Release: 2016-07-25 08:44:13
Original
790 people have browsed it
  1. //PHP filters disabled characters before entering the database (php code function)
  2. function safe_str($str){
  3. $array=array('receive.php','select','insert', 'update','delete','union','into','load_file','outfile');
  4. if(!is_array($str)){
  5. foreach($array as $v){
  6. $str= preg_replace("#({$v})#i","-\$小贝-",$str);
  7. }
  8. //$str=preg_replace("![][xX]([A-Fa- f0-9])!","x \$小贝",$str);
  9. $str=str_replace("'",''',$str);
  10. $str=str_replace('"' ,'"',$str);
  11. $str=str_replace("--",'-',$str);
  12. $str=str_replace("\*",'\-*',$str );
  13. $str=str_replace("\\",'monxin_backslash',$str);
  14. $r=$str;
  15. }else{
  16. $r=array();
  17. foreach($str as $key=> ;$value){
  18. //$key=safe_str($key);
  19. $r[$key]=safe_str($value);
  20. }
  21. }
  22. return $r;
  23. }
Copy code

PHP


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template