Superian Posted June 30, 2008 Share Posted June 30, 2008 What are the differences between the two codes or both are doing the same? First Block: <?php if (ini_get('register_globals')) { foreach ($GLOBALS as $int_temp_name => $int_temp_value) { if (!in_array($int_temp_name, array ( 'GLOBALS', '_FILES', '_REQUEST', '_COOKIE', '_SERVER', '_ENV', '_SESSION', ini_get('session.name'), 'int_temp_name', 'int_temp_value' ))) { unset ($GLOBALS[$int_temp_name]); } } } ?> Second Block: <?php if (ini_get('register_globals')) { $allowed = array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'GLOBALS' => 1); foreach ($GLOBALS as $key => $value) { if (!isset($allowed[$key])) { unset($GLOBALS[$key]); } } } ?> Link to comment https://forums.phpfreaks.com/topic/112627-solved-example-please/ Share on other sites More sharing options...
DarkWater Posted June 30, 2008 Share Posted June 30, 2008 They're both "undoing" register_globals which SHOULD BE OFF IN THE FIRST PLACE. @_@ Link to comment https://forums.phpfreaks.com/topic/112627-solved-example-please/#findComment-578413 Share on other sites More sharing options...
Superian Posted June 30, 2008 Author Share Posted June 30, 2008 They're both "undoing" register_globals which SHOULD BE OFF IN THE FIRST PLACE. @_@ I understand. What about the code below? <?php if (ini_get('register_globals')) { foreach ($GLOBALS as $key => $value) { if (!in_array($key, $allowed = array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'GLOBALS' => 1))) { unset($GLOBALS[$key]); } } } ?> Link to comment https://forums.phpfreaks.com/topic/112627-solved-example-please/#findComment-578423 Share on other sites More sharing options...
DarkWater Posted June 30, 2008 Share Posted June 30, 2008 The exact same thing. o-O Link to comment https://forums.phpfreaks.com/topic/112627-solved-example-please/#findComment-578424 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.