Created
November 25, 2013 20:12
-
-
Save triple-j/7648009 to your computer and use it in GitHub Desktop.
counteract magic quotes if they are enabled (http://www.php.net/manual/en/security.magicquotes.disabling.php#71817)
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 | |
// counteract magic quotes if they are enabled (http://www.php.net/manual/en/security.magicquotes.disabling.php#71817) | |
if (get_magic_quotes_gpc()) { | |
function undoMagicQuotes($array, $topLevel=true) { | |
$newArray = array(); | |
foreach($array as $key => $value) { | |
if (!$topLevel) { | |
$key = stripslashes($key); | |
} | |
if (is_array($value)) { | |
$newArray[$key] = undoMagicQuotes($value, false); | |
} else { | |
$newArray[$key] = stripslashes($value); | |
} | |
} | |
return $newArray; | |
} | |
$_GET = undoMagicQuotes($_GET); | |
$_POST = undoMagicQuotes($_POST); | |
$_COOKIE = undoMagicQuotes($_COOKIE); | |
$_REQUEST = undoMagicQuotes($_REQUEST); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment