note 106734 deleted from security.globals by tularis
| From: | tularis@php.net | Date: | Fri, 02 Dec 2011 20:02:30 +0000 |
| Subject: | note 106734 deleted from security.globals by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184864@lists.php.net to get a copy of this message | ||
Note Submitter: raphael at engenhosweb dot com dot br
Reason: useless
----
Ok.. Here is my contribuition.
Removes all elements from $GLOBALS which are inside the input superglobals.
<?php
/**
* Must be executed before any other scripts are loaded.
*
* If register_globals are on, unregister globals.
* Second test covers boolean set as string (php_value register_globals off).
*/
function unregister_globals() {
/* Input list. Don't change it */
static $_input = array (
'_POST', '_GET', '_COOKIE', '_SERVER', '_ENV',
'_FILES', '_REQUEST', '_SESSION', 'GLOBALS',
'HTTP_POST_VARS', 'HTTP_GET_VARS', 'HTTP_COOKIE_VARS',
'HTTP_SERVER_VARS', 'HTTP_ENV_VARS', 'HTTP_POST_FILES',
'HTTP_SESSION_VARS',
) ;
if ( ini_get( 'register_globals' ) == false )
return ;
/**
* Remove all globals that are not reserved by PHP
*/
foreach ( array_keys( $GLOBALS ) as $key ) {
if ( in_array( $key, $_input ) == false )
unset( $GLOBALS[ $key ] ) ;
}
return ;
}
?>