Last active
March 30, 2016 09:22
-
-
Save thabofletcher/de4397e1bbc78495b659 to your computer and use it in GitHub Desktop.
sanitize all dangerous superglobals
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
foreach ($_GET as $key => $value) { | |
$_GET[$key] = filter_input(INPUT_GET, $key, FILTER_SANITIZE_STRING); | |
} | |
foreach ($_POST as $key => $value) { | |
$_POST[$key] = filter_input(INPUT_POST, $key, FILTER_SANITIZE_STRING); | |
} | |
foreach ($_COOKIE as $key => $value) { | |
$_COOKIE[$key] = filter_input(INPUT_COOKIE, $key, FILTER_SANITIZE_STRING); | |
} | |
foreach ($_SERVER as $key => $value) { | |
$_SERVER[$key] = filter_input(INPUT_SERVER, $key, FILTER_SANITIZE_STRING); | |
} | |
foreach ($_ENV as $key => $value) { | |
$_ENV[$key] = filter_input(INPUT_ENV, $key, FILTER_SANITIZE_STRING); | |
} | |
$_REQUEST = array_merge( $_GET, $_POST ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment