当前位置:数据库 > SQLServer >>

PHP 防止sql注入函数代码

PHP 防止sql注入函数代码:
  1. <?php
  2. $magic_quotes_gpc = get_magic_quotes_gpc();
  3. @extract(daddslashes($_COOKIE));
  4. @extract(daddslashes($_POST));
  5. @extract(daddslashes($_GET));
  6. if(!$magic_quotes_gpc) {
  7.         $_FILES = daddslashes($_FILES);
  8. }
  9. function daddslashes($string, $force = 0) {
  10.         if(!$GLOBALS[magic_quotes_gpc] || $force) {
  11.                 if(is_array($string)) {
  12.                     foreach($string as $key => $val) {
  13.                         $string[$key] = daddslashes($val, $force);
  14.                     }
  15.                 } else {
  16.                     $string = addslashes($string);
  17.                 }
  18.         }
  19.         return $string;
  20. }
  21. ?>
补充:Web开发 , php ,
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,