note 95712 deleted from security.magicquotes.disabling by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 Jan 2010 19:17:27 +0000 |
| Subject: | note 95712 deleted from security.magicquotes.disabling by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165056@lists.php.net to get a copy of this message | ||
Note Submitter: Alix Axel
Reason: non-english
----
For PHP 5.3+ users here is a simpler, portable way to work around magic quotes:
<?php
if (get_magic_quotes_gpc() === 1)
{
$_GET = json_decode(stripslashes(json_encode($_GET, JSON_HEX_APOS)), true);
$_POST = json_decode(stripslashes(json_encode($_POST, JSON_HEX_APOS)), true);
$_COOKIE = json_decode(stripslashes(json_encode($_COOKIE, JSON_HEX_APOS)), true);
$_REQUEST = json_decode(stripslashes(json_encode($_REQUEST, JSON_HEX_APOS)), true);
}
?>
Fixes both keys and values in multi-dimensional arrays without using recursion.