note 60828 added to function.get-magic-quotes-gpc

From: Date: Wed, 18 Jan 2006 00:30:27 +0000
Subject: note 60828 added to function.get-magic-quotes-gpc
Groups: php.notes 
Request: Send a blank email to php-notes+get-101995@lists.php.net to get a copy of this message
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. ---- Server IP: 200.185.109.103Probable Submitter: 200.181.177.227 ---- Manual Page -- http://www.php.net/manual/en/function.get-magic-quotes-gpc.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60828 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60828&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60828&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60828&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60828&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60828&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60828&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60828&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60828&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101995) next »