Re: $_POST getting lost, $GLOBALS['HTTP_RAW_POST_DATA'] is still set
| From: | Adam Bregenzer | Date: | Fri, 13 Feb 2004 17:02:00 +0000 |
| Subject: | Re: $_POST getting lost, $GLOBALS['HTTP_RAW_POST_DATA'] is still set | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177616@lists.php.net to get a copy of this message | ||
On Fri, 2004-02-13 at 11:38, Joshua Beall wrote:
> I want to turn off magic quotes. I realize in retrospect that using a
> .htaccess file to turn magic quotes would probably be better than this code,
> and I am going to switch to that solution, but I am still trying
> to figure out what is causing my current problem:
Having a function to undo magic quotes can be very useful if you
distribute your application. Here is what I use, just call
disable_magic_quotes(). It should not do any damage if magic_quotes is
already disabled.
/* Undo damage caused by magic quotes */
function remove_magic_quotes($vars,$suffix = '') {
eval("\$vars_val =& \$GLOBALS['$vars']$suffix;");
if (is_array($vars_val)) {
foreach ($vars_val as $key => $val) {
remove_magic_quotes($vars, $suffix . "['$key']");
}
} else if (!is_object($vars_val)) {
$vars_val = stripslashes($vars_val);
eval("\$GLOBALS['$vars']$suffix = \$vars_val;");
}
}
// Defeat magic quotes
function disable_magic_quotes() {
if (get_magic_quotes_gpc()) {
remove_magic_quotes('_GET');
remove_magic_quotes('_POST');
remove_magic_quotes('_COOKIE');
ini_set('magic_quotes_gpc',0);
}
set_magic_quotes_runtime(0);
}
--
Adam Bregenzer
adam@bregenzer.net
http://adam.bregenzer.net/