php正则验证sql方注入

 1 <?php
 2 function inject_check($Sql_Str) {//自动过滤Sql的注入语句。
 3     $check=preg_match('/select|insert|update|delete|\'|\\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/i',$Sql_Str);
 4     if ($check) {
 5         echo '<script language="JavaScript">alert("系统警告:\n\n请不要尝试在参数中包含非法字符尝试注入!");</script>';
 6         exit();
 7     }else{
 8         return $Sql_Str;
 9     }
10 }
11 echo inject_check('select * from table where 1 or 1=1');
12 ?>

 

posted @ 2015-11-30 11:47  inc  阅读(657)  评论(0编辑  收藏  举报