<?php 
/**
function checksql() 
{ 
        
		   //$bad_str = "and|select|update|'|delete|insert|*"; 
		   $bad_str ='and|select|inert|update|delete|';
		   $bad_str =$bad_str .' \'|\/\*|\*|\.\.\/|\.\/|UNION|into|load_file|outfile';

           $bad_Array = explode("|",$bad_str); 
           // ---------------------------------过滤Get参数--------------------------------------- 
           foreach ($bad_Array as $bad_a) 
          { 
                 foreach ($_GET as $g) 
                { 
                     if (substr_count(strtolower($g),$bad_a) > 0) 
                     { 
                           echo "<script>alert('[软件提示]:非法字符输入,自动返回首页!');";
						   echo "location.href='index.php';";
                           echo "</script>"; 
                           exit(); 
                     } 
               } 
         } 

           //--------------------------过滤Post参数--------------------------

            foreach ($bad_Array as $bad_a) 
           { 
                  foreach ($_POST as $p) 
                 { 
                       if (substr_count(strtolower($p),$bad_a) > 0) 
                       { 
                           echo "<script>alert('[软件提示]:非法字符输入,自动返回首页!');";
						   echo "location.href='index.php';";
                           echo "</script>"; 
                           exit(); 
                     } 
                } 
           } 


             //----------------------------过滤Cookies参数---------------------------------------

                 foreach ($bad_Array as $bad_a) 
                 { 
                       foreach ($_COOKIE as $co) 
                        { 
                            if (substr_count(strtolower($co),$bad_a) > 0) 
                           { 
                               echo "<script>alert('[软件提示]:非法字符输入,自动返回首页!');";
						       echo "location.href='index.php';";
                               echo "</script>"; 
                               exit(); 
                          } 
                      } 
               } 
			   
			return false;
} 

?>

<?php  checksql(); ?>




<?php
  
  
  //----------------------------以下函数备用------------------------------------------------------------
  function  anti_sql()
  {
	  
       
       foreach ($_GET as $get_key=>$get_var) 
        { 
             if (is_numeric($get_var)) 
			 { 
                 $get[strtolower($get_key)] = get_int($get_var); 
            } 
			else
			 { 
                $get[strtolower($get_key)] = get_str($get_var); 
            } 
       } 

          
          foreach ($_POST as $post_key=>$post_var) 
         { 
               if (is_numeric($post_var))
			    { 
                    $post[strtolower($post_key)] = get_int($post_var); 
               } 
			   else
			    { 
                    $post[strtolower($post_key)] = get_str($post_var); 
                } 
         } 
		  
		 return true;
  }
  
 
 
  

   function get_int($number) 
          { 
                return intval($number); 
          } 
   
   
  function get_str($string) 
         { 
             if (!get_magic_quotes_gpc())
			  { 
                  return addslashes($string); 
              } 
              return $string; 
          }

?>


**/





