Snippets v2

Languages
My Snippets

Emulate Magic Quotes On Login or Register to Bookmark this snippet

Description PHP

This script should be included to emulate magic quotes on. If magic quotes are already on, we don't apply any changes to the variables.

The Code Download
  1. <?php
  2. /*
  3. This script should be included to emulate magic quotes on.
  4. If magic quotes are already on, we don't apply any changes to the variables.
  5. */
  6.  
  7. //this will set all other input data (from databases etc) to have slashes.
  8. //set_magic_quotes_runtime(TRUE);
  9.  
  10.     /*
  11.     All these global variables are not slash-encoded by default,
  12.     because magic_quotes_gpc is not set by default!
  13.     (And magic_quotes_gpc affects more than just $_GET, $_POST, and $_COOKIE)
  14.     */
  15.     $_SERVER = addslashesArray($_SERVER);
  16.     $_GET = addslashesArray($_GET);
  17.     $_POST = addslashesArray($_POST);
  18.     $_COOKIE = addslashesArray($_COOKIE);
  19.     $_FILES = addslashesArray($_FILES);
  20.     $_ENV = addslashesArray($_ENV);
  21.     $_REQUEST = addslashesArray($_REQUEST);
  22.     $HTTP_SERVER_VARS = addslashesArray($HTTP_SERVER_VARS);
  23.     $HTTP_GET_VARS = addslashesArray($HTTP_GET_VARS);
  24.     $HTTP_POST_VARS = addslashesArray($HTTP_POST_VARS);
  25.     $HTTP_COOKIE_VARS = addslashesArray($HTTP_COOKIE_VARS);
  26.     $HTTP_POST_FILES = addslashesArray($HTTP_POST_FILES);
  27.     $HTTP_ENV_VARS = addslashesArray($HTTP_ENV_VARS);
  28.     if (isset($_SESSION)) { #These are unconfirmed (?)
  29.         $_SESSION = addslashesArray($_SESSION, '');
  30.         $HTTP_SESSION_VARS = addslashesArray($HTTP_SESSION_VARS, '');
  31.     }
  32. }
  33.  
  34. /*
  35. The $GLOBALS array is also slash-encoded, but when all the above are
  36. changed, $GLOBALS is updated to reflect those changes.  (Therefore
  37. $GLOBALS should never be modified directly).  $GLOBALS also contains
  38. infinite recursion, so it's dangerous...
  39. */
  40. ?>
Credits Contact JC

Added by JC on 11th November, 2007

Comments

There are no comments about this snippet.

Post Comment HTML is allowed

You must be registered and logged in to post a comment.

Login here to post a comment