note 60311 added to security.magicquotes.disabling
| From: | NirajBhawnani at osu1 dot php dot net | Date: | Tue, 03 Jan 2006 12:03:27 +0000 |
| Subject: | note 60311 added to security.magicquotes.disabling | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101145@lists.php.net to get a copy of this message | ||
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);
}
?>
----
Manual Page -- http://www.php.net/manual/en/security.magicquotes.disabling.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60311
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60311&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60311&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60311&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60311&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60311&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60311&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60311&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60311&report=yes
Search -- http://master.php.net/manage/user-notes.php