Skip to content

Instantly share code, notes, and snippets.

@davebarnwell
Created January 5, 2015 19:38
Show Gist options
  • Select an option

  • Save davebarnwell/58bd861bbc7b9859cae9 to your computer and use it in GitHub Desktop.

Select an option

Save davebarnwell/58bd861bbc7b9859cae9 to your computer and use it in GitHub Desktop.
strip slashes from input if PHP magic quotes is enabled
<?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