Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Remove magic quotes on GPC data (See related posts)

Removes magic quotes on $_GET, $_POST, $_COOKIE, $_FILES and $_REQUEST, when they are enabled.

<?php

// 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);
}

?>

You need to create an account or log in to post comments to this site.


Click here to browse all 4839 code snippets

Related Posts