I ran into this problem in a huge code base with thousands of files. Inspired by the solution posted by @sschueller, I tested this auto_prepend_file code that logs cases for investigation. This method should also be used in conjunction with parsing / tokenization to catch all occurrences.
<?php $vars = get_defined_vars(); foreach ($vars as $var => $value) { if (in_array($var, array('$_SERVER', '$_REQUEST', '$_GET', '$_POST', '$_COOKIE', '$_SESSION', '$_FILES', '$_ENV'))) { // only examine the local symbols, not superglobals continue; } if (array_key_exists($var, $_REQUEST) && $value == $_REQUEST[$var]) { error_log(sprintf("register_globals reliance detected in %s for variable %s=%s", $_SERVER['SCRIPT_FILENAME'], $var, $value), 3, "/var/tmp/register_globals.log"); } }
roktechie
source share