Last active
August 29, 2015 13:56
-
-
Save james2doyle/9045018 to your computer and use it in GitHub Desktop.
Sanatize and filter $_GET and $_POST data that handles arrays and is recursive. http://goo.gl/Fonl6D
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
// Filters data against security risks. | |
function filter($data) { | |
if (is_array($data)) { | |
foreach ($data as $key => $element) { | |
$data[$key] = filter($element); | |
} | |
} else { | |
$data = trim(htmlentities(strip_tags($data))); | |
if(get_magic_quotes_gpc()) { | |
$data = stripslashes($data); | |
} | |
$data = filter_var($data ,FILTER_SANITIZE_STRING); | |
} | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment