note 84051 deleted from security.magicquotes by philip
| From: | philip@php.net | Date: | Sun, 21 Dec 2008 01:07:31 +0000 |
| Subject: | note 84051 deleted from security.magicquotes by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-148391@lists.php.net to get a copy of this message | ||
Note Submitter: travismowens at gmail dot com
----
With just a couple minor updates to Thomas' function, it can support both arrays and variables
like so:
function RemoveMagicQuotes ($postArray, $trim = false)
{
if (get_magic_quotes_gpc() == 1)
{
if ( is_array($postArray) )
{
$newArray = array();
foreach ($postArray as $key => $val)
{
if (is_array($val))
{
$newArray[$key] = removeMagicQuotes ($val, $trim);
}
else
{
if ($trim == true)
{
$val = trim($val);
}
$newArray[$key] = stripslashes($val);
}
}
return $newArray;
}
else
{
return stripcslashes($postArray);
}
}
else
{
return $postArray;
}
}