Jump to content

[SOLVED] Example Please!


Superian

Recommended Posts

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

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]);
      }
    }
  }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.