note 43546 added to function.get-magic-quotes-gpc
| From: | PatrickClery at rn2 dot php dot net | Date: | Fri, 25 Jun 2004 00:28:34 +0000 |
| Subject: | note 43546 added to function.get-magic-quotes-gpc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-71627@lists.php.net to get a copy of this message | ||
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);
?>
----
Manual Page -- http://www.php.net/manual/en/function.get-magic-quotes-gpc.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43546
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43546&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43546&report=yes
Search -- http://master.php.net/manage/user-notes.php