note 43546 deleted from function.get-magic-quotes-gpc by nlopess
| From: | nlopess@php.net | Date: | Fri, 25 Jun 2004 09:30:23 +0000 |
| Subject: | note 43546 deleted from function.get-magic-quotes-gpc by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71654@lists.php.net to get a copy of this message | ||
Note Submitter: Patrick Clery
----
The previously mentioned functions will NOT escape the keys of the given arrays. This will:
<?php
function magicQuotesRemove(&$array) {
if(!get_magic_quotes_gpc())
return;
/* Prepare a new array */
$copy = array();
foreach($array as $key => $elem) {
$copy[stripslashes($key)] = $elem;
if(is_array($elem))
magicQuotesRemove($elem);
else
$elem = stripslashes($elem);
$copy[stripslashes($key)] = $elem;
}
$array = $copy;
}
magicQuotesRemove($_GET);
magicQuotesRemove($_POST);
magicQuotesRemove($_COOKIE);
/* Why not magic_quotes_GPCR ? */
magicQuotesRemove($_REQUEST);
?>