Problems that may occur when RegisterGlobals is enabled

Source: Internet
Author: User
I have read the php manual that the global variables are recommended to be disabled, that is, to set regester_globales to off and the manual also provides an example to illustrate what will happen if it is not disabled. The example is as follows, however, the GETauth. php? Authorized1 does not know what it is... SyntaxHighlighte

I have read the php manual and said that global variables are recommended to be disabled, that is, set regester_globales to off.
In addition, the manual provides an example to illustrate the problem if you do not turn it off. The example is as follows.
GET auth. php? What does authorized = 1 mean ??? Hope you can help me.

Example of using register_globals = on

// If the user is valid, the value $ authorized = true is assigned.
If (authenticated_user ()){
$ Authorized = true;
}

// Because $ authorized is not initialized to false in advance,
// When register_globals is enabled, it may use GET auth. php? Authorized = 1 to define the variable value
// Anyone can bypass authentication.
If ($ authorized ){
Include "/highly/sensitive/data. php ";
}
?>
When register_globals = on, the above code is dangerous. If it is off, $ authorized cannot be changed through URL request or other methods, which is much better, even though initialization variables are a good programming habit. For example, if $ authorized = false is added before the preceding code is executed, it can be used whether register_globals is on or off, because the user status is initialized to unauthenticated.


From kaituozhe345

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.