note 47355 deleted from function.get-magic-quotes-gpc by philip

From: Date: Tue, 27 Jun 2006 06:40:09 +0000
Subject: note 47355 deleted from function.get-magic-quotes-gpc by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-114352@lists.php.net to get a copy of this message
Note Submitter: pestilence ---- In the example above, the author forgets to include $_REQUEST, which is also slashed (using PHP 4.3.8). It's good practice to include a routine to "unslash" or "slash" variables, if something happens that isn't to your expectation. However your PHP is written to depend on this option, it becomes important to support either when or if others deploy your code. --------------------------------------------------------------------- If you have written for having this option disabled: --------------------------------------------------------------------- if (get_magic_quotes_gpc()) unfck_gpc(); function unfck($v) { return is_array($v) ? array_map('unfck', $v) : stripslashes($v); } function unfck_gpc() { foreach (array('POST', 'GET', 'REQUEST', 'COOKIE') as $gpc) $GLOBALS["_$gpc"] = array_map('unfck', $GLOBALS["_$gpc"]); } --------------------------------------------------------------------- If you have written for having this option enabled: --------------------------------------------------------------------- if (!get_magic_quotes_gpc()) unfck_gpc(); function unfck($v) { return is_array($v) ? array_map('unfck', $v) : addslashes($v); } function unfck_gpc() { foreach (array('POST', 'GET', 'REQUEST', 'COOKIE') as $gpc) $GLOBALS["_$gpc"] = array_map('unfck', $GLOBALS["_$gpc"]); } --------------------------------------------------------------------- Including either code block, depending on how your PHP is written, will ensure that it will operate the same regardless of this configuration option.

« previous php.notes (#114352) next »