note 60828 deleted from function.get-magic-quotes-gpc by philip

From: Date: Tue, 27 Jun 2006 06:38:29 +0000
Subject: note 60828 deleted from function.get-magic-quotes-gpc by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-114342@lists.php.net to get a copy of this message
Note Submitter: gilthansNOSPAM at gmail dot com ---- I, for one, actually learned to trust Magic Quotes, especially when using code not written by me. Other programmers often leave input as is, without slashing even when needed, and I find it much more useful to actually make sure the Magic Quotes is ON than disabling it and rewriting all the code. I wrote this piece of PHP for when you want to make sure that Magic Quotes GPC is always ON: <?php if(!get_magic_quotes_gpc()){ function deepslash($v){ return (is_array($v)) ? array_map("deepslash", $v) : addslashes($v); } array_map("deepslash", $_POST); array_map("deepslash", $_GET); array_map("deepslash", $_COOKIE); array_map("deepslash", $_REQUEST); array_map("deepslash", $_GLOBALS); array_map("deepslash", $_SERVER); } ?> That might prevent some security problems in amateur scripts and is usually useful when someone asks you to secure a piece of code that a new programmer wrote for him.

« previous php.notes (#114342) next »