-
-
Save rafaelfoster/7346969 to your computer and use it in GitHub Desktop.
Function in PHP that receives the parameters (normaly passed by a $_POST or a $_GET and treat the informations removing some SQL commands, preventing the SQL Injection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Anti Injection | |
* Verifica e Trata as informações | |
* Autor: Danilo Iannone - [email protected] | |
*/ | |
function anti_injection( $obj ) { | |
$obj = preg_replace("/(from|alter table|select|insert|delete|update|where|drop table|show tables|#|\*|--)/i", "",strtolower($obj)); | |
$obj = trim($obj); | |
$obj = strip_tags($obj); | |
if(!get_magic_quotes_gpc()) { | |
$obj = addslashes($obj); | |
return $obj; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment