Migration to 3.2.: How to use $_SERVER in config.php?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
cangor
Registered User
Posts: 86
Joined: Thu Oct 28, 2010 1:56 pm

Migration to 3.2.: How to use $_SERVER in config.php?

Post by cangor »

Hello,

I'm just trying to migrate from 3.0.14 to 3.2.1. I'm working for some phpBB-Servers, but use only one phpBB-codebase. So in the config.php, I'm doing something like:

Code: Select all

if ($_SERVER['HTTP_HOST'] == "example1.com")
{	// set database for example1.com
}
else if ($_SERVER['HTTP_HOST'] == "example2.com")
{	// set database for example2.com
}
Now I get the error-msg: Illegal use of $_SERVER. You must use the request class to access input data.

I understand that for accessing $_SERVER, you should use the class request, like:

Code: Select all

$request->server('HTTP_HOST');
or

Code: Select all

$request->enable_super_globals();
The problem is, that $request is not defnied in config.php, it seems to be initialised later. So what am I supposed to do? Using $request = new phpbb\request\request(); for my own (being aware that it will be set later again)?

Return to “phpBB Custom Coding”