Guest User

Untitled

a guest
Jul 10th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?php
  2.  
  3. class Firewall{
  4.     public function __construct(){
  5.         if(@$_POST['firewall'] == 'cancelar'){
  6.             //NÃO FAZ NADA
  7.         }else{
  8.            
  9.             if ($_POST) {
  10.                 $this->post();
  11.             } else if ($_GET){
  12.                 $this->get();
  13.             }
  14.         }      
  15.     }
  16.  
  17.     function post(){
  18.         foreach ($_POST as $chave => $valor){
  19.             if(is_array($valor)){
  20.                 foreach ($valor as $chave2 => $valor2){
  21.                     $_POST[$chave2] = $this->antiInjection($valor2);
  22.                 }
  23.             }else{
  24.                 $_POST[$chave] = $this->antiInjection($valor);
  25.             }
  26.                
  27.         }return;
  28.     }
  29.  
  30.     function get(){
  31.         foreach ($_GET as $chave => $valor){
  32.                
  33.             if(is_array($valor)){
  34.                 foreach ($valor as $chave2 => $valor2){
  35.                     $_POST[$chave2] = $this->antiInjection($valor2);
  36.                 }
  37.             }
  38.             else { $_GET[$chave] = $this->antiInjection($valor);
  39.             }
  40.                
  41.         } return;
  42.     }
  43.  
  44.     function antiInjection($valor) {
  45.         $valor = preg_replace("/(from|select|insert|delete|where|drop table|show tables|show databases|describe|left join|right join|inner join|#|\*|--|\\\\)/i", "", $valor);
  46.         $valor = trim($valor);
  47.         $valor = strip_tags($valor);
  48.         $valor = addslashes($valor);
  49.  
  50.         return $valor;
  51.     }
  52. }
  53.  
  54. $fw = new Firewall();
Advertisement
Add Comment
Please, Sign In to add comment