Last active
June 1, 2017 15:20
-
-
Save hparadiz/3df6a08b493f8730bbae to your computer and use it in GitHub Desktop.
A function which simulates the register_globals setting from PHP <=5.3 for PHP >=5.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* A function which simulates the register_globals setting from PHP <=5.3 for PHP >=5.4 | |
* Blasphemy I know. Just an example of named functions detailed in https://php.net/manual/en/language.variables.variable.php | |
*/ | |
function register_globals($Order = 'EGPCS') | |
{ | |
$register_globals = function(array &$GlobalArray) | |
{ | |
foreach($GlobalArray as $Variable=>$Value) | |
{ | |
global $$Variable; | |
$$Variable = $Value; | |
} | |
}; | |
for($x=0;$x<5;$x++) | |
{ | |
switch(strtoupper(substr($Order,$x,1))) { | |
case 'E': | |
$register_globals($_ENV); | |
break; | |
case 'G': | |
$register_globals($_GET); | |
break; | |
case 'P': | |
$register_globals($_POST); | |
break; | |
case 'C': | |
$register_globals($_COOKIE); | |
break; | |
case 'S': | |
$register_globals($_SERVER); | |
break; | |
} | |
} | |
} | |
register_globals(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment