Related problems when RegisterGlobals is enabled

Source: Internet
Author: User
Regarding the problems that RegisterGlobals will encounter after it is enabled, I have read the php manual that the global variables are recommended to be disabled, that is, set regester_globales to off, and the manual also provides an example, the following is an example of how to disable GETauth. php? What does authorized1 mean ??? I hope you can help me to incorrectly use register_gl. problems you may encounter when Register Globals is enabled
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.


------ Solution --------------------
When regester_globales is enabled in auth. php? Authorized = 1 is not required to use GET
$ Authorized equals to $ _ GET ['authorized']
Can I define your variables through url? is it safe?
Http://bbs.php100.com/read-htm-tid-17163-page-1.html
Http://www.laruence.com/2009/07/13/976.html
This is another example.
------ Solution --------------------
This comment is clear.

// 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 ";
}

If you enable the setting and enable it when determining whether the variable authorized is true, you only need to construct authorized = 1 in the url to obtain the permission that authorized is true.

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.