English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

$database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this-> I'm a bit confused as to the above string can you break it down for me?

2006-11-14 03:25:50 · 2 answers · asked by author 2 in Computers & Internet Programming & Design

2 answers

Chapter 29. Using Register Globals
Perhaps the most controversial change in PHP is when the default value for the PHP directive register_globals went from ON to OFF in PHP 4.2.0. Reliance on this directive was quite common and many people didn't even know it existed and assumed it's just how PHP works. This page will explain how one can write insecure code with this directive but keep in mind that the directive itself isn't insecure but rather it's the misuse of it.

When on, register_globals will inject your scripts with all sorts of variables, like request variables from HTML forms. This coupled with the fact that PHP doesn't require variable initialization means writing insecure code is that much easier. It was a difficult decision, but the PHP community decided to disable this directive by default. When on, people use variables yet really don't know for sure where they come from and can only assume. Internal variables that are defined in the script itself get mixed up with request data sent by users and disabling register_globals changes this. Let's demonstrate with an example misuse of register_globals:

Example 29-1. Example misuse with register_globals = on

// define $authorized = true only if user is authenticated
if (authenticated_user()) {
$authorized = true;
}

// Because we didn't first initialize $authorized as false, this might be
// defined through register_globals, like from GET auth.php?authorized=1
// So, anyone can be seen as authenticated!
if ($authorized) {
include "/highly/sensitive/data.php";
}
?>


There is more on the following link.

2006-11-14 03:42:11 · answer #1 · answered by raecliff95 3 · 1 0

It looks like in the above example, $_SE is (or is at least the beginning) of the variable. $_ is NOT always a variable in PHP like it is in Perl. When I code PHP, I often use $_ to begin private variables in classes, or temporary variables in procedural scripts.

2006-11-14 03:31:51 · answer #2 · answered by Austin S 2 · 0 0

fedest.com, questions and answers