note 17433 deleted from function.get-magic-quotes-gpc by jimw

From: Date: Thu, 20 Dec 2001 22:25:05 +0000
Subject: note 17433 deleted from function.get-magic-quotes-gpc by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23490@lists.php.net to get a copy of this message
To disable magic_quotes_gpc in your script you can't just ini_set-it, because at that time the variables are already written by PHP. So you can only walk through all variables and stripslashes them individually. To even walk into deeply nested arrays, you can try this: if (ini_get("magic_quotes_gpc") == 1) { // Stripslashes recursively function strip_rec($this) { if (is_array($this)) { while (list($key, $val) = each($this)) { $this[$key] = strip_rec($val); } } else { $this = stripslashes($this); } return $this; } $HTTP_POST_VARS = strip_rec($HTTP_POST_VARS); $HTTP_GET_VARS = strip_rec($HTTP_GET_VARS); $HTTP_COOKIE_VARS = strip_rec($HTTP_COOKIE_VARS); // "Register globals?" if (ini_get("register_globals")) { if (is_array($HTTP_POST_VARS)) { while (list ($key, $val) = each ($HTTP_POST_VARS)) { $$key = $val; } } if (is_array($HTTP_GET_VARS)) { while (list ($key, $val) = each ($HTTP_GET_VARS)) { $$key = $val; } } if (is_array($HTTP_COOKIE_VARS)) { while (list ($key, $val) = each ($HTTP_COOKIE_VARS)) { $$key = $val; } } } }

« previous php.notes (#23490) next »