note 39704 added to function.get-magic-quotes-gpc

From: Date: Sun, 08 Feb 2004 05:58:06 +0000
Subject: note 39704 added to function.get-magic-quotes-gpc
Groups: php.notes 
Request: Send a blank email to php-notes+get-64805@lists.php.net to get a copy of this message
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. ---- 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+39704 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39704&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39704&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64805) next »