Created
January 5, 2015 19:38
-
-
Save davebarnwell/58bd861bbc7b9859cae9 to your computer and use it in GitHub Desktop.
strip slashes from input if PHP magic quotes is enabled
This file contains hidden or 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 | |
| // if magic quotes are on strip slashes from vars | |
| if (get_magic_quotes_gpc()) { | |
| function stripslashes_array(&$arr) { | |
| foreach ($arr as $k => &$v) { | |
| $nk = stripslashes($k); | |
| if ($nk != $k) { | |
| $arr[$nk] = &$v; | |
| unset($arr[$k]); | |
| } | |
| if (is_array($v)) { | |
| stripslashes_array($v); | |
| } else { | |
| $arr[$nk] = stripslashes($v); | |
| } | |
| } | |
| } | |
| stripslashes_array($_POST); | |
| stripslashes_array($_GET); | |
| stripslashes_array($_REQUEST); | |
| stripslashes_array($_COOKIE); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment