| 3 | | if ( ini_get('register_globals') ) { |
|---|
| 4 | | $superglobals = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET); |
|---|
| 5 | | if ( isset($_SESSION) ) |
|---|
| 6 | | array_unshift($superglobals, $_SESSION); |
|---|
| | 3 | function unregister_GLOBALS() { |
|---|
| | 4 | if ( !ini_get('register_globals') ) |
|---|
| | 5 | return; |
|---|
| | 6 | |
|---|
| | 7 | if ( isset($_REQUEST['GLOBALS']) ) |
|---|
| | 8 | die('GLOBALS overwrite attempt detected'); |
|---|
| | 9 | |
|---|
| | 10 | // Variables that shouldn't be unset |
|---|
| | 11 | $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix'); |
|---|
| 8 | | foreach ( $superglobals as $superglobal ) |
|---|
| 9 | | foreach ( $superglobal as $global => $value ) |
|---|
| 10 | | if ( 'table_prefix' != $global ) |
|---|
| 11 | | unset( $GLOBALS[$global] ); |
|---|
| | 13 | $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array()); |
|---|
| | 14 | foreach ( $input as $k => $v ) |
|---|
| | 15 | if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) |
|---|
| | 16 | unset($GLOBALS[$k]); |
|---|