经典php防注入函数代码
发布:smiling 来源: PHP粉丝网 添加日期:2014-08-25 08:49:53 浏览: 评论:
- <?php
-
-
-
-
-
-
-
-
- $arrfiltrate=array("'",";","union");
-
- $strgourl="";
-
- function funstringexist($strfiltrate,$arrfiltrate){
- foreach ($arrfiltrate as $key=>$value){
- if (eregi($value,$strfiltrate)){
- return true;
- }
- }
- return false;
- }
-
-
- if(function_exists(array_merge)){
- $arrpostandget=array_merge($http_post_vars,$http_get_vars);
- }else{
- foreach($http_post_vars as $key=>$value){
-
- $arrpostandget[]=$value;
- }
- foreach($http_get_vars as $key=>$value){
- $arrpostandget[]=$value;
- }
- }
-
-
- foreach($arrpostandget as $key=>$value){
- if (funstringexist($value,$arrfiltrate)){
- echo "<script language="网页特效">alert("非法字符");</script>";
- if (emptyempty($strgourl)){
- echo "<script language="javascript">history.go(-1);</script>";
- }else{
- echo "<script language="javascript">window.location="".$strgourl."";</script>";
- }
- exit;
- }
- }
- ?>
分享到: