note 77431 deleted from security.globals by danbrown

From: Date: Thu, 15 Jan 2009 16:23:08 +0000
Subject: note 77431 deleted from security.globals by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149266@lists.php.net to get a copy of this message
Note Submitter: Mike Willbanks ---- Alans code may get rid of globals but it is slow since it is doing regular expressions on each of the input items. Then to add on more time the code is being passed through eval. Besides the slower performance, his code is not checking to see if the variable may have been changed at any state before this code is being done. There might be auto_prepended files or include files that might need to run before it. He is also going through get and post and lastly request which is a little silly seeing as request will contain the get, post and cookie so he has run get and post twice. Here is a more effective fix that will take all the keys in request which become variable names and checks to make sure that the variables match then unsets the element. <?php if (ini_get(register_globals)) { $rg = array_keys($_REQUEST); foreach($rg as $var) { if ($_REQUEST[$v] === $$v) { unset($$v); } } } ?>

« previous php.notes (#149266) next »