note 82213 deleted from security.globals by cmb
| From: | cmb@php.net | Date: | Sun, 17 Jan 2021 13:56:54 +0000 |
| Subject: | note 82213 deleted from security.globals by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216178@lists.php.net to get a copy of this message | ||
Note Submitter: Ruquay K Calloway
----
While we all appreciate the many helpful posts to get rid of register_globals, maybe you're one
of those who just loves it. More likely, your boss says you just have to live with it because he
thinks it's a great feature.
No problem, just call (below defined):
<?php register_globals(); ?>
anywhere, as often as you want. Or update your scripts!
<?php
/**
* function to emulate the register_globals setting in PHP
* for all of those diehard fans of possibly harmful PHP settings :-)
* @author Ruquay K Calloway
* @param string $order order in which to register the globals, e.g. 'egpcs' for default
*/
function register_globals($order = 'egpcs')
{
// define a subroutine
if(!function_exists('register_global_array'))
{
function register_global_array(array $superglobal)
{
foreach($superglobal as $varname => $value)
{
global $$varname;
$$varname = $value;
}
}
}
$order = explode("\r\n", trim(chunk_split($order, 1)));
foreach($order as $k)
{
switch(strtolower($k))
{
case 'e': register_global_array($_ENV); break;
case 'g': register_global_array($_GET); break;
case 'p': register_global_array($_POST); break;
case 'c': register_global_array($_COOKIE); break;
case 's': register_global_array($_SERVER); break;
}
}
}
?>