note 27563 deleted from ref.variables by nlopess
| From: | nlopess@php.net | Date: | Mon, 28 Jun 2004 14:29:08 +0000 |
| Subject: | note 27563 deleted from ref.variables by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72015@lists.php.net to get a copy of this message | ||
Note Submitter: Darryl dot Friesen @ usask dot ca
----
The above code posted by maxim and dekiland doesn't seem to create $_REQUEST in the same manner
as described in the PHP Documentation:
"An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE".
I modified the code slightly. I haven't tested this much, but it seems to work as expected.
$evil_vars = Array('GET', 'POST', 'COOKIE', 'SERVER',
'ENV', 'REQUEST', 'SESSION');
$php_version = preg_replace("/[^\d]/", '', phpversion());
for ($i = 0; $i < sizeof($evil_vars); $i++)
{
if (is_array(${"HTTP_{$evil_vars[$i]}_VARS"}))
{
foreach (${"HTTP_{$evil_vars[$i]}_VARS"} as $var=>$val)
{
if($php_version<410)
{
$GLOBALS["_{$evil_vars[$i]}"][$var] = $val;
// following if condition added by D. Friesen
if (($evil_vars[$i] == 'GET') || ($evil_vars[$i] == 'POST') ||
($evil_vars[$i] == 'COOKIE'))
$GLOBALS["_REQUEST"][$var] = $val;
}
unset($$var); //changed from unset($$key); by dekiland
}
}
unset(${"HTTP_{$evil_vars[$i]}_VARS"});
}