Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Firewall{
- public function __construct(){
- if(@$_POST['firewall'] == 'cancelar'){
- //NÃO FAZ NADA
- }else{
- if ($_POST) {
- $this->post();
- } else if ($_GET){
- $this->get();
- }
- }
- }
- function post(){
- foreach ($_POST as $chave => $valor){
- if(is_array($valor)){
- foreach ($valor as $chave2 => $valor2){
- $_POST[$chave2] = $this->antiInjection($valor2);
- }
- }else{
- $_POST[$chave] = $this->antiInjection($valor);
- }
- }return;
- }
- function get(){
- foreach ($_GET as $chave => $valor){
- if(is_array($valor)){
- foreach ($valor as $chave2 => $valor2){
- $_POST[$chave2] = $this->antiInjection($valor2);
- }
- }
- else { $_GET[$chave] = $this->antiInjection($valor);
- }
- } return;
- }
- function antiInjection($valor) {
- $valor = preg_replace("/(from|select|insert|delete|where|drop table|show tables|show databases|describe|left join|right join|inner join|#|\*|--|\\\\)/i", "", $valor);
- $valor = trim($valor);
- $valor = strip_tags($valor);
- $valor = addslashes($valor);
- return $valor;
- }
- }
- $fw = new Firewall();
Advertisement
Add Comment
Please, Sign In to add comment