note 60311 deleted from security.magicquotes.disabling by bjori

From: Date: Tue, 04 Apr 2006 23:06:41 +0000
Subject: note 60311 deleted from security.magicquotes.disabling by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107352@lists.php.net to get a copy of this message
Note Submitter: Niraj Bhawnani ---- The stripslashes_deep method is probably not the best way to undo the "damage" done by magic quotes. The function copies the array passed to it, then array_map copies the array, and the return value is written over the old variables. Also, $_REQUEST isn't taken into consideration in the above method. I see this as a great place to use references. So here's a piece of code that I think should be faster: <?php function arrayStripSlashes(&$array) { foreach($array as &$value) { if (is_array($value)) { arrayStripSlashes($value); } else { $value = stripslashes($value); } } } if (get_magic_quotes_gpc()) { arrayStripSlashes($_POST); arrayStripSlashes($_REQUEST); arrayStripSlashes($_GET); arrayStripSlashes($_COOKIE); } ?>

« previous php.notes (#107352) next »