Merge branch '3.2.x'

* 3.2.x:
  [ticket/14818] Optimize generate_board_url function
This commit is contained in:
Tristan Darricau 2016-10-24 23:08:11 +02:00
commit c563fe3cc5
No known key found for this signature in database
GPG key ID: 817043C2E29DB881

View file

@ -1635,13 +1635,6 @@ function generate_board_url($without_script_path = false)
global $config, $user, $request;
$server_name = $user->host;
$server_port = $request->server('SERVER_PORT', 0);
$forwarded_proto = $request->server('HTTP_X_FORWARDED_PROTO');
if (!empty($forwarded_proto) && $forwarded_proto === 'https')
{
$server_port = 443;
}
// Forcing server vars is the only way to specify/override the protocol
if ($config['force_server_vars'] || !$server_name)
@ -1656,6 +1649,13 @@ function generate_board_url($without_script_path = false)
}
else
{
$server_port = $request->server('SERVER_PORT', 0);
$forwarded_proto = $request->server('HTTP_X_FORWARDED_PROTO');
if (!empty($forwarded_proto) && $forwarded_proto === 'https')
{
$server_port = 443;
}
// Do not rely on cookie_secure, users seem to think that it means a secured cookie instead of an encrypted connection
$cookie_secure = $request->is_secure() ? 1 : 0;
$url = (($cookie_secure) ? 'https://' : 'http://') . $server_name;