Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

register_globals fix [closed]

Tags:

php

hosting

I have a client who has an online shop he would like me to host. The site was written by another develop and uses register globals.

When I uploaded it to my server it told me it required register_globals to be enabled, I checked the .htaccess file and it was. When I asked the hosting company they told me it had been dreprecated and wouldn't run on the server. I'm not sure what parts of the code are dependant on it as I've not looked into the progamming too closely, I was only intending to host it.

Is there a quick fix or am I going to have to take the code apart and fix it with up to date alternatives?

like image 687
HuwD Avatar asked Nov 30 '22 04:11

HuwD


1 Answers

A real ugly but very quick fix is something like the following:

foreach (array('_GET', '_POST', '_COOKIE', '_SERVER') as $_SG) {
    foreach ($$_SG as $_SGK => $_SGV) {
        $$_SGK = $_SGV;
    }
}

Preferably at the top of any php script that can be executed, BEFORE any other code.

Please note, that this is not something I would really recommend. Please try to persuade your client(s) that they should get something better. If code requires register_globals, chances are that it's as insecure as hell...

like image 160
Johannes Konst Avatar answered Dec 06 '22 11:12

Johannes Konst