» tagged pages
» logout
PHP
Return to PHP Code Snippets

Remove magic quotes on GPC data

Tags Applied to this Entry

1 person has tagged this page:
Removes magic quotes on $_GET, $_POST, $_COOKIE, $_FILES and $_REQUEST, when they are enabled.



// remove magic_quotes
if(get_magic_quotes_gpc())
{
function undo_magic_quotes_array($array)
{
return is_array($array) ? array_map('undo_magic_quotes_array', $array) : str_replace("\\'", "'",
str_replace("\\\"", "\"",
str_replace("\\\\", "\\",
str_replace("\\\x00", "\x00", $array))));
}

$_GET = undo_magic_quotes_array($_GET);
$_POST = undo_magic_quotes_array($_POST);
$_COOKIE = undo_magic_quotes_array($_COOKIE);
$_FILES = undo_magic_quotes_array($_FILES);
$_REQUEST = undo_magic_quotes_array($_REQUEST);
}

?>
Username:
Password:
(or Cancel)