I always hear using global variables are dangerous. Does this apply to Drupal? Take a look at the following example:
function myFunction($bla) {
global $user;
if (isAuthenticated($user->uid)) {
print $secretCode;
}
}
Can this be hacked?
Global variables can be dangerous for many reasons, some of which include:
Nothing is particularly threatening about your use case. It should be fine. If you're very scared, you can ensure that $user->uid is an integer before evaluating:
function myFunction($bla) {
global $user;
if( is_int($user->uid) ){
if (isAuthenticated($user->uid)) {
print $secretCode;
}
}
}
But this is probably unnecessary.
No. If you are using session_register, it's possible for an SQL injection. Since that's an ancient method, in PHP 4. Although, a lot of people still use it.