note 35238 deleted from security.registerglobals by didou

From: Date: Mon, 25 Aug 2003 12:24:03 +0000
Subject: note 35238 deleted from security.registerglobals by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-55033@lists.php.net to get a copy of this message
Note Submitter: mark@virtualcreations.com.au ---- For all those people out there who are too lazy to rewrite all their code when their host enforces a "no register_globals" policy, I wrote this function to make sure all globals are registered, even if register_globals is turned off. It respects the "variables_order" (EGPCS) parameter as well. Simply run it once, at the start of your script. function always_register_globals() { if (ini_get("register_globals") == 1) return; // // Split the variables_order config variable into its component characters // $chars = preg_split('//', ini_get("variables_order"), -1, PREG_SPLIT_NO_EMPTY); foreach ($chars as $letter) { switch ($letter) { case "E": $glob = "_ENV"; break; case "G": $glob = "_GET"; break; case "P": $glob = "_POST"; break; case "C": $glob = "_COOKIE"; break; case "S": $glob = "_SERVER"; break; } global ${$glob}; $var_glob = &${$glob}; foreach ($var_glob as $varname => $value) { global ${$varname}; ${$varname} = $value; } } }

« previous php.notes (#55033) next »