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

About this user

Albert Peschar http://www.cheatguide.nl/

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Remove magic quotes on GPC data

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

   1  
   2  <?php
   3  
   4  // remove magic_quotes
   5  if(get_magic_quotes_gpc())
   6  {
   7    function undo_magic_quotes_array($array)
   8    {
   9      return is_array($array) ? array_map('undo_magic_quotes_array', $array) : str_replace("\\'", "'",
  10  							                                                               str_replace("\\\"", "\"",
  11                                                                               str_replace("\\\\", "\\",
  12                                                                               str_replace("\\\x00", "\x00", $array))));
  13    }
  14  
  15    $_GET = undo_magic_quotes_array($_GET);
  16    $_POST = undo_magic_quotes_array($_POST);
  17    $_COOKIE = undo_magic_quotes_array($_COOKIE);
  18    $_FILES = undo_magic_quotes_array($_FILES);
  19    $_REQUEST = undo_magic_quotes_array($_REQUEST);
  20  }
  21  
  22  ?>

Remove magic quotes on GPC data

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

   1  
   2  <?php
   3  
   4  // remove magic_quotes
   5  if(get_magic_quotes_gpc())
   6  {
   7    function undo_magic_quotes_array($array)
   8    {
   9      return is_array($array) ? array_map('undo_magic_quotes_array', $array) : str_replace("\\'", "'",
  10  							                                                               str_replace("\\\"", "\"",
  11                                                                               str_replace("\\\\", "\\",
  12                                                                               str_replace("\\\x00", "\x00", $array))));
  13    }
  14  
  15    $_GET = undo_magic_quotes_array($_GET);
  16    $_POST = undo_magic_quotes_array($_POST);
  17    $_COOKIE = undo_magic_quotes_array($_COOKIE);
  18    $_FILES = undo_magic_quotes_array($_FILES);
  19    $_REQUEST = undo_magic_quotes_array($_REQUEST);
  20  }
  21  
  22  ?>
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS