note 28240 deleted from function.set-magic-quotes-runtime by didou

From: Date: Thu, 29 May 2003 21:46:42 +0000
Subject: note 28240 deleted from function.set-magic-quotes-runtime by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-49337@lists.php.net to get a copy of this message
Note Submitter: gordon@kanazawa-gu.ac.jp ---- Gnarf's useful "remove_magic_quotes" function can be enhanced to account for "magic_quotes_sybase" and "magic_quotes_runtime", which, according to http://www.php.net/manual/en/ref.sybase.php, can completely override "magic_quotes_gpc". remove_magic_quotes(&$HTTP_GET_VARS); remove_magic_quotes(&$HTTP_POST_VARS); remove_magic_quotes(&$HTTP_COOKIE_VARS); remove_magic_quotes(&$HTTP_SESSION_VARS); ini_set("magic_quotes_gpc", 0); ini_set("magic_quotes_sybase", 0); ini_set("magic_quotes_runtime", 0); function remove_magic_quotes(&$x) { if (is_array($x)) { while (list($key,$value) = each($x)) { if ($value) remove_magic_quotes(&$x[$key]); } } else if (ini_get('magic_quotes_sybase')) { $x = preg_replace("/''/", "'", $x); } else if (ini_get('magic_quotes_runtime')) { $x = preg_replace("/\\\"/", '"', $x); } else if (ini_get('magic_quotes_gpc')) { $x = stripslashes($x); } } This version also uses HTTP_*_VARS for slightly more backwards compatability and passes variables by reference for efficiency.

« previous php.notes (#49337) next »