<?php
if (ini_get('register_globals'))
{
$__sgs = array('_ENV', '_GET', '_POST', '_COOKIE', '_SERVER');
foreach ($__sgs as $__sg)
{
$__k = array_keys(${$__sg});
foreach($__k as $__v)
{
if (isset($$__v) && ${$__sg}[$__v] === $$__v)
{
unset($$__v);
} // end if superglobal var = local var
} // end foreach superglobal key
} // end foreach superglobal
} // end if register_globals
?>
Disabling PHP's register_globals in userland
By silfreed - Posted on January 10th, 2008
Tagged: PHP
So you have a large PHP deployment that is (still? - this is 2008!) using register_globals. How do you test individual pieces of the site without being able to change the ini variable via .htaccess? Try this code out:
Delicious
Digg
Reddit
Technorati
Post new comment