usr-local-ΕΨΗΕΛΩΝ usr-local-ΕΨΗΕΛΩΝ - 1 month ago 20
PHP Question

Reintroduce $HTTP_POST_VARS in PHP 5.3

I need to run a legacy PHP application in a shared hosting environment. I have promised my customer I'll support that legacy application for some time but I found that it doesn't work because it widely uses the deprecated

$HTTP_POST_VARS
.

Downgrading PHP is not an option. Patching the application could be infeasible because the PHP files are generated from a Windows executable file (I'm not kidding!) and every time the site is regenerated from desktop we could lose modifications.

I'm asking if there is a way to tell PHP to reintroduce
$HTTP_POST_VARS
for all websites on a host or just for a particular vhost. Any other option/suggestion is appreciated

Answer

You can do this

config.php

$HTTP_POST_VARS = &$_POST;
$HTTP_GET_VARS = &$_GET;
$HTTP_COOKIE_VARS = &$_COOKIE;

.htaccess

php_value auto_prepend_file /path/to/config.php

PHP doc auto_prepend_file string

Specifies the name of a file that is automatically parsed before the main file. The file is included as if it was called with the require function, so include_path is used.

The special value none disables auto-prepending.

EDIT: To be extra thorough, these are the other superglobals that could also be aliased:

$HTTP_SERVER_VARS = &$_SERVER;
$HTTP_POST_FILES = &$_FILES;
$HTTP_SESSION_VARS = &$_SESSION;
$HTTP_ENV_VARS = &$_ENV;