note 39704 deleted from function.get-magic-quotes-gpc by nlopess
| From: | nlopess@php.net | Date: | Sun, 08 Feb 2004 09:47:24 +0000 |
| Subject: | note 39704 deleted from function.get-magic-quotes-gpc by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-64814@lists.php.net to get a copy of this message | ||
Note Submitter: justin@homelessinsane.com
----
I would also like to make my hatred of this "magic quotes" feature known. I really hope
whoever came up with this idea dies a painful death.
I noticed that the "gpc" is deceiving because this also appears to add slashes to the
$_SERVER. It may add to other $_ arrays such as $_ENV but I haven't tested those so WATCH OUT!
You are at the mercy of this unpredictable evil.
Here is a simple way to turn off this feature and waste a little CPU in the mean time. There are a
bunch of methods posted here but this is really the simplest, working model.
<?PHP
if (get_magic_quotes_gpc()) {
$_GET = array_map("stripslashes", $_GET);
$_POST = array_map("stripslashes", $_POST);
$_COOKIE = array_map("stripslashes", $_COOKIE);
$_SERVER = array_map("stripslashes", $_SERVER);
}
?>
Be careful when writing PHP code that could be potentially meshed with other people's PHP code.
If your code molests the $_ arrays you could create huge security problems for other people using
your code. At the moment I am writing a banner manager and I am really getting gimped trying to
figure out the best way to work my way around this.