December 17, 2009

register_global on in windows

http://www.oldcoconut.com/?cat=5


For those domain hosted in Windows IIS, you will get a headache when you wish to turn on something on the php just for your domain script by not effecting other domain or application hosted on the same server which requires the default settings which is turned off.

Eg:

Both domain A and B is hosted on the IIS Server.
Domain A : requires register_globals turned ON
Domain B : requires register_globals turned OFF
Default PHP.ini : register_globals turned OFF.

On the above scenario, domain B is having problem as the register_globals is already turned OFF. Domain A will be having problems.

As the research found, domain A’s programmer will need to recode the application to suit the environment codes. This will be easy for those which is having less files. What if the domain is having 1K files?!..Well, good luck to the developer!

There is a trick behind to solve such issue. Rather than recode your application, download another php engine and place it on the same server. PHP engine is quite a wonderful engine where it do allow you to have multiple engine on the same server with either sharing the same php.ini (what’s the point?!) or different php.ini (that is good).

How to do it?

Well, rather simple. Here are some below hints:

1. Check on your existing PHP engine. Make sure the php engine is referring to the php.ini file which is located in its own directory instead of in C:\windows\system32 OR referring to registry at HKEY_LOCAL_MACHINE\SOFTWARE\PHP. Of course not all php engine can support it. *Upgrade your php engine to the latest version.
2. Clean up unwanted php.ini resource in C:\Windows\system32 or remove the registry which is stores the php.ini path in HKEY_LOCAL_MACHINE\SOFTWARE\PHP registry.
3. Download the PHP engine for another domain. Extract it and rename it as another folder such as “PHP4-RegisterGlobals-ON”. Make sure the php.ini is in the folder rather than in the registry or C:\Windows\System32
4. Update the php extension mapping for the domain to refer to the new php path instead of the old one for domain A via IIS management console. If you are using IIS 5.0 and above, make sure you grant the new php.exe execution in “Web Server Extension”.
5. Edit the php.ini to enable the register_globals. Save it once it is done (LOL).
6. Test the domain A. Should be no problem if everything went smoothly.

*Not all php version do support on multiple engine on the same server. Make sure you upgrade to the latest one. When upgrade it, it is recommended to upgrade to the same family rather than different family.

No comments:

Post a Comment