两种不同版本的防注入函数


//**************   防注入函数

function inject_check($sql_str) {   
   $check=eregi('and|or|where|limit|group by|select|insert|update|delete|\'|\\*|\*|\.\.\/|\.\/|union|into|load_file|outfile',$sql_str); // 进行过滤 PHP5.3以前用
   //$check= preg_match('/and|or|where|limit|group by|select|insert|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/i', $sql_str);     // 进行过滤 PHP5.3以后用    
   if($check){
    echo "你输入非法字符!";
    exit();
    }else{
     return $sql_str;
     }
  }

//**************   防注入函数 完


PHP5.3以后的版本没有了eregi,所以只能用preg_match


摘自:http://www.q3060.com/list3/list117/

猜你喜欢

转载自blog.csdn.net/u014413032/article/details/48682055