note 41247 deleted from security.globals by philip
| From: | philip@php.net | Date: | Wed, 14 Jul 2004 21:42:55 +0000 |
| Subject: | note 41247 deleted from security.globals by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73240@lists.php.net to get a copy of this message | ||
Note Submitter: electronerd@monolith3d.com
----
(I am the same person as electronerd@hotmail.com)
Thank you for the correction.
Updated code:
<?php
$var_list = get_defined_vars();
$safelist = array('_GET', '_POST', '_COOKIE', '_SERVER',
'_ENV', '_FILES', '_REQUEST', '_SESSION');
foreach($var_list as $name => $value)
{
if(array_search($name, $safelist) === FALSE)
{
unset($$name);
}
}
unset($var_list, $name, $value, $safelist);
?>
As before, all you have to do to extend the list of variables to keep is to add them to $safelist
(though, obviously, if you want to save $var_list, $safelist, $name, or $value, you're going to
have to modify the script).