Just downloaded drupal to check. The file that is called first every time is includes/boostrap.inc, so the code would go in the top of that, however whilst I was looking in the file I noticed they already have a function
PHP Code:
/**
* Unsets all disallowed global variables. See $allowed for what's allowed.
*/
function drupal_unset_globals() {
if (ini_get('register_globals')) {
$allowed = array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'access_check' => 1, 'GLOBALS' => 1);
foreach ($GLOBALS as $key => $value) {
if (!isset($allowed[$key])) {
unset($GLOBALS[$key]);
}
}
}
}
This is called pretty much straight away regardless, so it looks as though the Drupal developers already have it covered and you can probably just ignore the warning message safely and not do anything.
You can still add Warren's code if you like, to the top of that file. I notice the Drupal one allows a fair bit more to remain--not sure how much that affects the safety or whether there will be any problems from clearing more?
It was Drupal 5.7 that I looked at.
Bookmarks