Created
August 8, 2012 10:15
-
-
Save JulienBreux/3294030 to your computer and use it in GitHub Desktop.
IO prevent
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 | |
function secure(&$value, $key) | |
{ | |
if ((bool)preg_match('/^[0-9]+$/', $value)) | |
$value = (int)$value; | |
elseif ((bool)preg_match('/^[0-9]+\.[0-9]+$/', $value)) | |
$value = (float)$value; | |
else | |
$value = mysql_real_escape_string($value); | |
} | |
array_walk($_GET, 'secure'); | |
array_walk($_POST, 'secure'); | |
array_walk($_REQUEST, 'secure'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment