Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
For the second part of your question. If you can use .htaccess files then you can enable/disable register globals on a per directory basis with:

php_flag register_globals on

or

php_flag register_globals off

As for my thoughts of running with it on. It depends on how the application is coded. If coded properly, running with register globals on isn't a big deal, but most applications don't quite cut it in this regard.

Here's the problem. Say you have a little script that looks like this:

Code
<br /><?<br /><br />$a = 1;<br />$b = 2;<br /><br />if ($a + $b = 4) {<br />   $c = 1;<br />}<br /><br />if ($c == 1) {<br />   echo "Hey, my math sucks, cuz 1 + 2 does not equal 4!";<br />}<br />?><br />


Now, normally what you'd expect to happen is nothing. Since $a + $b never equals 4 that echo statement will never be executed. But, with register globals on, all somebody would have to do would be to call your script like this:

http://www.yourdomain.com/scriptname.php?c=1

That injects the value for $c right into your script. Even though bit of code that sets $c in your script never gets executed. The problem is, that $c is never predefined and this is the problem with alot of scripts. Properly coded, that script would look like this:

Code
<br /><?<br /><br />// Predefine some variables<br />$c = 0;<br /><br /><br />$a = 1;<br />$b = 2;<br /><br />if ($a + $b = 4) {<br />   $c = 1;<br />}<br /><br />if ($c == 1) {<br />   echo "Hey, my math sucks, cuz 1 + 2 does not equal 4!";<br />}<br />?><br />


So now, even if register globals are on and someone tries to pass $c via the url, the script sets it to 0 at the beginning so that echo line will never be executed.

Hopefully, that makes a bit of sense. I can program but I can't explain things worth a pile of beans


UBB.threads Developer
Sponsored Links
Entire Thread
Subject Posted By Posted
Question about register globals Zackary 03/13/2004 12:44 AM
Re: Question about register globals Rick 03/13/2004 8:33 AM
Re: Question about register globals Zackary 03/13/2004 9:15 AM
Re: Question about register globals Ron M 03/13/2004 10:02 PM
Re: Question about register globals scroungr 03/24/2004 3:46 AM
Re: Question about register globals Rick 03/24/2004 5:45 AM
Re: Question about register globals scroungr 03/24/2004 5:54 AM
Re: Question about register globals dimopoulos 03/24/2004 11:17 AM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Bill B
Bill B
Issaquah, WA
Posts: 87
Joined: December 2001
Forum Statistics
Forums63
Topics37,575
Posts293,931
Members13,824
Most Online6,139
Sep 21st, 2024
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
Gizmo 1
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)